逆向工程 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 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

  • Note that in some versions of Chrome, the “Form Data” will be located under the “Payload” tab

image

  • 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 REST API Documentation for details about how to formulate a curl request to the Discourse API.)

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


Last Reviewed by @SaraDev on 2022-06-03T00:00:00Z

100 个赞
Discourse REST API Documentation
How do I get all posts from a specific category?
Assign group permission to a category via API
Is there an API for changing a password?
Delete Post from a Topic Using discourse API
Add a user to a group via API?
Can we toggle anonymous mode via API
API: Getting all posts in a topic
Problem creating a category using the API
Discourse API Documentation Released!
Mark as accepted solution by API?
Tickets Plugin :tickets:
Assign topics or messages when created via API
Dev Category sidebar
Approving an already-existing user through API?
Category Slug api
Custom permalinks
Posting a new topic via API
Incoming Web Hooks
Can I use API keys for this?
Getting who liked a post from the API
Assigning mod status to multiple users
API for Category based notification level update
The purpose of the 2 Discourse API systems
Topic Status API
Discourse Data Explorer
How to unlike a topic or post
API call to unmask all emails
How to upload a file via API and get it's URL?
Poor Notifications API documentation
How do you get the permissions assigned to a topic using the API?
API for not so techie
Change ownership through the API?
Get list of wiki editors
Calling POST on /posts.json returns null
API: fetch all users with external id info
How to set user's location string with Discourse API
How to remove someone from a Message?
Getting a topic statistics with API
Replying to PM via API not working anymore
Updating Custom User Field through the API
Download a user's posting history via Discourse API?
Can I update the user field automatically via API or otherwise?
How to automate configuration
No way to get period stats?
500 or 400 when updating the content of a post using the API
Need help to **getSelected** and **replace** from Toolbarevent
How to edit post with API without bumping topic?
Apis for bookmarking post and topic, and removing them as well
Not generate topic automatically for all blog posts
Is there a way to check validity of a new username via the API before actually trying to register?
Specify user by external id
PHP/API to check whether user exists (by email) and is in specific group
How to Change User Profile Picture
How to easily make Discourse bots?
Remove users script either via API or PG available?
Make requests to the Discourse API with Zapier
How do I set-up this workflow? Membership form with Payment > Discourse Invite
Is there an API endpoint for enabling voting in a category?
Automate Badges with Webhooks for cross site integration?
/directory_items.json API returns wrong link for next page
I need to mass-create groups using the API
API documentation error?
Cannot update group owners via Ruby or REST API
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
Post unread count clear api
Set watch_first_post via API?
How to connect Discourse with hundreds of apps using Make
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
Mark notifications as read from Discourse API
How to update a private message by API?
Documentation on Client Api
Data Explorer Queries accessible to public
Bulk revert edits (bulk undo edits)
Trying to make a post.json a wiki
Is it possible change the post owner?
SSO, old disabled accounts
Suspend/unsuspend user based on WP membership status
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?
SSO and Screened IPs
API support for deleting categories?
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 to reply to Topic reply?
Force-post in restricted category
How can I get external_id from the user object?
Creating a staged user with an API call
API request returns text/html and not a json object
Admin guide to tags in Discourse
Theme-Component v Plugin: What's the difference
Can I use the JSON API instead of building a plugin?
Allow API use by regular users, not just admins
API Error 422 for Invite Emails to users with existing account
Allow API use by regular users, not just admins
Unable to GET user by External ID
SSO and Screened IPs
API Error: You are not permitted to view the requested resource
How do I get the latest topics from a specific category via API?
How to add machine-generated tags to a post?
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
Move topics to subcategories automatically based on their tags
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
API: Get all private messages sent to a group
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?
Can Discourse API link with Obsidian?
How to script the setup wizard?
POST on /posts returns null on moderated categories
Badges data to my website database
Send an invite to a user but complete their profile programmatically
Unlist "About the *****" topics automatically when it gets created
Add user to group after purchase
Retrieving AI Summaries via API Call?
Bulk undelete topics
"Get a user by id" can't get email
Best Practise for Using a Raspberry PI as Bot for Posting Updates in Discourse
Best way to get (via API) a list of users from a group, and their bios
Re-Activate a suspended User via API
Automate sending Discourse invite emails with Zapier
Is there is any open API for getting similar topic in discourse?
How to get mentions for a specific user via the API?
"Fake" OAuth Provider?
How to delete user accounts via API without IP blocking
Deleting all messages from a User in a Category
Allow name removal using SSO
API feature request for additonal info about external accounts
API for getting topics doesn't include tags
Is there any endpoint that would provide a user's external account IDs from their Discourse ID?
Getting categories on your website via JS
Add users to a specific group via API
Parse groups and their member count
There are 2 IDs when I try to get API, in case of lack documentation
Is there an API call to set the logo image of a category?
User Data By Date Rage
Correct way to Get specific posts from a topic (Discourse API)
How could I set tag for a topic by API
PUT /u/{username}.json does not change the email
Set all anonymized user names to common "deleted user"
Beginner's guide to using Discourse Themes
API bug : final "." in username causes error
How can you like a specific post through the API?
How can you like a specific post through the API?
Unable to lock post with API
Update user details
Reverse engineer the Discourse adplugin
Make requests to the Discourse API with Zapier
User Status
Run Data Explorer queries with the Discourse API
How to know if user has SSO
Creating a User - Tag relation plugin
How to download Comments and Topics
Auto delete the post after 3 months on specific topic - need API option
Create and configure an API key
Issue with Api
Ability to set topic external URL next to the title through the API
User API keys specification
Discourse REST API Documentation
Posts made via API and Spam Detection
Discourse Subscriptions - use API to find out product, plan and renewal date
Best way to update or create existing user, via API, from connected client?
Automatic backup monitoring
Sourcemap sensitive files leaked
How to query the topics_with_no_response.json API with filters
Updating custom fields using API
Discourse Likes API
First time login for a user using API KEY
500 Internal Server Error when trying to change the owner of a post with API calls
One image for multiple categories
Grant a custom badge through the API
How to find the api endpoint for creating forum topics
Exporting / Extracting Community Health Data
Can I create a new query in Data Explorer using API?
I am looking for a webhook or event api
Using Python to programmatically create 100 groups
Can I use shared drafts with the API?
API to get composer settings?
.json endpoint to receive array of arbitrary posts with a single request
No Community Name in /site.json
Support for tl=[lang] parameters in REST API (for non-anon users)
Reserved usernames programmably?
API / Functionality required to push Data from Discourse to external resource
How to add and remove a flag for a post in a plugin
Is there a way to serve in-house ads based on the current user's location?
Cancel an invite
How do I set up a read only API for my forum page
Join Group Button on Group Pages
How to batch post
Adding non-visible user custom fields to the API
Seeking help with user pop-up enhancement: inserting unique privat chat link
How to create a data explorer query with the APIs?
How to create a data explorer query with the APIs?
Procedurally nullify notifications for a group
How to change topic date after import
Get topics a user is active in
Delete all posts by a user on entire site with API?
How to get posts viewed by a user via APIs?
Are Post Voting votes/replies accessible via API?
Cannot fathom the API for adding and removing group owners
How to enable this field - "Solved" - programatically for each category
Need Help updating profile info via API
How to enable this field - "Solved" - programatically for each category
Is it possible to set a default notification schedule for new users?
Can I anonymize a user via the API?
Is there an api to set the primary group for a user
Programmatic way to get all API endpoints for my instance?
Get list of users by emal addresses?
Can't SSO due to blocked IP addresses
Custom tag query for homepage?
Export custom field for users in discourse hosted forum
Discourse User Notes
Is there a way to edit posts with the API without notifying the user?
Discourse REST API comprehensive examples
Discourse REST API comprehensive examples
Adding non-visible user custom fields to the API
Unable to add new post using API
Rest API to add owners has stopped working
Direct Api Endpoint For User Impersonation
Is there a back-end API where I can manage all of the users and their permissions automatically?
Unable to Associate Category Banner via API During Category Creation with Python Code
Is there any pagination in place for fetching category topics data?
How to get all topics from a specific category using offset/page param in the API query?
Create Invite api not sending emails
How to add and remove a Tag in a plugin
Is there an API that can convert a topic into a PDF file?
How can I download a spreadsheet of the user directory?
How to use the API to set a timer for a topic?
Webinar: Love Your Community
Programmatic RAG uploads?
How to assign topic to a moderator using curl or python script(not from web UI)
Updating custom fields using API
500 internal server error when updating a post by id
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?
Discourse Chat Integration
User ignore feature: webhook and API
Get user by e-mail
API GET for Category User notification_level
Discourse REST API Documentation
How to mark Topic or Notification as "Read = true"
Discourse REST API Documentation
Discourse REST API Documentation
API Error: You are not permitted to view the requested resource
Integrating Discourse with a larger social network app?
Exclude / Suppress (Automatically) Closed Topics from the Homepage?
Correct method for updating category group permission level via API
API: a scope with access to /uploads
Changed API for directory_items
Add category moderators with the API?
Is there an api to set the primary group for a user
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
Pull or quote content from within the revision history
Not able to bulk upload censored words?
Adding user to group from API gets "BAD CSRF"
Discourse always posts in general using API
User API only shows 3 badges
Trust Level Requirements from API
Struggling with pagination within search/query.json
How can I get user image's url
How to get unread notification / topic count via API?
Check_username api endpoint seems to not work correctly
Reset avatar in sync SSO
Can a topic be made the site-wide banner via the API?