# How to get user api\_key based on user\_id?

**URL:** https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416
**Category:** Development
**Created:** [February 15, 2017, 11:26am UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416 "2017-02-15T11:26:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mrrao](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mrrao](https://meta.discourse.org/u/mrrao)
#### Post date: [February 15, 2017, 11:26am UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416/1 "2017-02-15T11:26:54Z")

</div>

I can see that admin can create api\_key for individual user. I want to get api\_key for a particular user. How can i do that. Some one please help me to resolve this.

Thanks

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [February 16, 2017, 12:08am UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416/2 "2017-02-16T00:08:31Z")

</div>

If the user has an api\_key, it will be returned when you make an authenticated GET request to `/admin/users/:user_id.json`.

---

<div class="post-metadata">

### Author: ![mrrao](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mrrao](https://meta.discourse.org/u/mrrao)
#### Post date: [February 16, 2017, 9:27am UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416/3 "2017-02-16T09:27:59Z")

</div>

Thanks for your support. This solution working fine. Is there any way to get api\_key by sending api call to users/list/active.json end point?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [February 16, 2017, 6:05pm UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416/4 "2017-02-16T18:05:11Z")

</div>

Maybe try

`/admin/api/keys.json`

IMHO asking for only the information you’re interested in would be more efficient

Well, it also has the `avatar_template` that you won’t likely be interested in. But still.

---

<div class="post-metadata">

### Author: ![mrrao](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mrrao](https://meta.discourse.org/u/mrrao)
#### Post date: [February 17, 2017, 6:57am UTC](https://meta.discourse.org/t/how-to-get-user-api-key-based-on-user-id/57416/5 "2017-02-17T06:57:54Z")

</div>

@Mittineague I tried /admin/api/keys.json and i’m getting api keys. But it hard to iterate through entire list to get particular user api\_key.
