There is a NEW endpoint /api/alpha/post/replies. In the past comments/list was used to get lists of comments for a variety of situations, making it hard to debug, have many many parameters and it's response overly verbose. That endpoint will remain there, unchanged, for compatibility reasons. You can continue using it if this new endpoint is not to your liking.
The new endpoint post/replies
is only for getting replies to a post and as such the response is not a flat list of comments, it is a nested hierarchy thing which mirrors the way the replies are displayed in the UI. It's parameters are the same as comments/list, as much as possible, including max_depth, limit, post_id, parent_id.
Let's take this post as an example: https://piefed.social/post/1076697?sort=hot#replies. I chose that one because the conversation has a nice hierarchy to it and yet there are only 25 replies so it's something we can get our arms around.
The comment structure is the same as before except I added a 'replies' attribute on the end which is a list of comments, which in turn have 'replies' on them. Only the top-level replies have 'post' and 'community' as this data would be the same for all child replies and is redundant.
To get all the replies to a post:
https://piefed.social/api/alpha/post/replies?post_id=1076697&sort=Hot
To paginate the replies, while getting full unbroken reply trees, specify a page size using 'limit'
https://piefed.social/api/alpha/post/replies?post_id=1076697&sort=Hot&limit=3
The above limit is intentionally small so you can see that the result includes the entire first branch. IRL you will want 20 or 50. NB the result includes a 'next_page' value:
This is different to the pagination on the rest of the API - it is the ID of the first comment on the next page, rather than a page number. You use it the same tho - you can get the next page of results by doing
https://piefed.social/api/alpha/post/replies?post_id=1076697&sort=Hot&limit=3&page=7228615
The problem with page numbers is that people can create replies in the time between when you got the first page and when you got the second (or later) pages, so replies can end up being in two pages of results. By basing the pagination on the ID of the reply we avoid this.
You can omit post_id and instead provide parent_id to get a sub-branch deep in the discussion. The max_depth filter will be applied relative from parent_id, not the root.
A fix has been deployed to piefed.social. I'm not sure which instance you're on but the others are usually not too many days behind.