Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.63 KB

README.md

File metadata and controls

62 lines (43 loc) · 1.63 KB

Ngrok.AgentAPI

NuGet version ngrok Agent version

Simple library to use the ngrok Agent API. Start and stop tunnels programmatically.

How to use

Step 1: Run ngrok via external console or background service

Before you start using ngrok in your NET project, you need to make sure that ngrok is running. If not, run ngrok using the console, a script, or a background service.

ngrok start --none;

Step 2: Start a new instance of the NgrokAgentClient

In your NET project, create a new instance of NgrokAgentClient as follows.

using Ngrok.AgentAPI

api = new NgrokAgentClient();

Step 3: Call any method

Example:

// List all tunnels and do something
var resource = api.ListTunnels();
if(resource.Tunnels != null){
    foreach (var tunnel in list.Tunnels)
    {
        var tunnelName = tunnel.Name;
        // ...
    }
}

Example:

// Start a new HTTP tunnel on port 5000 using http and https schemes
var configuration = new HttpTunnelConfiguration("MyLocalWebsite", "https://localhost:5000")
{
    Schemes = new string[] { "http", "https" },
    HostHeader = "localhost:5000"
};
var myTunnel = api.StartTunnel(configuration);

See also

To see the list with all the methods, see the official webpage of the ngrok agent API documentation.

License

MIT