How to batch post

AI-generated summary

To batch post on Discourse, Alex_王 sought advice on which API to use. Canapin recommended the createTopicPostPM API, suggesting a short time limit between requests to avoid rate limits, or using a rails script with topic_creator.rb. pfaffman pointed to the Reverse engineer the Discourse API documentation and suggested using an import script for large quantities of posts. Following the advice, Alex_王 successfully used an API key and a Python script to solve the issue.

I have some posts that include the TITLE as well as the body. I want to write a script to post this data in bulk on my discourse. Which api of Discourse should I call?

By the way, I noticed that there are some columns in the post database that are different from raw text, such as “search” (which is supposed to be used as a query index), so directly inserting the post content into the database shouldn’t work.

Thanks!!

Hi :wave:

If you want to create new topics, I’d use https://docs.discourse.org/#tag/Topics/operation/createTopicPostPM, and set a short time limit between each request to prevent reaching the rate limit.

I think you could also use a rails script and use discourse/lib/topic_creator.rb at main · discourse/discourse · GitHub. You can have a look at the importer scripts to see how it’s used:

If you don’t have tons of topics, I think a quick script using the API would be the easiest way.

The best documentation for the API is usually Reverse engineer the Discourse API.

If you want to create hundreds of posts I recommend using/writing an import script.

Thanks everyone I use the api key and a python script solve it!!