נושא API מקבל את ההודעות הלא נכונות - תמיד סטייה של 5

סיכום מבוסס בינה מלאכותית

The Topic API is consistently returning posts that are off by 5, as noted by markschmucker. For example, requesting post 10 returns the 5th post, and requesting post 50 returns the 45th post. supermathie suggests that this is intended to include previous posts for context, but markschmucker argues that this should be handled in the UI, not the API. supermathie also provides examples of how to work with the returned data, including using jq to select the desired post. The API documentation is referenced by supermathie, but markschmucker questions where the specific behavior is documented.

/t/slug/123.json?post_number=10 מקבל את ההודעה ה-5. /t/slug/123.json?post_number=50 מקבל את ההודעה ה-45, וכן הלאה. זה תמיד מדרג ב-5. אם תרצה לקבל את כל ההודעות, עליך להשתמש בהצגת עמודים (pagination), ואם לא תתייחס לכך, הרשימה שתקבל תהיה שגויה.

אני רק יכול לנחש שזה נעשה כדי לכלול כמה הודעות קודמות להקשר. אם זה המקרה, לדעתי זה צריך להיעשות בממשק המשתמש, לא ב-API.

This endpoint promises to return information including the specified post, for example:

○ → curl -s 'https://meta.discourse.org/t/fkb-pro-social-theme/234323.json?post_number=40' | jq .post_stream.posts[].post_number
33
34
35
36
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

As a single-page application, Discourse uses its API efficiently to minimise work. It’s not reasonable to make one API call per post; that would massively balloon the amount of back and forth between client and server.

It’s trivial to select the post you expect from the result. Same as above, getting only post 40’s cooked content:

○ → curl -s 'https://meta.discourse.org/t/fkb-pro-social-theme/234323.json?post_number=40' | jq -r '.post_stream.posts[] | select(.post_number == 40) | .cooked'
<p>Hi Tiago,</p>
<p>Can you please clarify it a little bit? Some screenshots, your actual code and where is your advert appear would be very helpful. Thank you <img src="https://emoji.discourse-cdn.com/twitter/slightly_smiling_face.png?v=12" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:" loading="lazy" width="20" height="20"></p>

Or, if you absolutely want to return information about only the single post you are querying, you are free to make a Data Explorer query that does only that.

ok, but where is that documented?

I’m not against pagination.

You can see API documentation here: https://docs.discourse.org/#tag/Topics/operation/getSpecificPostsFromTopic