Software Architect / Microsoft MVP (AI) and Technical Author

C#, Cognitive Services, Facebook API, Instagram Graph API, Machine Learning, Social Media

Instagram Graph API – Part 1: Introducing the Instagram Graph API and how do you connect to it?

Last week I outlined the main topics I’d be covering a miniseries that shows how to extract data using the Instagram Graph API with C#.  You can read what prompted me to draft this miniseries here.

To recap, here we’ll be covering the following topics:

  • Part 1 – Introducing the Instagram Graph API and how do you connect to it?
  • Part 2 – Fetching data with the Insights API
  • Part 3 – How to write an API in C# that extracts data using the Instagram Insights API
  • Part 4 – How you can use Azure Cognitive Services to surface insights in Instagram data

This is part one.

Why Use the Instagram Graph API?

In today’s attention economy influencers and brands are prolific on multiple social media platforms and with more than 1 Billion monthly active users (MAU) its safe to say that a lot of eyeballs are on Instagram!

Users take to Instagram to share and comment on the things that matter to them. Some recommend products or services with photos, accompanying hashtags and even location data.

In the last 10 years we’ve seen businesses and brands effectively day trade user attention as it shifts from one digital platform to another.  The advertisers targeting palette has never been so rich.

Instagram is one of the most popular platforms at the minute and ships with a developer API that lets you build solutions can programmatically:

  • join in on conversations users are having and engage them
  • search for other businesses
  • publish media
  • reply to and delete comments on your Instagram Media
  • search for photos by hashtag
  • get metrics for Business Accounts and media
  • ….and much more!

The Original Instagram API v the Graph API

In 2018, Facebook introduced that endpoints of the original Instagram API would be getting deprecated:

“Starting today (January 30), we are launching three new features on the Instagram Graph API designed to help businesses better manage their organic presence on Instagram. As part of our API changes, we will also be deprecating the older Instagram API Platform over the next two years beginning on July 31, 2018”

The bottom line is that if you want to build applications that tap into Facebook and Instagram data, you need to use the Graph API. Complete deprecation of the original Instagram API will be completed by 2020.  You can read exactly what is getting deprecated here.

Another thing to note is that for access to some API endpoints and data you need an Instagram Business Account.

What API Endpoints are available?

Depending on your requirements you’ll need to tap into the API endpoints that are relevant for you, here is a high-level overview of each API:

Business Discovery – The Business Discovery API is a subset of Instagram Graph API endpoints that allow you to get basic metadata and metrics for other Instagram Business Accounts.

Content Publishing – The Content Publishing API is a subset of Instagram Graph API endpoints that allow you to publish IG Media objects on Instagram Business IG Users.

Comment Moderation – The Comment Moderation API is a subset of Instagram Graph API endpoints that allow you to reply to comments, delete comments, hide/unhide comments, and disable/enable comments on media objects owned by Instagram Business and Instagram Creator Accounts.

Hashtag Search – The Hashtag Search API allows you to find public photos and videos that have been tagged with specific hashtags.

Insights – The Insights API allows you to get social interaction metrics for IG Users and their IG Media objects. Amounts for each metric are calculated upon API request.

Mentions – The Mentions API is a subset of Instagram Graph API endpoints and Webhooks. They allow you to identify captions, comments, and media in which an Instagram Business or Creator Account’s alias has been tagged or @mentioned.

With each of these functional areas you’ll find discrete REST API endpoints.  For example, the Insights API features the following:

GET /{ig-media-id}/insights — gets metrics on a media object

GET /{ig-user-id}/insights — gets metrics on an Instagram Business Account or Instagram Creator account.

You can read a more detailed documentation about these API endpoints here.

For the purposes of this miniseries we’ll be using the Insights API to extract data from an Instagram Business account.  Before we can do that however, a few things to be setup first which brings us onto…

What do you need to connect to the Instagram Graph API?

Connecting to the Instagram Graph API involves a few steps.  Initially it wasn’t entirely intuitive to me, especially when dealing the Graph API Explorer.

For example, when using the Graph API Explorer you need to drill down into the Facebook Pages that your user can manage, then identify the Page ID and use this in a subsequent query to actually get the data you need from the Instagram Business Account that you’re interested in.

One of the reasons for this mini-series was to document the steps and give me a point of reference to follow in the future!

At a high level you need the following in place:

  1. An Instagram Business User account
  2. Facebook Page connected to that account
  3. A Facebook Developer account that can perform Tasks on that Page
  4. registered Facebook App with Basic settings configured

There is an end to end tutorial here which guides your through steps 1 -4. Reach out to me if you need help with this.

Test your connection to the Instagram Graph API with the Graph API Explorer

When you’ve configured your Instagram Business Account, connected your Facebook Page and assigned the relevant permissions to your Facebook application you can then connect to the Instagram Graph API!

It’s a good idea to test the connection before we move on, to do this you can use a tool called the Graph API Explorer which is accessible from the Facebook Developer Console.

From the Graph API Explorer you can supply the following URL:{PAGE_ID}?fields=instagram_business_account&access_token={access-token}

After submitting this URL to the Graph API Explorer it will returned the ID of the Instagram Business Account.  In the screenshot below I’ve hidden the Page ID blue and the Access Token in black:

Now that we’ve been able to connect to the Instagram Business Account, we can start to make requests to the Instagram Graph API!


In this article, we’ve introduced the Instagram Graph API and the API endpoints that it ships with.  We’ve also looked at the main steps you need to go through in order to connect to the Instagram Graph API and some tooling that lets you test connectivity.

In Part 2 of this miniseries, we’ll connect to the Insights API and see how you can use that to extract image related data such as the number of likes or comments per image.


Enjoy This Blog?

Get more in the eBook.

This contains an end to end solution and entire source code.

Available on Gumroad here.




Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.


  1. Rahul

    Hi Jamie,

    First, thanks for this post, it is helpful to understand the basics and about the prerequisite of API call in very simple language.

    Can you guide about the API calling via C# code to get Instagram account feeds in response?

    Also, just want to reconfirm, is it mandatory to have Business account and facebook page, it just want to fetch feeds, as having Instagram Basic Display API, will it work in my case when only want to fetch and display feeds?

  2. David

    Hi jamie,
    For instagram graph api is there any doc for handling authorisation like basic display api. We can use Graph API Explorer but i need it to be call within any app like refreshing token after expires. i don’t see any endpoints in Graph API to refresh token or to get access token for instagram account.

  3. Adithya

    Hi Jamies,
    Can Business Discovery API be used to get the post comments and followers of a public page like IBM or barclays profile?

    Thanks in advance.

  4. Imad

    Hello Jamie,

    Thanks for your post, I find it very interesting and helpful!

    If I only need to fetch metrics about public posts of public non business accounts, do I still need to have a Business account and a Facebook page connected to it ?


Leave a Reply