1
0
Fork 0
Pull stats from discourse and generate report
Find a file
2025-04-01 17:09:19 +01:00
charts Move charts 2025-04-01 17:09:19 +01:00
examples Move charts 2025-04-01 17:09:19 +01:00
.DS_Store Move charts 2025-04-01 17:09:19 +01:00
discourse_stats_report.py Adding initital files 2025-04-01 17:06:36 +01:00
README.md Adding initital files 2025-04-01 17:06:36 +01:00

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 JSON
  • discourse_report.csv: Tabular version of the statistics
  • discourse_report.md: Markdown summary (if --markdown enabled)
  • charts/: Folder containing .png charts for each metric

Example Output

📊 Example Chart

Topics Over Time

📄 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**

![topics chart](charts/topics.png)

## Posts
Trend: **stable**

![posts chart](charts/posts.png)

License

MIT License