From post number to post id

Hi everybody!
I’m wondering whether there’s a way through Discourse API to get the post id from a canonical post url such as<topic_id>/<post_number> where of course TN is the topic id/number and PN is the post number.

I did a few tries using the post stream data from<topic_id>.json, thinking that, for example, post_number N would be the n-th post id in the post_stream->stream data returned by the call, but if posts were deleted or split were done in the topic posts flow, the post_number does not correspond to the n-th position in the stream.

Am I missing something obvious?


Have you tried /t/<topic_id>/posts.json? That will get 20 posts and you can take the post_number-th one, which will contain a post id.

But to get more that 20 you’ll need pagination, which I don’t see how to do at the moment.