The discussion revolves around challenges with pagination in the Discourse API, particularly when using search/query.json to retrieve posts within a date range. danielt initially struggled with pagination, noting that page 2 and page 3 returned identical results for complex queries, unlike simpler searches. vinothkannans clarified that the query string should use & instead of ? for subsequent pages, correcting the URL structure. pfaffman shared a Ruby script for downloading topics, though it doesn’t handle date filtering. danielt acknowledged the mistake in URL formatting and questioned how to access additional posts when more_posts is true. sam confirmed pagination support and referenced the Discourse API documentation. faheem asked about the meaning of term in the API, and blake explained that term refers to a search query, not a time period, and suggested reverse-engineering the UI’s API calls to understand pagination. faheem expressed a desire to fetch all topics in a category at once, but blake clarified that multiple API calls are necessary due to performance constraints, and suggested using data explore queries as an alternative.
I don’t know if it’ll help, but I wrote a little ruby program that will download all of a topic or category. (It doesn’t pay attention to dates, though.)
Oops. Getting the links wrong is what made me believe discourse support pagination using page=X in the first place (my own bad conversion from curl to a web browser).
Perhaps I should have ask a more general question: If search/query.json has a grouped_search_result with more_posts set true, how do I get to see the additional posts?
أنا أحاول فهم كيفية استخدام واجهة برمجة تطبيقات Discourse. في الروابط أدناه، أفترض أن term تشير إلى فترة أو مدة. وهذا مبني على erm=after:2016-01-01%20before:2017-01-01 وما إلى ذلك. لكنني غير متأكد مما تعنيه term=API. هل يمكن لأي شخص توضيح ذلك؟
في الواقع، هناك نقطتا نهاية للبحث يمكنك استهدافهما: /search.json?q= و /search/query?term=
كلمة term تعني ببساطة مصطلح البحث ولا تشير إلى الفترة أو المدة.
لفهم واجهة برمجة تطبيقات البحث، من الأفضل اتباع الرابط Reverse engineer the Discourse API وإجراء عمليات البحث التي تنوي تنفيذها عبر الواجهة، ثم مراقبة كيف تقوم واجهة المستخدم بإجراء نفس الطلبات إلى واجهة برمجة التطبيقات.
في الواقع، أود جلب محتوى الصفحة بالكامل (في حالتي، قائمة بالمواضيع في فئة معينة، انظر Obtaining a list of topics from a category). لا أريد التصفح صفحة تلو الأخرى إذا لم يكن ذلك ضروريًا. ولا أعتقد أن عكس الهندسة هنا سيعمل، لأن Discourse تقوم فقط بتوسيع الصفحة أثناء التمرير لأسفل. لا توجد خيار، حسب علمي، لعرض الصفحة بالكامل. هل توجد طريقة للقيام بذلك؟
لا توجد استدعاءات API واحدة تجلب جميع الموضوعات في التصنيف. سيتعين عليك إجراء استدعاءات API متعددة. والسبب في ذلك هو أن التصنيف قد يحتوي على أكثر من مليون موضوع، وقد يكون ذلك استعلامًا ضخمًا ويؤثر على أداء موقعك. عند عكس هندسة التمرير، يمكنك رؤية كيفية قيام واجهة مستخدم Discourse بإجراء استدعاءات API لجلب المزيد من الموضوعات، ويمكنك تكرار هذا السلوك في واجهة برمجة التطبيقات الخاصة بك.
اعتمادًا على ما تحاول تحقيقه، يمكنك أيضًا استخدام استعلام استكشاف البيانات للحصول على عدد الموضوعات في تصنيف معين، ثم إجراء استدعاء API لهذا الاستعلام المحفوظ.