Press ESC to close

Using the Real-time Instagram API

Instagram has an interesting feature that it likes to call the “real-time” API. If you are familiar with a real-time API like the Twitter firehouse I must inform you that Instagram’s version by no means functions the same way. Twitter’s streaming API gives the subscriber a feed of all tweets and the associated data. However, Instagram’s version requires the user subscriber to a hashtag or location much like Twitter’s, but only notifies the subscriber that a new image/video has been posted for that subscription. This in reality is not much of a real-time API. It requires you to make another call back to the API in order to retrieve the actual content at which point the user is responsible for keeping track of what content has already been consumed.

So is it really worth it to use this so called “real-time” API? In my opinion, no it isn’t. Instead the use of polling will make you a happy developer. Instead use the following methodology:

  1. Create a reference table in your database to track location, hashtag, user or coordinates.
  2. Poll the object you wish to track at a reasonable interval. Base this off of how many results are returned in each collection. If the result sets are large, then increase the poll frequency.
  3. After, each poll record the max image ID. This way for next poll you know which content to look for. Instagram has the ability to only return results before or after an image ID.

It is really quite simpler and less of a headache than the “real-time” API. Is it real-time? No, but it also doesn’t complicate your programming.