Back

Instagram API Essential Guide

Aug 1, 20246 minute read

What type of API does Instagram provide?

Instagram primarily uses a GraphQL API, but also offers other API types:

Instagram Graph API

Instagram's main API is called the Instagram Graph API, which uses GraphQL. Key points about the Instagram Graph API:

  • It allows developers to create applications that interact with Instagram data
  • It can be used to receive and post media, manage comments, search tags, obtain metrics, etc.
  • It requires a business account or creator account to access

GraphQL API Details

  • Instagram's GraphQL API allows specifying exactly what data to query using a type system
  • Queries are sent as strings in the body of HTTP POST requests
  • Responses are returned in JSON format
  • It provides more flexibility compared to REST APIs in querying specific data

Other API Types

While the main API is GraphQL-based, Instagram also offers:

  • Instagram Basic Display API - A REST API for basic read-only access to profile info, photos and videos
  • oEmbed API - For embedding Instagram content

Does the Instagram API have webhooks?

Here are the key points regarding Instagram API webhooks:

  1. The official Instagram API does have webhooks available.

  2. Webhooks allow you to receive real-time HTTP notifications of changes to specific objects in the Meta social graph.

  3. The main types of events you can subscribe to include:

    • message_reactions: When a customer reacts or unreacts to a message
    • messages: When messages are sent/received, including text, media, shares, story replies, etc.
    • messaging_postbacks: When a customer clicks an Icebreaker option or Generic Template button
    • messaging_seen: When a message has been read by the recipient
    • messaging_referral: When an ig.me link with a referral parameter is clicked
    • standby: For multi-app messaging flows when the app is not in control
  4. To use webhooks, you need the instagram_basic, instagram_manage_messages, and pages_manage_metadata permissions.

  5. There are some limitations, like not supporting gifs/stickers in messages.

  6. You configure webhook subscriptions in the developer dashboard under Messenger > Instagram Settings, not via API calls.

  7. The /subscribed_apps endpoint is for Facebook Messenger webhooks, not Instagram.

  8. Getting webhook notifications for new followers is not directly supported. A workaround is to periodically fetch the follower list and compare to find new ones.

In summary, while Instagram does offer webhooks for messaging-related events, some features like new follower notifications are not natively supported. The available webhooks focus primarily on messaging interactions rather than account-level changes.

Rate Limits and other limitations

Here's a summary of the API Rate Limits for the Instagram API:

API Rate Limit

Instagram has recently reduced its API rate limit from 5,000 to 200 requests per hour. This change is intended to align Instagram's API rate limitations with Facebook's current rate limits and to limit the ability of unauthorized actors to acquire large volumes of user data over time.

Performance Rate Limits

The current policy allows an app to make a maximum of 200 calls per user during a rolling one-hour window. This is not to be confused with the per-user limit, which can be more than 200 calls per hour but within the app maximum. For example, if there are 100 users on an app, it can make 20,000 calls within an hour.

Business Use Cases Rate Limits

All calls to Instagram Graph API are subject to Business Use Cases (BUC) rate limits. These limits are unique for each combination of an app and its user pair, and the call rate limit resets every 24 hours.

Key Points to Consider

  1. The rate limit indicates the maximum number of API calls an application can make within a certain time frame.

  2. When API requests exceed the higher rate limit, Instagram returns a "429 Too Many Requests" HTTP status code.

  3. Instagram occasionally updates its platform and API, which can alter rate limit policies or the behavior of certain endpoints.

  4. Optimizing API calls is crucial to avoid hitting error thresholds. This includes implementing batching procedures, response caching, and focusing on retrieving only essential data.

Best Practices

  1. Implement exponential backoff: When encountering rate limits, increase the delay between API calls exponentially with each retry attempt.

  2. Use webhooks where possible: This allows Instagram to push relevant data to your endpoints as events occur, reducing the need for frequent API calls.

  3. Manage third-party integrations: Ensure that integrated external tools and services adhere to optimization best practices and monitor their API traffic volumes.

  4. Optimize API calls: Review batching procedures, implement response caching, and focus on retrieving only essential data.

  5. Implement proper error handling and retry strategies in your code to avoid unnecessary API calls.

By following these guidelines and best practices, developers can more effectively work within Instagram's API rate limits and avoid common errors.

Latest API Version

Based on the search results provided, here is a summary of the most recent version of the Instagram API:

The most recent version of the Instagram API is the Instagram Graph API. This replaced the original Instagram API that was closed down in 2018. Key points about the current Instagram API include:

Key Points

  • The Instagram Graph API is now the primary way for apps to read and write to the Instagram platform.

  • It is much more restrictive than the previous API, requiring approval from Instagram to access data.

  • Developers need to use the Graph API to collect any Instagram data, and usage is restricted.

  • The latest version mentioned in the changelog is v11.0, introduced in June 2021.

Features and Capabilities

The Instagram Graph API allows developers to:

  • Get and publish media
  • Manage and reply to comments
  • Identify media where the user has been @mentioned
  • Find hashtagged media
  • Get basic metadata and metrics about other Instagram Business and Creator accounts

Access Requirements

To use the Instagram Graph API:

  • You need either an Instagram Business Account or Creator Account
  • You must create a Facebook Developer account
  • Your app needs to go through an approval process before being allowed to access data

Recent Changes

Some notable recent changes include:

  • Introduction of app-scoped user IDs (ASIDs) in v11.0+
  • Addition of time-based pagination parameters in v11.0+
  • Support for video Reels in API responses as of June 2022

In summary, the Instagram API has undergone significant changes in recent years, becoming more restricted but still providing key functionality for approved developers and business users. The most up-to-date version is the Graph API, with v11.0 being the latest major version mentioned.

How to get a Instagram developer account and API Keys?

Here's how to get a developer account for Instagram to create an API integration:

Step 1: Create an Instagram Business Account

  1. Convert your Instagram account to a Business account in the Instagram app settings.

  2. Go to your Instagram profile settings and select "Switch to Professional Account", then choose "Business".

  3. Select a category for your business and optionally add contact information.

  1. Create a Facebook Page if you don't already have one.

  2. In your Facebook Page settings, go to "Professional Dashboard" and select "Linked Accounts".

  3. Click "Connect Account" for Instagram and follow the prompts to link your Instagram Business account to your Facebook Page.

Step 3: Create a Facebook Developer Account

  1. Go to the Facebook for Developers website (developers.facebook.com).

  2. Click on "My Apps" in the top menu.

  3. Click "Create App" and select "Business" as the app type.

  4. Enter a name for your app and your contact email.

Step 4: Set Up Instagram Graph API

  1. In your newly created Facebook app, find "Instagram Graph API" in the list of products.

  2. Click "Set Up" next to Instagram Graph API.

What can you do with the Instagram API?

Here's a list of data models you can interact with using the Instagram API, along with what is possible for each:

User

  • Retrieve basic profile information (username, full name, profile picture, bio)
  • Get follower and following counts
  • Access media count
  • Retrieve user's media (posts, stories for own account)

Media

  • Retrieve media items (photos, videos, carousels)
  • Get media metadata (caption, timestamp, media type)
  • Access engagement metrics (like count, comment count)
  • Publish new media items (posts, stories) to business accounts
  • Add location information to media

Comments

  • Retrieve comments on media items
  • Post replies to comments

Insights (for business accounts)

  • Access account-level insights (followers, reach, impressions)
  • Retrieve media-level insights (engagement, reach, impressions)

Business Discovery

  • Access public information of other business accounts
  • Retrieve media data from other business accounts

Hashtags

  • Search for hashtags (limited functionality)

Locations

  • Search for locations based on coordinates

Restrictions and Limitations

  • Cannot access stories of other accounts
  • Limited access to personal accounts (non-business)
  • Cannot send or read direct messages through the primary Instagram API
  • Cannot like posts or interact with other accounts' content programmatically

Key Points to Consider

  • Most advanced features require a business or creator account
  • API access is subject to rate limits and usage policies
  • Some functionalities may require additional permissions or app review

It's important to note that the Instagram API has undergone significant changes over time, and many previously available features have been restricted. The current API focuses primarily on business use cases and content creation for your own account, rather than broad data collection or interaction with other accounts.