# connect api rancher by CLI

**URL:** https://forums.suse.com/t/connect-api-rancher-by-cli/36269
**Category:** SUSE Rancher Prime
**Created:** [November 24, 2021, 4:04am UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269 "2021-11-24T04:04:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![isael](https://avatars.discourse-cdn.com/v4/letter/i/8edcca/32.png) [@isael](https://forums.suse.com/u/isael)
#### Post date: [November 24, 2021, 4:04am UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269/1 "2021-11-24T04:04:20Z")

</div>

I’m trying to connect to the rancher’s api because I want to make a CLI to view my cluster and pods (their status) but all attempts I made from unauthorized even passing the token, is it possible to do this CLI? Can someone give me an example, or if I can even connect it to the rancher’s api

---

<div class="post-metadata">

### Author: ![andreasd](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@andreasd](https://forums.suse.com/u/andreasd)
#### Post date: [November 25, 2021, 3:23pm UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269/2 "2021-11-25T15:23:39Z")

</div>

I am a newbie myself at using the API, but this is an example that at least gives me data back.

> curl -X GET -H “Authorization: Bearer token-xxx:yyyyy” [https://rancher-test.fqdn/v3/clusters/c-dgcsk](https://rancher-test.fqdn/v3/clusters/c-dgcsk)

So far I have yet to PUT or POST anything.

Note, I have had no luck with a token limited to anything, only the global access one seem to work. I hope that helps somewhat.

---

<div class="post-metadata">

### Author: ![wcoateRR](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/wcoaterr/32/8144_2.png) [@wcoateRR](https://forums.suse.com/u/wcoateRR)
#### Post date: [November 29, 2021, 3:39pm UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269/3 "2021-11-29T15:39:30Z")

</div>

[Using the Rancher Command Line Interface](https://rancher.com/docs/rancher/v2.6/en/cli/) seems like your easiest, but you can poke through [Rancher Docs: API](https://rancher.com/docs/rancher/v2.6/en/api/) too if you need something past that.

---

<div class="post-metadata">

### Author: ![andreasd](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@andreasd](https://forums.suse.com/u/andreasd)
#### Post date: [December 15, 2021, 10:38am UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269/4 "2021-12-15T10:38:04Z")

</div>

The Rancher CLI is stupidly limited. You can’t really do much with it. But, it’s worth mentioning.

---

<div class="post-metadata">

### Author: ![wcoateRR](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/wcoaterr/32/8144_2.png) [@wcoateRR](https://forums.suse.com/u/wcoateRR)
#### Post date: [December 15, 2021, 2:57pm UTC](https://forums.suse.com/t/connect-api-rancher-by-cli/36269/5 "2021-12-15T14:57:38Z")

</div>

I haven’t tried it yet. Still playing around on other things and my task right now is proof-of-concept & documentation & things of that nature.

However, re-reading the original question, I think a part of an issue might be that I don’t think Rancher itself knows about what’s on the downstream clusters. So I think if you’re trying to look at everything running in downstream, then it’s likely that using Rancher API or CLI to get a list of clusters and kubeconfig files for the clusters and then using kubectl on that list of clusters seems like it might be the way to go for that level of detail & info.
