pyngrok

A Python wrapper for ngrok that manages its own binary and tunnels

SDK
PyPI
v8.1.2
464stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity76
Maintenance76
Community52
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality85
Innovation76
Learning Curve88

pyngrok is a Python wrapper for ngrok, the reverse proxy that opens secure tunnels from public URLs to localhost. It manages its own ngrok binary (downloading and installing it automatically) and exposes ngrok through a convenient Python API as well as the command line, so you can open, inspect, and close tunnels programmatically without hand-managing the ngrok process.

pyngrok is ideal for testing webhooks, demoing local sites, enabling SSH access, and building ingress into development environments. A simple ngrok.connect() call returns a NgrokTunnel object with the generated public URL, and the library also handles configuration, authentication tokens, process lifecycle, and log event capture.

What You Get

  • A Python API to open, list, and close ngrok tunnels programmatically
  • Automatic download and management of the correct ngrok binary
  • Process supervision with access to ngrok log events and errors
  • Configuration and auth-token handling for ngrok accounts
  • A command-line interface mirroring the Python API

Common Use Cases

  • Exposing a local web server to a public URL for webhook testing
  • Demoing a work-in-progress site to remote stakeholders
  • Enabling temporary SSH or TCP access into a development machine
  • Integrating public tunnels into automated tests and CI pipelines

Under The Hood

Architecture - The pyngrok package is compact and role-organized: ngrok.py holds the public API (connect, disconnect, kill, get_tunnels) and the NgrokTunnel object, process.py starts and supervises the ngrok subprocess and streams its log events, installer.py downloads and installs the platform-appropriate ngrok binary, conf.py manages configuration and the ngrok config file, agent.py talks to ngrok’s local agent API, and exception.py and log.py provide typed errors and structured logging. The CLI is wired through the same public functions.

Tech Stack - Pure Python packaged with modern pyproject.toml tooling. It shells out to and manages the real ngrok binary rather than reimplementing the protocol, communicating with ngrok’s local web/agent interface to enumerate tunnels. It targets current Python 3 versions and is also distributed via conda-forge.

Code Quality - The project is well maintained: it reports coverage via Codecov, a Codacy code-quality grade, ReadTheDocs documentation, and a tests directory with a CI build workflow. It ships a SECURITY.md and CONTRIBUTING guide and follows consistent, documented naming across its small module set.

API Design - The API is intentionally minimal and beginner-friendly - a single ngrok.connect() opens a tunnel and returns an object whose public_url attribute is the generated address. Thorough ReadTheDocs docs, copy-paste README examples, and a mirrored CLI make the learning curve very shallow; the main external concept is ngrok itself (auth tokens, tunnel types).

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search