Im quite new to Python and APIs, but anyway.
Im trying to only print out the running tunnels public url that use the TCP protocol from ngrok API. I have got it to print all my running tunnels urls, but not specific protocols.
How could i modify this code to print only the TCP protocol tunnels public urls i have running?
import ngrok
client = ngrok.Client("API KEY HERE")
for tunnels in client.tunnels.list():
print(tunnels.public_url)
I'm using this documentation
CodePudding user response:
Following the documentation of ngrok's python api it seams that each tunnel has it's proto
property
https://python-api.docs.ngrok.com/datatypes.html#ngrok.datatypes.Tunnel.proto
for tunnel in client.tunnels.list():
if tunnel.proto == 'tcp':
print(tunnel.public_url)