# A way to list the loaded environments from the command line with non-self-hosted zrok?

**URL:** <https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412>\
**Category:** zrok\
**Created:** [July 19, 2023, 2:54pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412 "2023-07-19T14:54:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![twisteddog99](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/twisteddog99/32/1120_2.png) [@twisteddog99](https://openziti.discourse.group/u/twisteddog99)\
**Post date:** [July 19, 2023, 2:54pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/1 "2023-07-19T14:54:48Z")

</div>

Hi there,  
I just started looking into zrok as ngrok was so limited and I’m loving the functionality. However I have just one question:  
On my development machine I have zrok enabled and connected to my account.  
On a remote machine (docker container) I automatically enable zrok and have it start (private) sharing a rest api endpoint.  
I’m looking for a way to (programmatically via the cli) get a list of other open environments on my zrok account which would include the one running from the docker container on the development machine. This way I can get the share token and open a share programmatically from the dev machine.  
After looking at all the commands avaliable I found only this one:  
`./zrok admin list frontends` but it returns the following error:

```auto
goroutine 1 [running]:
main.(*adminListFrontendsCommand).run(0x0?, 0x0?, {0x0?, 0x0?, 0x0?})
	/Users/runner/work/zrok/zrok/cmd/zrok/adminListFrontends.go:47 +0x5d3
github.com/spf13/cobra.(*Command).execute(0xc000178300, {0x102ebbbc8, 0x0, 0x0})
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x102e70140)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
main.main()
	/Users/runner/work/zrok/zrok/cmd/zrok/main.go:98 +0x25

```

I’m running the non-self hosted version of zrok.  
Can’t find anything in the docs about how to do this, although maybe I’ve overlooked something.  
Thanks,  
T

---

<div class="post-metadata">

**Author:** ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)\
**Post date:** [July 19, 2023, 3:02pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/2 "2023-07-19T15:02:13Z")

</div>

Hey T…

I’m the lead developer building `zrok`. There’s not currently a way to do this from the CLI. I’ll get it on the backlog and get something pulled together. Can’t promise exactly when, but I’ll try and get it it knocked out sometime relatively soon.

In the meantime, if you were so motivated, you could hit the API directly and query these details. There are already API endpoints to handle all of this (the web console uses them).

Setting up API auth is pretty straightforward… it’s just the enable token from your account. If you wanted to pursue that, and need any clarification, let me know.

Q

---

<div class="post-metadata">

**Author:** ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)\
**Post date:** [July 19, 2023, 3:07pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/3 "2023-07-19T15:07:14Z")

</div>

The API endpoint you’d want to use is `/api/v1/overview`… it returns:

```auto
{
  "accountLimited": true,
  "environments": [
    {
      "environment": {
        "description": "string",
        "host": "string",
        "address": "string",
        "zId": "string",
        "activity": [
          {
            "rx": 0,
            "tx": 0
          }
        ],
        "limited": true,
        "createdAt": 0,
        "updatedAt": 0
      },
      "frontends": [
        {
          "id": 0,
          "shrToken": "string",
          "zId": "string",
          "createdAt": 0,
          "updatedAt": 0
        }
      ],
      "shares": [
        {
          "token": "string",
          "zId": "string",
          "shareMode": "string",
          "backendMode": "string",
          "frontendSelection": "string",
          "frontendEndpoint": "string",
          "backendProxyEndpoint": "string",
          "reserved": true,
          "activity": [
            {
              "rx": 0,
              "tx": 0
            }
          ],
          "limited": true,
          "createdAt": 0,
          "updatedAt": 0
        }
      ]
    }
  ]
}

```

There is an OpenAPI spec in `specs/zrok.yml`, if that’s helpful.

---

<div class="post-metadata">

**Author:** ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)\
**Post date:** [July 19, 2023, 3:09pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/4 "2023-07-19T15:09:36Z")

</div>

Actually… would you be happy with raw JSON output listed above? If so, I could probably add a `zrok overview` command, which would spit those details out in about 10 minutes. 🙂

Would that solve your problem?

---

<div class="post-metadata">

**Author:** ![twisteddog99](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/twisteddog99/32/1120_2.png) [@twisteddog99](https://openziti.discourse.group/u/twisteddog99)\
**Post date:** [July 19, 2023, 3:14pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/5 "2023-07-19T15:14:18Z")

</div>

Hi Michael,  
I’m happy just making a request to the api using the details you provided.  
Thanks so much,  
T

---

<div class="post-metadata">

**Author:** ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)\
**Post date:** [July 19, 2023, 3:18pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/6 "2023-07-19T15:18:04Z")

</div>

That works. I’m adding `zrok overview` also. Will be released with `v0.4.3`. I bet there’ll be other people who need that who don’t want to hit the API themselves. 👍

---

<div class="post-metadata">

**Author:** ![michael.quigley](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/michael.quigley/32/1123_2.png) [@michael.quigley](https://openziti.discourse.group/u/michael.quigley)\
**Post date:** [July 19, 2023, 3:30pm UTC](https://openziti.discourse.group/t/a-way-to-list-the-loaded-environments-from-the-command-line-with-non-self-hosted-zrok/1412/7 "2023-07-19T15:30:02Z")

</div>

Coming in `v0.4.3`:

```auto
$ zrok overview | jq
{
  "environments": [
    {
      "environment": {
        "address": "127.0.0.1",
        "createdAt": 1689356838275,
        "description": "michael@ziti-lx",
        "host": "michael; ziti-lx; linux; ubuntu; debian; 22.04; 5.19.0-46-generic; x86_64",
        "updatedAt": 1689356838275,
        "zId": "d4B6CfRY.8"
      },
      "shares": [
        {
          "backendMode": "proxy",
          "backendProxyEndpoint": "http://localhost:8080",
          "createdAt": 1689780534706,
          "frontendEndpoint": "http://w5uufq60mfxk.zrok.quigley.com:8080",
          "frontendSelection": "public",
          "shareMode": "public",
          "token": "w5uufq60mfxk",
          "updatedAt": 1689780534706,
          "zId": "4aysJ01hg0bnG81js7Zq5K"
        }
      ]
    }
  ]
}

```
