This Python script allows you to create topics on a Discourse forum using the Discourse API. It can handle both single and multiple topics, with support for custom formatting, image embedding, and category assignment.
- Python 3.x
requests
librarypython-dotenv
librarytqdm
library (for progress tracking)
-
Clone the repository or download the script.
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory with the following content:DISCOURSE_URL=https://your-discourse-site.com API_KEY=your-api-key-here API_USERNAME=your-username-here
-
Prepare a
topic.json
(single topic) ortopics.json
(multiple topics) file. -
Run the script:
python create_discourse_topics.py
The script will load topics from the provided JSON file, create them on your Discourse site, and log the results.
- Supports creating a single topic or multiple topics.
- Handles markdown formatting, image embedding, and external URLs.
- Configurable retry limit and rate-limiting delay for API calls.
Logs are saved to discourse_topics.log
and will also be printed to the console.