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!
1 个赞
Bumping this to see if anyone had an idea?
blake
(Blake Erickson)
2021 年10 月 4 日 15:01
3
John_Lehmann:
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.
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.
2 个赞
simonk
(Simon King)
2021 年10 月 4 日 15:43
4
Could you write a data-explorer query that returns the data that you want, and then execute that query via the API?
Virtually any action that can be performed through the Discourse user interface can also be triggered with the Discourse API. For a general overview of how to find the correct API request for an action, see Reverse engineer the Discourse API .
To run a Data Explorer query from the API, you need to make a POST request to /admin/plugins/explorer/queries/<query-id>/run. You can find the a Data Explorer query’s ID by visiting the query on your site and getting the value of the id parameter that yo…
2 个赞
@blake
I don’t suppose the topic event would include changes to the OP?
1 个赞
blake
(Blake Erickson)
2021 年10 月 4 日 17:25
6
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!
大家好,
我正在开发一个移动应用程序 ,该应用程序将与我们自托管的 Discourse 实例 集成。我需要检索特定类别中所有帖子的首个帖子 ,类似于此处讨论的用例。
虽然目前的方法是先获取主题,然后再单独检索每个首个帖子,但我正在寻找一种更有效的方法,适合移动应用程序。理想情况下,这可以最大限度地减少 API 调用次数,以节省带宽并提高性能。
是否有人实现过类似的解决方案或能就最有效的方法提供指导?任何见解或建议都将不胜感激!
1 个赞
blake
(Blake Erickson)
2025 年4 月 24 日 18:24
8
我认为上面提到的数据浏览器查询路由值得一试。这样您就可以为每个类别发出一个请求。