GithubHelp home page GithubHelp logo

ngrok-api-python's Introduction

ngrok API client library for Python

This library wraps the ngrok HTTP API to make it easier to consume in Python.

Installation

This library is published on PyPi:

pip install ngrok-api

Support

The best place to get support using this library is through the ngrok Slack Community. If you find any bugs, please contribute by opening a new GitHub issue.

Documentation

A quickstart guide and a full API reference are included in the ngrok python API documentation.

Quickstart

Please consult the documentation for additional examples.

import ngrok

# Construct the API client
client = ngrok.Client("<API KEY>")

# List all online tunnels
for t in client.tunnels.list():
    print(t)

# Create an IP policy that allows traffic from some subnets
policy = client.ip_policies.create()
for cidr in ["24.0.0.0/8", "12.0.0.0/8"]:
    client.ip_policy_rules.create(cidr=cidr, ip_policy_id=policy.id, action="allow")

ngrok-api-python's People

Contributors

bobzilladev avatar ck-ward avatar inconshreveable avatar krwenholz avatar marcelchampagne avatar ngrok-bors-ng[bot] avatar russorat avatar wdawson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ngrok-api-python's Issues

Starting a simple tunnel

Just found this repo / pypi package. Really nice to see this available.

Just one minor question, since the documentation is quite technical, and does not refer to functionality but only to technical features.
I want to use this library to create a tunnel like I do during normal development on a daily basis, using the cli: ngrok http 5000. But I cannot find the actual endpoint that I need to use for that. Is this even possible, or is there more to it?

difficult installation of the ngrok api due to requests dependency specification

The ngrok-api package hard-specifies a version of requests, which is 2 years back. This specification model causes problems with pip and especially poetry. Pip displays a warning during installation if a newer application package is installed in the virtual environment. Poetry prohibits installation.

Because no versions of ngrok-api match >0.8.0,<0.9.0
 and ngrok-api (0.8.0) depends on requests (2.25.1), ngrok-api (>=0.8.0,<0.9.0) requires requests (2.25.1).
And because [...] depends on requests (>=2.28.2,<3.0.0)
 and no versions of [...] match >1.1.2,<2.0.0, ngrok-api (>=0.8.0,<0.9.0) is incompatible with [...] (>=1.1.2,<2.0.0).
So, because [xxxx] depends on both [...] (^1.1.2) and ngrok-api (^0.8.0), version solving failed.

I would like to implement one of the 2 following solutions :

Strategy 1 : Could you declare this dependency by authorizing the use of intermediate version (^2.25.1 instead of ==2.25.1). Knowing that in case of warning with pip, this is already what is done. We're running ngrok-api with a newer version of requests ?

Strategy 2 : Could you update the requests package used more regularly ?

Thanks a lot for your work.

Cannot install ngrok-api and ngrok packages at the same time

Replication:

  • Install the ngrok SDK pip install ngrok
  • Install the ngrok API client pip install ngrok-api
  • Create a new file called test.py
    import ngrok
    
    ngrok.forward("http://localhost:8080")
  • python test.py

Results in:

Traceback (most recent call last):
  File "test/test.py", line 3, in <module>
    ngrok.forward("http://localhost:8080")
    ^^^^^^^^^^^^^^
AttributeError: module 'ngrok' has no attribute 'forward'

Cause

The package ngrok and ngrok-api both contain the same published package folder ngrok. ngrok-api seems to take precedence:

ls python3.11/site-packages/ngrok
__init__.py     __main__.py     __pycache__     client.py       datatypes.py    error.py        http_client.py  iterator.py     mypy.ini        ngrok.abi3.so   ngrok.pyi       ngrok_parser.py py.typed        services.py     utils.py

Suggested fix

Update this package to expose the package directory ngrok_api which might be a better choice.

Unable to setup up ngrok tunnel

I am not able to setup ngrok tunnel
bellow is the error I am facing
The ngrok process errored on start: Your ngrok-agent version "2.3.41" is too old. The minimum supported agent version for your account is "3.2.0". Please update to a newer version with ngrok update, by downloading from https://ngrok.com/download, or by updating your SDK version. Paid accounts are currently excluded from minimum agent version requirements. To begin handling traffic immediately without updating your agent, upgrade to a paid plan: https://dashboard.ngrok.com/billing/subscription.\r\n\r\nERR_NGROK_121\r\n.

Please let me know if there is any temprory fix
I have tried updating the ngrok version in the pip packge

KeyError: 'ns_targets' when creating a reserved domain

When I create a reserved domain, I get the following error while the domain is created in ngrok.

>>> import os
>>> import ngrok
>>> ng = ngrok.Client(os.getenv('API_KEY'))
>>> ng.reserved_domains.create(name="test.example.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/takehiko.kodama/Documents/test/ngrok/env/lib/python3.9/site-packages/ngrok/services.py", line 2487, in create
    return ReservedDomain(self._client, result)
  File "/Users/takehiko.kodama/Documents/test/ngrok/env/lib/python3.9/site-packages/ngrok/datatypes.py", line 2694, in __init__
    ReservedDomainCertStatus(client, props["certificate_management_status"])
  File "/Users/takehiko.kodama/Documents/test/ngrok/env/lib/python3.9/site-packages/ngrok/datatypes.py", line 2849, in __init__
    ReservedDomainCertJob(client, props["provisioning_job"])
  File "/Users/takehiko.kodama/Documents/test/ngrok/env/lib/python3.9/site-packages/ngrok/datatypes.py", line 2907, in __init__
    if props["ns_targets"] is not None
KeyError: 'ns_targets'

Ngrok unable to delete tunnel sessions

ngrok-api 0.10.0

if __name__ == "__main__":
    client = ngrok.Client("<token>")
    for ses in client.tunnel_sessions.list():
        client.tunnel_sessions.stop(ses.id)

ngrok.error.Error: (Error(...), 'You did not provide a Content-Type with your request. Please check your API client implementation and use one of the supported content types: https://ngrok.com/docs/api#content-types')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.