Restrict moderator access to only the stats panel on the admin dashboard?

Is it possible to get a shared Data Explorer query export programmatically? Doing the naive thing — accessing — doesn’t work like it does for the official reports page. Instead of actually doing the query it just returns the raw SQL itself.

Edit: ah, it’s How to run Data Explorer queries with the Discourse API