Topic: API: how to get comments for a post?

Posted under General

I've been working on a mobile app using the JSON API, but I've hit a snag. How do you get the comments for a post? I can get a comment by ID, but posts only have a "has_comments" field - how do I know which comment IDs correspond to which posts?

Updated by TonyCoon

Thanks, that works.

Another question: when I specify a page number and some tags to list posts, how do I find how many pages there are?

Updated by anonymous

I don't believe you can. Even e621's own pagination doesn't go past something like 100 pages, though I forget whether that is the exact upper limit. But either way, after a certain number of pages, e621 starts offering pages based on post ID instead of "page number."

Updated by anonymous

Unfortunately it looks like you can't when using JSON, but you can using XML. XML's root element (posts) has a 'count' attribute, which is the total number of posts returned by the search, and an 'offset' attribute showing how many posts are before the first one (so if you requested page 2, 75 posts per page, the offset will be 75).

Updated by anonymous

Here's another one (this thread just won't die!): how to get the reason a post is flagged for deletion?

Thanks for all the help btw.

Updated by anonymous

ikdind said:
I don't believe you can. Even e621's own pagination doesn't go past something like 100 pages, though I forget whether that is the exact upper limit. But either way, after a certain number of pages, e621 starts offering pages based on post ID instead of "page number."

1000 pages, hard coded. at that point in time we start to hit ruby's scaling issues with pagination and gotta play magic numbers, it still works well though.

Updated by anonymous

Well since this topic is almost like what I want to ask. Why doesn't Delete post that has delete because a better version has been posted comments crossover to the new version?

Updated by anonymous

Falord said:
Well since this topic is almost like what I want to ask. Why doesn't Delete post that has delete because a better version has been posted comments crossover to the new version?

... I don't what... what is.. huh?

Updated by anonymous

Aurali said:
... I don't what... what is.. huh?

... all I meant was the comment for deleted post go over to new posts of the same image...

Updated by anonymous

Because then the comments might not make sense on the new post. If a bunch of people point out that post X is a smaller version of Y, and those comments get moved to post Y, then all of a sudden you have a bunch of comments saying that post Y is too small, which is wrong.

Updated by anonymous

  • 1