Retrieving more than 150 Instagram comments

Ally picture Ally · Apr 14, 2014 · Viewed 31.3k times · Source

The Problem

I would like to be able view all of the comments on any given piece of Instagram media, even if the media has over 150 comments. As of now, it is seemingly impossible to view more than the most recent 20 comments on a piece of media on the Instagram site and if one uses either the Instagram API Console or the Instagram API Libraries, the most recent 150 comments are returned with no options for pagination or viewing addition comments.

What I Have Tried

I first, of course, tried the documented media comment query in both the provided console and in my own environment. In both cases, a maximum of 150 comments were returned. Stumped, I began looking for more information online.

Having read over the Instagram API Documentation thoroughly, tested various endpoints in the Instagram API Console, and read various StackOverflow questions in the Instagram tag and Instagram API Google Group questions on several Instagram topics, I wondered if there was a chance of something being undocumented that I could try.

The user recent media endpoint documentation includes parameters for max_id and max_timestamp that allow for paging through the most recent media for any given user by retrieving the media that comes before said max_id or max_timestamp. Since each comment comes with created_time and id attributes, I attempted to add the parameters for max_id and max_timestamp (both on their own and together) for various comment IDs and timestamps in an attempt to page through comments. None of my attempts worked.

I am now at a standstill unless someone has another suggestion.

Specific Example

Using the Instagram API Console, I took the following steps in attempt to get all of the comments for this photo.

  1. Authenticated myself for an OAuth2 token
  2. Ran a user search query for coltonlhaynes to obtain the user id: 9610843
  3. Ran a user recent media query for user id: 9610843 to obtain the most recent media
  4. Gathered information about the most recent media (the above linked photo)
    • media id: 698057751201132903_9610843
    • comment count: 1375
  5. Ran a media comment query for media id: 698057751201132903_9610843 to obtain most recent comments
  6. Gathered information about the least recent comment
    • created time: 1397460230
    • comment id: 698269477955776593
  7. Ran a media comment query for media id: 698057751201132903_9610843 with the following additional query parameter strings in attempt to page through comments, but received the same results as step #6
    • ?max_timestamp=1397460230
    • ?max_id=698269477955776593
    • ?max_timestamp=1397460230&max_id=698269477955776593
    • ?max_id=698269477955776593&max_timestamp=1397460230

Please Note

To my knowledge, there is no solution to this issue, but since the Instagram Development Team has stated that they will no longer be monitoring the Google Group and will be monitoring StackOverflow instead, I'm putting this here.

Answer

Damian Nikodem picture Damian Nikodem · Jan 25, 2015

Ok, This is going to be a very "Hacky" solution, and I am not currently setup to do this myself (due to lack of ADSL at home) but I can provide a step by step guide of how I would approach this issue.

First of all you will need a tool called "Charles Web Debuging Proxy"

There is a tutorial on the site on how to enable "SSL debugging" in charles, (which will require you to install a new "root certificate" on your mobile device, to trick it into thinking that https transactions signed by charles are actually signed by instagram.com )

Now Set your mobile device to route all requests through said proxy ( which will have to be installed on your local wi-fi network.)

go to https://www.google.com and check that charles is logging both requests and responses.

Once this is all setup correctly then you can take a look at the API calls which the instagram app itself uses to generate said comment pages.