Access to stats via API?

AI-generated summary

The discussion revolves around accessing site statistics via the Discourse API. niemeyer asks about API access for metrics, seeking an alternative to screen scraping. pfaffman suggests the Data Explorer plugin as a potential solution. niemeyer confirms that /admin/dashboard.json provides the needed data. Falco adds that specific stats endpoints like /admin/reports/page_view_total_reqs are available. jerdog notes that while many dashboard reports can be accessed via .json URLs (e.g., /admin/reports/visits.json), custom timeframes require adjusting the report first, though some parameters like start_date and end_date can be used. The conversation highlights the availability of API endpoints for stats but also points out limitations in direct time range customization.

Is there any way to access the site statistics via the API? We’re trying to put some of these metrics inside a larger graph, and it would be great to be able to do that via the proper API instead of screen-scraping the dashboard or something else similarly hackish.

I think that with the data manager plugin you can download statistics via the api.

Edit: it’s data explorer plugin.

Thanks for the hint, I’ll have a look at it.

We also just found out that /admin/dashboard.json should offer what we need for that purpose.

Yes, and there are endpoints like https://meta.discourse.org/admin/reports/page_view_total_reqs for individual stats.

This endpoint is good, but not seeing any others being exposed, or at least Docs doesn’t reveal them.

Does anyone know if any others are exposed? I am thinking a lot of us, or at least some of us, have organizations which keep a data warehouse with stats and being able to access reports via the API would be helpful for them.

Edit: any of the reports from the Dashboard can be viewed in json format by just appending .json to the URL, i.e. /admin/reports/visits.json - and that’s helpful. However there isn’t a way that I have found to allow you to set the timeframe for the data.

Edit2: and it looks like you can get some customised timeframes ala /admin/reports/visits.json?category_id=all&end_date=2018-02-08&start_date=2018-01-01 but you do have to adjust the timeframe in the report first to then get the fields you can update