If it must be done through the API, you could set up a Data Explorer query and use the methods outlined in How to run Data Explorer queries with the Discourse API
2 Likes
If it must be done through the API, you could set up a Data Explorer query and use the methods outlined in How to run Data Explorer queries with the Discourse API