# Using the API to get category\_id by slug or name

**URL:** https://meta.discourse.org/t/using-the-api-to-get-category-id-by-slug-or-name/48894
**Category:** Development
**Created:** [19 Agosto, 2016 19:49 UTC](https://meta.discourse.org/t/using-the-api-to-get-category-id-by-slug-or-name/48894 "2016-08-19T19:49:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mb450](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mb450/32/121465_2.png) [@mb450](https://meta.discourse.org/u/mb450)
#### Post date: [19 Agosto, 2016 19:49 UTC](https://meta.discourse.org/t/using-the-api-to-get-category-id-by-slug-or-name/48894/1 "2016-08-19T19:49:57Z")

</div>

Hi all

Is there a way to get a category’s id by either it’s name or slug?  
I’ve got an admin area that needs to post to discourse when a record is edited.

I’ve found the /categories.json call but that will grow over time and I don’t want to have to iterate over the results.

Anyone got any ideas?

Thanks

Matt

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [19 Agosto, 2016 19:52 UTC](https://meta.discourse.org/t/using-the-api-to-get-category-id-by-slug-or-name/48894/2 "2016-08-19T19:52:44Z")

</div>

[https://meta.discourse.org/c/dev/show.json](https://meta.discourse.org/c/dev/show.json) (Open in a new tab)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [21 Agosto, 2016 02:54 UTC](https://meta.discourse.org/t/using-the-api-to-get-category-id-by-slug-or-name/48894/3 "2016-08-21T02:54:33Z")

</div>

> [@mb450](#):
>
> I’ve found the /categories.json call but that will grow over time and I don’t want to have to iterate over the results.

The JS uses the information at /site.json for the list of “all categories that I’m allowed to know about”. (It’s just inserted into the HTML instead of requested at that URL.)
