19
Feb

Using Instagram Graph API to access any business account followers and media count

Using Instagram Graph API to access any business account followers and media count

Instagram is a social networking site for sharing photos and videos. But more than that, Instagram is also being used by many companies, brands and shops to promote their business. By using Instagram business account, companies can get real time metrics, followers insights, comments and details like these to see how their visitors are reacting to their Instagram branding strategies.

What is API?

API is the acronym for Application Programming Interface. It allows two applications to talk to each other using some software program.

What is Instagram Graph API?

The Instagram Graph API allows users to programmatically access Instagram Business Accounts data for eg. media, comments, followers, etc. It makes the Instagram data easily manageable by binding API response into a Custom API integration.

Steps to get business account followers from your account:

1. Login to facebook and create a facebook page of your brand or company to link with instagram business account.

2. Create an instagram account for your business

3. Now connect your facebook page with instagram account. Follow these steps:

    • Go to facebook page’s setting.
    • Click on Instagram.
  • Login with your Instagram account. If you do not have business account of instagram, then after login from here, it will prompt to setup the business account. Convert your account to business account by continuing with the steps. It is necessary to have Instagram business account to work with Instagram graph API.

facebook page setting

4. Now go to https://developers.facebook.com. If not login already, login with your facebook ID.

5. Go to My Apps > Create New App:

facebook developer

6. Create App, by filling details in Form, Display Name is your App Name:

app id

Here we have selected Social_connect as our App Name. Once created, you will be redirected to App detail page:

7.  Now go to Tools>Graph API Explorer:

Graph API Explorer

8. Make sure your App is selected in Application. If not, select it from the dropdown:

Application Application 1

token

It will show a Permission popup:
Select manage_pages , instagram_basic and insights permissions.

permission popup

10. It creates an access token and adds automatically to Access Token field:

access token

One thing to note is that, this token is short term token and expires in few hours. To bind token in our app, we generally need long-lived token. To generate a long-lived token, follow these steps:

  • Click on info icon:

info icon

  • Click on Open in Access Token Tool.

open in access token tool

  • It will open Access Token Info page. Click on Extend Access Token button in that page:

extend access token

  • It will generate long lived token, which is good to go for at least 2 months:

extend access token 2

The long lived token can also be generated using API call. You can find more information about this in the following link:  https://developers.facebook.com/docs/facebook-login/access-tokens/refreshing#long-via-code

11. Now we need our page id to proceed. There are 2 options to get facebook page id.

  • In the API path, type “me/account” and hit Enter. Id received in data is page id.

graph api

  • You can also get Page ID from About section of your facebook page:

facebook setting page

12. Enter your page ID in API path and hit the Enter button; it will return page name and page id:

api path

13. You need to have instagram_business_account id to proceed with Instagram Graph API.  For this, select instagram_business_account from Search fields left side and hit enter. You will receive id of your instagram_business_account:

instagram account

14. Now enter instagram_business_account id to API path.

15. To get followers count for a business account, get the business account username and put it in this API url:

?fields=business_discovery.username(<enter account username here>){followers_count,media_count}
For example : ?fields=business_discovery.username(bluebottle){followers_count,media_count}

Add this path after instagram_business_account_id in API url and you will receive followers count and media count as response:

business account

share

Comparing every inch of Angular JS and React JS

Comparing every inch of Angular JS and React JS

previous-blog-arrowPrevious
Ficode is a Leading Design Agency in the UK

Ficode is a Leading Design Agency in the UK

next-blog-arrowNext