How to retrieve comments from a media in instagram?

11,827

Solution 1

You have to be in live mode and have public_content permission to get comments.

sandbox mode will only give you and your sandbox user's info in API response, if you or your sandbox user have commented on a media then that will only show in response, once u go live mode, all comments will be in response.

Also API will only give you maximum of 150 latest comments for any media, not all.

Solution 2

You can use cURL to get 40 comment per 1 request likes this

"linkOfMedia"/?__a=1

and then take comment in graphql->shortcode_media->edge_media_to_comment->edges. If you want more you should take end_cursor at page_info object then add &end_cursor= after the link.

Share:
11,827
user2614596
Author by

user2614596

Updated on June 05, 2022

Comments

  • user2614596
    user2614596 about 2 years

    I'm working on a project which aims to analyse instagram users' posts. I have a list of users and for each of them I have to crawl the recent media with the number of likes, comments and the text of comments. By using the recent media endpoint I've achieved some user media (of my user, using the access_token associated to my account). The result only gives the number of comments per media, but not the text. So I selected some media_id from this output and tryied to retrieve the comments associated to the media. But the result is ever

    {"meta": {"code": 200}, "data": []}

    The endpoint url that I use is

    https://api.instagram.com/v1/media/{media-id}/comments?access_token=ACCESS-TOKEN

    the access_token is generated with public_content, follower_list and basic scopes.

    My app is in a sandbox, and I am the only one user of the sandbox. Any suggestion? thanks in advance

  • FarmerGedden
    FarmerGedden almost 7 years
    Unfortunately this approach is against Instagram's Terms of service: "We prohibit crawling, scraping, caching or otherwise accessing any content on the Service via automated means, including but not limited to, user profiles and photos (except as may be the result of standard search engine protocols or technologies used by a search engine with Instagram's express consent)."
  • Quyen Anh Nguyen
    Quyen Anh Nguyen over 6 years
    Thank you. I understood and now this approach can't work anymore.
  • afsarkhan10182
    afsarkhan10182 over 4 years
    Does this answer is valid in 2019? As instagram has done many changes to its API
  • krisrak
    krisrak over 4 years
    This API is deprecated now
  • afsarkhan10182
    afsarkhan10182 over 4 years
    Without Automation BOT is it possible in 2019?