Get ID for updating a post

AI-generated summary

In the Dev category, nisbeti discusses the challenge of programmatically retrieving the correct post ID to update the default “About this category” topic after creating a new category via the API. The user describes a current workaround where they fetch the latest posts in the category to get the post ID, then reverse-engineer the update ID by adding 3 to that value (e.g., post ID 55 requires updating ID 58). They ask if this offset is reliable or if a better method exists. Tom_Newsom suggests a more direct approach: querying the topic JSON endpoint directly (e.g., /t/about-the-group-one-category/20.json) to extract the post ID from the first post in the response, eliminating the need for manual calculation or reverse engineering.

When creating a new category, I must have an automatically created post, as: Every category has an initial "About this category" topic.
So, I use the API to create the ‘group one’ category, then I get the topic-url from the result, and I can then use the API to change the title of the “About this category” topic.
curl -X PUT -d title="This is my new title for group one category" -d api_key=blahblah -d api_username=system http://localhost:3000/t/about-the-group-one-category/20

I can then use the API to get the latest posts in that newly created category,
http://localhost:3000/c/group-one/l/latest.json
which gives me the default post and its id. If the id of the post is 55, then I notice that (using the reverse engineering approach), the id that must be updated is the id + 3 = 58

So, I can use this to change the default text of the post:
curl -X PUT -d post[raw]="This is the new text for the About this category initial post" -d api_key=blahblah 7 -d api_username=system http://localhost:3000/posts/58

Is there a better way to get the id for updaing, or can I be certain that it will always be the post id + 3?

Why not just do http://localhost:3000/t/about-the-group-one-category/20.json and pull the id from the first post?