Best API for All First Posts in a Category

AI-generated summary

The discussion is about finding the best API for retrieving all first posts in a category. John_Lehmann wants to avoid making one request per topic/post and is currently using search to get topics and then retrieving the first post from each topic. blake suggests that iterating through each topic and grabbing the first post is probably the best option, and webhooks could be a good option in the future.

simonk recommends writing a data-explorer query to return the desired data and executing it via the API. blake agrees that this is a great option and also notes that the topic event should trigger for changes to the original post.

Tarun_Sharma is developing a mobile application that integrates with a self-hosted Discourse instance and needs to retrieve all first posts from topics within a specific category. blake suggests trying the data explorer query route, which would allow making one request per category.

We want to get all of the first posts in a category (which we are using as wikis but not actually wikis).

Preferably, we’d like to avoid having to do one request per topic/post.

The best way have so far is using search to get topics, and then get the topics one by one and take the first post out of the stream.

Web hooks will be a good option in the future but we’d like to start with PULL.

thanks!

Bumping this to see if anyone had an idea?

I’m not aware of a bulk way of getting the first replies to many topics. Iterating through each topic and grabbing the first post is probably the best option.

Yes, webhooks really are a good option here and you can trigger off the “Post Event”.

But this would trigger for EVERY post event and you’d just have to ignore all the posts that aren’t the first reply on a topic.

Could you write a data-explorer query that returns the data that you want, and then execute that query via the API?

@blake

image

I don’t suppose the topic event would include changes to the OP?

It should trigger for changes. The description for it says:

When there is a new topic, revised, changed, or deleted.

Yes, that is great option! :slight_smile:

Hi everyone,​

I’m developing a mobile application that integrates with our self-hosted Discourse instance. I need to retrieve all first posts from topics within a specific category, similar to the use case discussed here.​

While the current approach involves fetching topics and then retrieving each first post individually, I’m looking for a more efficient method suitable for mobile applications. Ideally, this would minimize the number of API calls to conserve bandwidth and improve performance.​

Has anyone implemented a similar solution or can offer guidance on the most efficient way to achieve this? Any insights or suggestions would be greatly appreciated!

I think the data explorer query route mentioned above would be worth trying out. This way you could make one request per category.