Let me preface by saying I am new to Discourse. I have constructed a query in Data Explorer that I would like to be used to populate a particular page on our website (It would basically show the topics under a particular category). From what I can see, I would require an All Users API key to fetch the data, but how can I avoid exposing this API key?
Is the solution to simply fetch the data server-side and then return it, or is there something I’m missing here? Is there some way to restrict the scope of an API key for this specific purpose?
AI-generated summary
The discussion revolves around displaying Data Explorer data on an external website. gbain wants to show topics under a particular category but is concerned about exposing the All Users API key. simon suggests making the request from the server to avoid exposing the API key.
Meanwhile, michaeld recommends using the JSON category topic list instead of Data Explorer, as it’s possible to consume it using JavaScript. However, gbain wants to include text from the first post of each topic and finds that the topic excerpt is missing from the API response. michaeld reveals a hidden site setting (always_include_topic_excerpts) that can solve this issue, but gbain is unsure if this setting is accessible on a hosted plan.
Yes, making the request from your server is the correct approach.
You don’t need the data explorer for that, you can request the json for the category topic list and consume it using Javascript.
Thanks for replying
. The reason I was leaning towards Data Explorer was because I wanted to show some text from the first post of the topic, however I realize now this may be possible by using the topic excerpt. I tried running the Category “List Topics” query specified in the API docs but do not seem to get back an ‘excerpt’ field for the topics. But running the Data Explorer query I can see that adding ‘t.excerpt’ returns the excerpt data.
I guess my question now would be how can I get topic excerpts through the API?
There is a hidden site setting for that:
SiteSetting.always_include_topic_excerpts = true
I am on a hosted plan though. Is it still possible to access these hidden settings?