Pull stats from discourse and generate report
charts | ||
examples | ||
.DS_Store | ||
discourse_stats_report.py | ||
README.md |
Discourse Stats Reporter
A Python script to fetch and analyze statistics from a Discourse forum using the Discourse Admin API. The script generates reports in JSON, CSV, and optional Markdown formats, and can also produce charts for visual insights.
Features
- Pulls 90 days of statistics from a Discourse instance
- Supports:
- JSON output
- CSV output
- Markdown report with charts
- Chart generation using
matplotlib
- Command-line interface and YAML-based config support
Requirements
- Python 3.7+
- Dependencies:
pip install requests matplotlib pyyaml
Usage
Command Line
python discourse_stats_report.py \
--url https://your.discourse.site \
--api-key YOUR_API_KEY \
--api-username YOUR_USERNAME \
--output both \
--charts \
--markdown
With Config File
Create a config.yml
file:
url: https://your.discourse.site
api_key: YOUR_API_KEY
api_username: YOUR_USERNAME
output: both
charts: true
markdown: true
Run with:
python discourse_stats_report.py -c config.yml
Output
discourse_report.json
: Raw statistics in JSONdiscourse_report.csv
: Tabular version of the statisticsdiscourse_report.md
: Markdown summary (if--markdown
enabled)charts/
: Folder containing.png
charts for each metric
Example Output
📊 Example Chart
📄 Sample JSON
{
"2025-03-01": {
"topics": 10,
"posts": 25,
"signups": 3,
"likes": 15
},
"2025-03-02": {
"topics": 12,
"posts": 30,
"signups": 2,
"likes": 18
}
}
📄 Sample CSV
date,likes,posts,signups,topics
2025-03-01,15,25,3,10
2025-03-02,18,30,2,12
📝 Sample Markdown
# Discourse Statistics Report (Last 90 Days)
## Topics
Trend: **increasing**

## Posts
Trend: **stable**

License
MIT License