Integrate Instagram API with Google Sheets

How to integrate Instagram with Google Sheets

Instagram’s API has a lot of features, including the ability to track hashtags and analyze performance data, collect data about mentions, embed Instagram photos on a website, and more.

In this tutorial, I’ll show you how to connect the Instagram API to Google Sheets and import Instagram data to Google Sheets, without writing any code, in 9 easy steps:

  1. Install the Apipheny Add-on
  2. Create a Facebook API app
  3. Configure Facebook Login
  4. Get a Facebook API User Access Token
  5. Get the User’s Page ID
  6. Get the Page’s Instagram Business Account ID
  7. Choose an Instagram API URL endpoint
  8. Enter your Instagram API URL into Apipheny
  9. Run the Instagram API Request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Create a Facebook API app

Start by navigating to https://developers.facebook.com/ and click My Apps > Create App:

Facebook - create API app page
Facebook – create API app page

Fill out your app’s display name and contact email and click Create App ID:

Create Facebook App ID
Create Facebook App ID

You’ll then be directed back to your Facebook Developer dashboard.

3.) Copy and paste your App ID from under the app’s name to a safe location, because you will need the APP ID again in the later steps:

Copy your Facebook App ID somewhere safe
Copy your Facebook App ID somewhere safe

Step 3.) Configure Facebook Login

  1. Add the Facebook Login product to your app in the App Dashboard, by clicking the plus (+) button next to Products and adding Facebook Login:
Click the plus button next to products in the Facebook App Dashboard
Click the plus button next to products in the Facebook App Dashboard

2. Click the Setup button corresponding to the Facebook Login card:

Click the Setup button next to the Facebook Login card
Click the Setup button next to the Facebook Login card

3. Choose the platform you want to use. In this case we chose Web:

Choose your platform
Choose your platform

4. Enter your redirect URI in the Valid OAuth redirect URIs field (you can use https://www.apipheny.io/ if you want), and then click the Save Changes button:

Enter your redirect URI
Enter your redirect URI

Step 4.) Get a User Access Token

In your browser’s address bar, paste the following URL, but replace the fields in curly braces, then press Enter:

https://www.facebook.com/v7.0/dialog/oauth?client_id=app_id&redirect_uri=redirect_URI &state=random_string&response_type=token&scope=instagram_basic,pages_show_list,instagram_manage_insights
  • app_id is your app ID
  • redirect_URI is the redirect URI you used in Step 3.) above
  • random_string is any random string of your choice

Facebook will ask you to confirm your account and to associate it with your app. Select your account, then click the Next button:

Connect your Instagram account to the Facebook app
Connect your Instagram account to the Facebook app

Next, select the page you want to use with your app, then click the Next button:

Select the Facebook page you want to use with your app
Select the Facebook page you want to use with your app

On the following step, confirm the app’s access rights and click the Done button:

Choose your API permissions and click Done
Choose your API permissions and click Done

Finally, click the OK button to confirm linking your Instagram app:

Press OK
Press OK

Your browser will be redirected and your access token will be displayed in the address bar.

Copy and paste your Facebook access token to a safe location, because you’ll need it again in the next steps:

Facebook access token in the URL bar
Facebook access token in the URL bar

Step 5.) Get the User’s Page ID

In your browser’s address bar, paste the following link, replace your access token, then press Enter:

https://graph.facebook.com/me/accounts?access_token=access_token

access_token is the access token you obtained previously at the end of Step 4. Just replace it with your token.

Getting Facebook page ID
Getting Facebook page ID

In the response you receive, you’ll get your Page ID. Copy and paste your Page ID to a safe location because you will need it again in the next steps.

Step 6.) Get the Page’s Instagram Business Account ID

In your browser’s address bar, paste the following link, replace the Page ID and the access token, then press Enter:

https://graph.facebook.com/page_id?fields=instagram_business_account&access_token=access_token
  • page_id is the Page ID you obtained in Step 5.
  • access_token is the access token you obtained at the end of Step 4.

From the received response, you’ll get your Instagram Account ID. Copy and paste your Instagram Account ID to a safe location because you will need it in the next steps:

Instagram Account ID
Instagram Account ID

Step 7.) Choose an Instagram API URL endpoint

In this section, we’ll show you how to browse the Instagram API documentation to find an API endpoint URL that retrieves the information you need from Instagram.

If you’re unsure what an API is, or how it works, let me explain briefly. Every API has a URL. Every API URL has endpoint(s) that you can use to specify what exact data you want returned from the API.

If you already know the Instagram API URL and endpoint that you want to use, or you want to use the same example URL and endpoint as us, just skip to Step 8.

To find your endpoint, first open the Instagram API documentation page: https://developers.facebook.com/docs/instagram

You’ll see that the menu on the left contains a list of available Instagram APIs:

Instagram API homepage
Instagram API homepage

For example, click on the Instagram Graph API, then click the Reference item. There you’ll find a list with all the available endpoint categories:

Instagram API endpoint documentation
Instagram API endpoint documentation

The Page category contains multiple endpoints:

Instagram API Page endpoint documentation
Instagram API Page endpoint documentation

One of the Page category endpoints is Getting a Page’s IG User, which returns the Instagram User connected to the Facebook Page:

https://graph.facebook.com/page-id?fields=instagram_business_account

page-id is the ID of the connected Facebook Page.

The documentation for this endpoint contains the endpoint’s HTTP method (GET) and API URL, a short description of the endpoint’s purpose, a list of the required permissions, an example request and its accompanying response:

Instagram API endpoint reference
Instagram API endpoint reference

Step 8.) Enter your Instagram API URL Into Apipheny

Now, to get your Instagram data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened to the “Import” tab.

In the Import Tab, enter the following details into the Apipheny add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your Instagram API endpoint. For this example, we are using the “GET” method.

API URL: In Step 7, we explained how you can find the Instagram API endpoint that you need. Now copy your complete Instagram API URL into the Apipheny add-on, in the field that says API URL Path (JSON / CSV), followed by any GET parameters required for your query (if applicable).

For this example, we are using the Business Discovery endpoint, which allows you to get basic metadata and metrics about other Instagram Business and Creator Accounts. The corresponding API URL is:

https://graph.facebook.com/account_id?fields=business_discovery.username(username){followers_count,media_count}&access_token=your_access_token
  • {account_id} is YOUR account ID
  • {username} is the username of the account you want to pull data for
  • {your_access_token} is the access token you obtained previously
  • {followers_count,media_count} are the fields that will be obtained in the response and they should be used as they are, between curly braces

Headers: No headers are required for this Instagram API request.

Instagram API request entered in the Apipheny Google Sheets add-on
Instagram API request entered in the Apipheny Google Sheets add-on

Step 9.) Run the Instagram API Request in your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your Instagram data will be imported into your Google Sheets, congratulations!

Instagram API integrated with Google Sheets and Instagram data imported into Google Sheets using the Apipheny add-on
Instagram API integrated with Google Sheets and Instagram data imported into Google Sheets using the Apipheny add-on

After making a successful request to the Instagram API in your Google Sheet, try querying a different Instagram API endpoint, or try using one of the more advanced features in the Apipheny add-on.


Crypto API Tutorials:


API Tutorials


API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?


If you want to import Instagram data into Google Data Studio, follow the steps above to integrate the Instagram API with Google Sheets, then connect your Google Sheet to Google Data Studio.

Google Sheets API Integration Demo