Easiest way is probably the data explorer plugin and then How to run Data Explorer queries with the Discourse API. I doubt that there is an endpoint that provides that, so you’ll need to sort-of make one with data-explorer.
2 Likes