How to reverse engineer the Discourse API

Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api.

Many of the endpoints are properly documented in the [discourse_api][1] gem, however some endpoints lack documentation.

To determine how to do something with the JSON API here are some steps you can follow.

Example: recategorize a topic.

  • Go to a topic and start editing a category:

  • Open Chrome dev tools, switch to the Network tab, select XHR filter:

  • Perform the operation

  • Look at preview as well to figure out the results

  • You now have all the info you need.
  1. The endpoint is http://try.discourse.org/t/online-learning/108.json

  2. Payload is passed using a PUT

  3. The parameter sent is: category_id: 5

Equipped with this information you can make your own calls using your favorite programming language. All you need to do is add your Api-Username and Api-Key to the request headers. (See Discourse API Documentation for details about how to forumlate a curl reqest to the Discourse API.)

API credentials can be generated from the Admin / API tab:

[1]: GitHub - discourse/discourse_api: Ruby API for Discourse2020-06-11T17:00:00Z

57 Likes
Discourse API Documentation
Discourse API Documentation
How do I get all posts from a specific category?
Assign group permission to a category via API
Delete Post from a Topic Using discourse API
Is there an API for changing a password?
Get list of wiki editors
Add a user to a group via API?
How can i set posting option through api?
Dev Category sidebar
Discourse API Documentation Released!
API: Getting all posts in a topic
Custom permalinks
Change ownership through the API?
Integrating Discourse with a larger social network app?
Calling POST on /posts.json returns null
Is there a way to see hourly post data?
Exclude / Suppress (Automatically) Closed Topics from the Homepage?
Correct method for updating category group permission level via API
Api documentation on creating private forums
Api documentation on creating private forums
Changed API for directory_items
Add category moderators with the API?
Tickets Plugin :tickets:
Topic Status API
Problem creating a category using the API
Bulk change setting - want to enable accepted solution for multiple subcategories
How to remove tags via API
Seeding a new forum by creating users and content
Open composer for existing topic/personal message via URL
Adding user to group from API gets "BAD CSRF"
Discourse always posts in general using API
User API only shows 3 badges
API call to unmask all emails
Approving an already-existing user through API?
API for Category based notification level update
Trust Level Requirements from API
Struggling with pagination within search/query.json
How to get unread notification / topic count via API?
Check_username api endpoint seems to not work correctly
Poor Notifications API documentation
Reset avatar in sync SSO
How to set user's location string with Discourse API
How to remove someone from a Message?
Replying to PM via API not working anymore
API - Get topics a user is active in
Can I update the user field automatically via API or otherwise?
No way to get period stats?
500 or 400 when updating the content of a post using the API
Apis for bookmarking post and topic, and removing them as well
Not generate topic automatically for all blog posts
Get Categories detalis by categories name
API: fetch all users with external id info
Update theme with API
Is there a way to check validity of a new username via the API before actually trying to register?
Specify user by external id
Posting a new topic via API
Remove users script either via API or PG available?
Getting who liked a post from the API
How do I set-up this workflow? Membership form with Payment > Discourse Invite
How to upload a file via API and get it's URL?
Is there an API endpoint for enabling voting in a category?
Data Explorer Plugin
/directory_items.json API returns wrong link for next page
Pinning topics not at top of latest response
Incoming Web Hooks
API documentation error?
Cannot update group owners via Ruby or REST API
Shared Drafts: Allow staff to collaborate on posts before publishing
API for changing category groups
Internal server error setting tags via the api
How can i rename a group with the help of discourse api?
Leaderboard Plugin
Admin forum statistics for posts/topics
Post unread count clear api
Set watch_first_post via API?
How should I get the raw text of a single post
Get "badge-notification" from API?
Setting a category to use the solved plugin via console
Custom Query on static web page
Mark notifications as read from Discourse API
How to run Data Explorer queries with the Discourse API
Data Explorer Queries accessible to public
Bulk revert edits (bulk undone edits)
Trying to make a post.json a wiki
Anonymizing Users in Discourse
Is it possible change the post owner?
SSO, old disabled accounts
Suspend/unsuspend user based on WP membership status
API feature request
Discourses API get just the number of search results
API for preview
Is there a support about api check when users create topic
Update a Post, via API PUT: request
Why isn't the Discourse API fully documented?
Unsubscribing a user from all emails via an API call?
Slackbot with Discourse Admin stats
How do I add tags to a post created with the API?
Now that there is an API call for Merge Users, how to call it?
How do I get the json for the each raw from topics in the category?
Adding UI for Merge Users
How can I get external_id from the user object?
Creating a staged user with an API call
A comprehensive guide to Discourse tags
Theme-Component v Plugin: What's the difference
Can I use the JSON API instead of building a plugin?
Unable to GET user by External ID
The purpose of the 2 Discourse API systems
API Error: You are not permitted to view the requested resource
How to add machine-generated tags to a post?
Category Slug api
Post commits via webhook inside a topic as reply
WordPress Membership Integration (Private Forum) with Discourse
GraphQL api for Discourse
Zapier webhook to update topics
Add Tag to The topic
Subcategory Name
Obtaining a list of topics from a category
Struggling with pagination within search/query.json
Post anonymously via API?
Retroactive topic timers
Endpoint for User Information
Understanding Discourse Trust Levels
Is there a way to change or delete the secondary email
Group restrictions API on Category
How to create Category/Group through API
What is Discourse API?
Allow all users to see users post_count when using the API
Multiple Topic Timers?
Updating custom fields using API
Can Discourse API link with Obsidian?
How to get uploaded image url using the Discourse API?
Automate sending Discourse invite emails with Zapier
Top Referred Topics and Trending search via API
What is the Timing of Formal Discourse REST API?
Chatroom Integration Plugin (discourse-chat-integration)
User ignore feature: webhook and API
Get user by e-mail
API GET for Category User notification_level
How to make requests to the Discourse API with Zapier
Allow name removal using SSO
Discourse API Documentation
How to mark Topic or Notification as "Read = true"
Assign topics or messages when created via API
Discourse API Documentation
Discourse API Documentation
API Error: You are not permitted to view the requested resource
API call to get all site_texts