Using the API to get category_id by slug or name


(Matt) #1

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


(Rafael dos Santos Silva) #2

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


(Kane York) #3

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.)