I am trying to create a program that retrieves the total number of likes, comments, etc from an Instagram account, not necessarily the content of comments etc but just gives the total number of likes and comments from a specific account. Is that possible using the Instagram API?
2 Answers
So I've been stuck on this exact problem and here's the pertinent bit of my research for Instagram so far.
With "basic display" access one can get access to username, the total posts by the user, and the user id. That gives access to the actual posts, but not any anylitics to do with it, ie. no likes, shares, comments etc. Just a list of URL's.
You can use the "Business Discovery" endpoint (pulls profile info, follower counts, posts and associated like and comment counts) in two ways; 1. Authorize your own facebook page, create a long lived access token using curl or some other method and code it into your app and reuse the same token to pull all that data... But it's rate limited to something like 200 requests an hour. 2. Request permissions from the user, with a facebook access token. This is the most annoying bit. In order to get insights or any advanced data from the instagram graph api, the instagram user has to be a creator or business account, and MUST link a facebook page to the instagram account. And then use their info to request the data, thus no rate limits.
The benefit to point 1 above is that it doesn't really require an app review, since you are using your own testing account. But again, the rate limit and high probability of change is a negative.
You could also request instagram insights permissions, which would give you lots of information, but thats the same issue as point 2 above. Expanded permissions.
This permission would allow you to pull things like; -A list of cities of the users followers -A list of countries of users followers -The gender and age distribution -Post impressions (Total number of times the IG User's IG Media objects (i.e. posts, stories and promotions) have been viewed. Includes ad activity generated through the API, Facebook ads interfaces, and the Promote feature. Does not include profile views.) -Active followers (Total number of the IG User's followers who were online during the specified range.) -Profile Views (Total number of users who have viewed the IG User's profile within the specified period. -Reach (Total number of times the IG User's media objects (i.e. posts, stories and promotions) have been uniquely viewed. Includes ad activity generated through the API, Facebook ads interfaces, and the Promote feature.)
relevant doc -> https://developers.facebook.com/docs/instagram-api/reference/user/insights
But the unfortunate thing, is that there is also this relevant doc -> https://developers.facebook.com/docs/instagram-api/overview#authentication

- 491
- 3
- 9
You can use business discovery in instagram graph api. This api can get account data from the other user by their username. (but it is still using your own facebook token)
sample req:
https://graph.facebook.com/v3.2/17841406390881400? fields=business_discovery.username(mattttgogogo){followers_count,media_count,media{media_url,timestamp,like_count,comments_count, permalink}}&access_token=
sample res:
{
"business_discovery": {
"followers_count": 113,
"media_count": 19,
"media": {
"data": [
{
"media_url": "https://scontent.cdninstagram.com/v/t51.2885-15/53548713_2066113247020455_3245400417240682448_n.jpg?_nc_cat=107&ccb=2&_nc_sid=8ae9d6&_nc_ohc=UIQzZq1WznMAX8utxLk&_nc_ht=scontent.cdninstagram.com&oh=b1fcd69119164fb4291b56aae212446a&oe=602439D5",
"timestamp": "2019-03-10T10:03:49+0000",
"like_count": 29,
"comments_count": 1,...
Not sure if they provide an api to get the sum, but at least you can calculate based on the response

- 31
- 1