# How do I get subcategory details by Slug using Discourse API?

**URL:** https://meta.discourse.org/t/how-do-i-get-subcategory-details-by-slug-using-discourse-api/216117
**Category:** Development
**Tags:** rest-api
**Created:** [January 26, 2022, 7:39pm UTC](https://meta.discourse.org/t/how-do-i-get-subcategory-details-by-slug-using-discourse-api/216117 "2022-01-26T19:39:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yilin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yilin/32/247624_2.png) [@yilin](https://meta.discourse.org/u/yilin)
#### Post date: [January 26, 2022, 7:39pm UTC](https://meta.discourse.org/t/how-do-i-get-subcategory-details-by-slug-using-discourse-api/216117/1 "2022-01-26T19:39:19Z")

</div>

Hi,  
I created a parent category with slug “testparent” and a sub category with slug “testsub”. When I use `/c/testparent/show.json`, it could get the detail of the parent category properly. But when I use `/c/testsub/show.json`, it gives me below error

 ![Screen Shot 2022-01-26 at 11.36.20 AM](https://global.discourse-cdn.com/meta/original/3X/5/8/5871f72eb952140eb280b2fa6c891a2469e81587.png)

What is the api to get subcategory details? Thanks.

---

<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: [January 26, 2022, 7:48pm UTC](https://meta.discourse.org/t/how-do-i-get-subcategory-details-by-slug-using-discourse-api/216117/2 "2022-01-26T19:48:17Z")

</div>

I think the canonical URL for that is by ID, so `/c/ID/show.json` will work with both parent and children categories.

You can do the slug → ID translation by parsing the response from `/site.json`.

---

<div class="post-metadata">

### Author: ![yilin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yilin/32/247624_2.png) [@yilin](https://meta.discourse.org/u/yilin)
#### Post date: [January 27, 2022, 12:10am UTC](https://meta.discourse.org/t/how-do-i-get-subcategory-details-by-slug-using-discourse-api/216117/3 "2022-01-27T00:10:15Z")

</div>

Thanks a lot for your help. Just an update for what I found by reverse engineering minutes ago. I happen to see that `/c/testparent/testsub/find_by_slug.json` could get me subcategory details by slug.
