Discourse API Documentation



I just realized that by passing the category id I only get 30 topics per category. How can I get the list of all the topics (or topic id’s) in a category? Can I paginate the results somehow?

(Blake Erickson) #224

Yep, just add &page=2 to the url like:



Thanks! I noticed that the last result of ‘/c/id.json?no_subcategories=false&page=0’ is the same as the first result in ‘/c/id.json?no_subcategories=false&page=1’ in case of multiple categories. The last result of page=1 is not duplicated on page=2 though. Is there a reason for this or is this a bug?

(Blake Erickson) #226

Yes, I think when the last result of page 0 shows up as the first result of page 1 but not on subsequent pages is a bug. A also think this may have come up before somewhere else on meta.

(Dylan Hunt) #227

What’s with the unset {{$guid}} {{$guid}} 's? I can’t seem where to find this in the Postman tutorial above.

Also, why doesn’t Postman contain all the required fields? Seems that half the stuff is left out (strange to add only some of the required fields).

Then category id (int)? not name (str)? How can I find this? it’s not in the url

Where do i post the body of the message? replace the random guid’s unset vars?

Overall, pretty confused with intro docs when trying to test by posting a new topic :confused:

(Ryan Odening) #228

thanks for sharing! the line I pasted above doesn’t work for me, though. It’s a very important one.

EDIT: ok. actually like I see some stuff. but any chance we can get a json version of this?
that would be tiiiiiiiiiiiight.

(Ryan Odening) #229

also, i noticed that badges in user is not up to date

(Frank Bailey) #230

Is there an API call I can make to retrieve a simple count of all users registered on my Discourse site?


You could do a get call on about.json and pull the user_count out of that.

For example: https://meta.discourse.org/about.json


(Frank Bailey) #232

Haha, that’s awesome. Give exactly what I need. Thanks a ton Mike!


Under the current build 2.0.0.beta1, badges are not working at all via API (curl). I’m getting a 400 error or this:
The requested URL or resource could not be found.

Is anyone else having issues with badge requests via the API? Categories, etc. seem to work fine.


UPDATE: it turns out there are some minor type-os in the API Documentation. Specifically, the call for assigning a badge to a user needs to updated to reflect “user-badges” instead of a “user_badges”:

As I sift through additional calls, I’ll update as things come up. Is there anther channel to commit updates to the documentation or is this thread the best place to do so?

(Jeff Atwood) #235

Sure let @oblakeerickson know.

(Blake Erickson) #236

I’ve updated the user-badges.json route in the documentation. Thank you for lettings us know about it :slight_smile:.

If you find any more updates that need to be made just let me know or you can always submit a PR to the api docs repo.

(Erlend Sogge Heggen) #237

Updating the API with missing or outdated API calls is something that frequently comes up as a contributor-friendly task. Would be great to have a #howto that covers the most common API contributions,


I found one today that was missing - how to pin a topic via the api

full post url / status

Shall I add a PR for it?

Would be good however to have that PUT Request as just domain.com/t/id/status rather than domain.com/t/post-slug/id but that is prob more of a feature request more than anything. Thoughts?

Ignore me - you dont need the slug you can just use the /t/id/status

(Blake Erickson) #239

Yes please! That would be awesome. There are instructions in the README, but I will work on a #howto later, please reach out if you need any help though.

I think this has been brought up before somewhere, but there is a little “hack” you can do: just replace the slug with a dash - (any character actually) and the rails router will still find the topic by just the ‘id’.

(Tomasz Lotocki) #240

@oblakeerickson I had an issue with the latest postman relese, it looks like you need to set up enviroment by hand and then importing collection will work.

Otherwise Postman will complain about invalid file format.

(Blake Erickson) #241

Thanks for letting me know, but I’m not totally sure what you mean

However, this is why I specified this in the instructions:

Could you not import the environment file and had to manually create it?


I have found had to import via settings section rather than main import option before as wouldnt work. Might be worth trying it that way. Think there was an issue with postman itself