# Discourse API: Get Categories Related to Posts

**URL:** https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498
**Category:** Development
**Created:** [20 באוקטובר,‏ 2019,‏ 5:17pm UTC](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498 "2019-10-20T17:17:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Magnetidog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magnetidog/32/116910_2.png) [@Magnetidog](https://meta.discourse.org/u/Magnetidog)
#### Post date: [20 באוקטובר,‏ 2019,‏ 5:17pm UTC](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498/1 "2019-10-20T17:17:08Z")

</div>

Hello!

I am developing a search autocomplete external to Discourse, to be used in other websites connected to our network, where I will be able to output in the same autcomplete a mix of results from Discourse and from other sources (in particular with shop results).

I am using the Discourse API for Search, and I can get posts, topics, and blurbs without issues. The only information I am missing right now is the category name and possibly “color”, as it is shown in the search popup within Discourse.

Is there some way to get categories connected to the posts **through a single API request**? Or should I devise some alternate method?

The only way I can use right now is to send two different queries, one for the category list, the other for the actual forum search.

Thanks.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [22 באוקטובר,‏ 2019,‏ 4:38pm UTC](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498/2 "2019-10-22T16:38:38Z")

</div>

You will need to use a separate api call to get a list of categories, but that is probably something you can cache locally somehow so that you won’t have to query for it along with every search query.

---

<div class="post-metadata">

### Author: ![Magnetidog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/magnetidog/32/116910_2.png) [@Magnetidog](https://meta.discourse.org/u/Magnetidog)
#### Post date: [22 באוקטובר,‏ 2019,‏ 6:06pm UTC](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498/3 "2019-10-22T18:06:27Z")

</div>

Blake, thanks for your reply. Indeed, this is the route I went - locally cached categories.

For people doing similar stuff to what I am doing: since in my case I needed all the categories and subcategories, I also ended up using the site.json API point instead of categories.json (which seems to return only top level categories).
