Oct 10, 2011

Tumblr API v2 Ordering Issue

If you use Tumblr's API for anything I thought I'd let you know about a rather annoying bug that I found the other day.  The bug is related to how Tumblr returns posts and the inability to specify any other type of ordering.  Hopefully, this will help someone who might be scratching their head and wondering why things don't look right.

At Virb we've been rocking the Tumblr API v1 and just recently upgraded to v2.  One of the reasons for upgrading  (besides the inevitable deprecation of v1) was to take advantage of the much more reliable and stable v2.  After the upgrade we definitely saw better stability, but we also started seeing help tickets about out of order posts.  I quickly looked into how to fix this and found nothing to fix the ordering that Tumblr was providing.

I knew either I was doing something wrong, which was highly likely, or something wasn't right with Tumblr's API.  I ended up emailing them and got back a pretty speedy response.  Here's what I got back:

"The post are coming back on date ordered by id order. These people if the used the api to back date items would see this." [sic]

So essentially, the v2 API returns posts in descending order by id BUT, if someone changes the date AFTER the post has been officially posted, the post most likely will be out of order.  I asked if there was any way to order chronologically and I have received no response.

I'm sure Tumblr had their reasons for ordering by id, but if you have an API to pull data from a system that is highly chronological, it would make sense that you would provide a way (especially since it was default on the old API) to pull those posts chronologically.