response['blog']['posts'] != response['posts'].length

71 views
Skip to first unread message

benbu...@gmail.com

unread,
May 31, 2013, 1:34:22 PM5/31/13
to tumbl...@googlegroups.com
Hi,

I'm new to the API and I've run into something a little confusing.

The response to /posts or /info contains an item which is listed as the "total number of posts to this blog." It looks like this is just the number of published posts (not including private posts), but the body "posts" object contains both published and private posts. So, when I'm processing the response to a /posts request: response['blog']['posts'] != response['posts'].length (even accounting for limit/offset/pagination).

Example on a blog with 3 private posts:
- 47 total posts reported in 'info' response
- using limit of 20 and offsets: 0,20,40
- Response for offset 0 : 'posts' object contains 20 posts, 0 are private
- Response for offset 20 : posts' object contains 20 posts, 3 are private
- Response for offset 40 : 'posts' object contains 10 posts, 0 are private
- Total posts returned: 50

My questions:
- Is there a way to get the count of private posts on a blog (other than by calculation)?

- Or is there a way to get the total number of published+private posts (other than by calculation)?

- Or is there a way to get the most recent post id on a blog (other than by getting the posts)?

- Or most importantly, what's The Right Way to get all the published and private posts on a blog? I've got something like: keep increasing the offset by the limit until you get zero results?

Thanks,
Ben

HT154

unread,
May 31, 2013, 4:40:12 PM5/31/13
to tumbl...@googlegroups.com
To my knowledge:
- No
- Nope
- Call /posts with limit=1 and getting the id is the closest I can think of.
- I use limit=(loadedPosts.count)

Unfortunately, these inconsistencies you've noticed just have to be worked around.
Reply all
Reply to author
Forward
0 new messages