How to batch post

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!!

1 Like

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 https://github.com/discourse/discourse/blob/main/lib/topic_creator.rb. 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.

3 Likes

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.

1 Like

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

2 Likes