Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

Instagram Basic Display API Guide: Fetch Instagram User Info

Lixiong Wei

Lixiong Wei

Updated on November 29, 2024

Instagram, with its visually-driven platform, has become a powerful tool for businesses, developers, and creators. To enhance the user experience and facilitate seamless integration, Instagram provides two essential tools: Instagram Graph API and Instagram Basic Display API. In this article, we'll focus on the capabilities of Instagram Basic Display API and how it can be leveraged to optimize your Instagram presence.

💡
Apidog is an All-in-one API development platform which allows you to easily design, test, and document your API. For the one who wants to test Instagram API, using Apidog is always the easiest solution.
button

Instagram Basic Display API

The Instagram Basic Display API is a tool provided by Instagram (a subsidiary of Facebook) that allows developers to access basic user information, media content, and other data from Instagram accounts. This API is specifically designed for scenarios where read-only access to user data is required, making it suitable for applications that focus on displaying Instagram content or providing personalized experiences.

Set up before accessing to API

Requirements:

1. A Facebook developer account.

2. A tester Instagram account.

3. A web page (URL) for redirect, to grant permission for the application to access Instagram.

Steps for setup:

  1. In developer page, click on Create App. Select Other to proceed.
create app facebook

2. choose customer as app type for Instagram basic display API

choose app type

Next, fill in your information (App name, contact email) and proceed

3. Set platform URL. Go to setting > basic, click on add platform at the bottom and enter your URL (The web page mentioned in requirement).

edit basic info
update website url

4. Set up Instagram Basic API on dashboard

set up instagram basic api

After the app is created, a form will appear with some things to be saved and to be filled in.

check api info

App ID and secret will be needed later.

5. Enter the same URL as before in Valid OAuth redirect URI, Deauthorization callback URL and data deletion request since this app is for testing purpose.

client oauth uri

Add tester into the form, for example, if Alice want to retrieve Bob’s information, then enter Bob account username.

add app roles

After adding a user, the status of the user will be pending since authorization from user is needed. It is recommend to use the tester account.

6. Login to your tester Instagram account, go to settings> website permission> Apps and Websites> Tester Invites. Accept the test invitation.

login to tester instagram account

Basic set up is complete!

How to request for authorization?

Authorization code is needed before using API, the survival time of this authorization code is 1 hour. To obtain the code, enter the URL in this form:

https://api.instagram.com/oauth/authorize?client_id={app-id}&redirect_uri={redirect-uri}
&scope=user_profile,user_media
&response_type=code

Explanation for the attributes:

 App-id: The application id is the app-id, this can be found in basic display under Instagram basic display app.

 redirect_uri: the same URL as valid OAuth redirect URI.

redirect uri

Remember not to leave space for the whole URL.

After click on enter, it will go to the page for allowing authorization.

allow auth

After allowing all access, it will redirect to the your own url, with code parameter attached to url, looks like

https://www.example.com/?code=ABCD......#_

The authorization code is the one after code=, remember to delete the #_ since this is not the part of authorization code.

How to use Apidog to use exchange the code to access token?

Apidog is an All-in-one API development platform which allows you to easily design, test, and document your API. For the one who wants to test Instagram API, using Apidog is always the easiest solution.

button

Convert the authorization code to access token

Switch method to POST, input URL:

https://api.instagram.com/oauth/access_token

Added these parameters that is needed:

  • client_id = Instagram App ID
  • client_secret = Instagram App secret
  • code = Authorization code obtained
  • grant_type = authorization_code (This value is set)
  • redirect_uri = your own URI
Set up with Apidog

Click on send, the access token will be returned in form of JSON file, looks like:

{
"access_token": "IGQWR9......",
"user_id": 7666070400110123
}

Note: the token is also valid for 1 hour

How to use access token and user ID to query account information?

There are brunch of features can be fetch using Instagram Display Basic API, here below are two examples of information retreiving.

  1. access an account's basic information

Sample request using curl:

curl -X GET \  'https://graph.instagram.com/{user-id}?fields=id,username&access_token={access-token}'

Parameters explanation:  

  • User_id: get from previous step
  • Access_token: from previous step
  • Fields: can be partially optional.  There are 4 type of fields available:
1. Account_type: account type 
2. Id: user_id 
3. Media_count: number of posts
4. Username: account name

If you want to get all of these four, enter all of them separate by comma (,)

Set up in Apidog

The return result:

2. Retrieve user’s post information

Sample request:

curl -X GET \ 
'https://graph.instagram.com/me/media?fields=id,caption&access_token=IGQVJ...'

Set up in Apidog:

For more features with Instagram display API, refer to:

Get Profiles and Media - Instagram Platform - Documentation - Meta for Developers

Conclusion

In conclusion, the Instagram API opens up a world of possibilities for developers to interact with the Instagram platform and create innovative applications. From accessing user information and media content to posting new photos and videos, the diverse range of endpoints allows developers to tailor their applications to specific needs.

How to Access Claude 3.7 Sonnet API and Test Using ApidogTutorials

How to Access Claude 3.7 Sonnet API and Test Using Apidog

Learn how to access Anthropic’s Claude 3.7 Sonnet API and test it with Apidog in this step-by-step tutorial. Discover setup, configuration, and best practices for exploring Claude’s coding and reasoning powers efficiently, perfect for developers seeking to leverage this advanced AI model.

Ashley Innocent

February 25, 2025

A Developer’s Guide to Testing LLM AI APIs with SSETutorials

A Developer’s Guide to Testing LLM AI APIs with SSE

Discover how Apidog's upgraded SSE debugging enhances real-time interaction with AI models. Streamline testing, visualize AI’s thought process, and customize response handling for AI APIs, ensuring an efficient and transparent debugging process.

Oliver Kingsley

February 20, 2025

How to Build Websites Using Lovable AITutorials

How to Build Websites Using Lovable AI

Discover how to build any website using Lovable in this comprehensive guide. Learn step-by-step processes, explore innovative features, and integrate free tools like Apidog to streamline API management.

Ashley Innocent

February 19, 2025