The endpoints documented on this page were deprecated on October 24, 2020 and now return an error code 400. Please use the new Instagram oEmbed endpoint instead.

Instagram oEmbed (Legacy)

You can get a public Instagram photo or video post’s embed HTML code and use it to embed the post in other websites. Embedded posts automatically resize to fit their container, so they will look great on both desktop and mobile websites.

People own their Instagram content, so each embedded post gives proper attribution by displaying the post owner’s username and linking to the post owner’s profile.

Limitations

The GET /oembed and GET /p/{post-url}/media endpoints are only meant to be used for embedding Instagram content on websites and apps. They are not to be used for any other purpose. Using metadata and media content (or their derivations) from the APIs for any purpose other than providing a front-end view of the media content is strictly prohibited. This prohibition encompasses consuming, manipulating, extracting, or persisting the metadata and media content, including but not limited to deriving information about posts from the metadata for analytics purposes.

GET /oembed

Returns a JSON object containing the post’s embed HTML code along with additional data about the post and post owner. Use the embed HTML code to embed the post in a website.

Requirements

No access tokens or permissions are required.

Request Syntax

GET https://api.instagram.com/oembed

Query String Parameters

KeyValue Description

url
Required

The post's URL.

callback

A JSON callback to be invoked.

hidecaption

If set to true, the embed code hides the caption. Defaults to false if parameter is not included in request.

maxwidth

Maximum width of returned media. Must be greater than 320. Note that the maxheight parameter is not supported and always returns null. This is because the embed code is responsive and its height varies depending on its width and length of the caption.

omitscript

If set to true, the returned embed HTML code will not include the <script> tag. See Embed.js below.

breaking_change

Set to oembed to have the endpoint respond with an error code 400 and the message: This endpoint is deprecated, please go to https://developers.facebook.com/docs/instagram/oembed to learn how to migrate your endpoint.

Response

A JSON object containing the the post’s embed HTML code and additional data about the post and post owner. The embed HTML code will be assigned to the html property.

Sample Request

https://api.instagram.com/oembed?url=https://www.instagram.com/p/fA9uwTtkSN/

Sample Response

{
    "version": "1.0",
    "title": "Wii Gato (Lipe Sleep)",
    "author_name": "diegoquinteiro",
    "author_url": "https://www.instagram.com/diegoquinteiro",
    "author_id": 9538472,
    "media_id": "558717847597368461_9538472",
    "provider_name": "Instagram",
    "provider_url": "https://www.instagram.com",
    "type": "rich",
    "width": 658,
    "height": null,
    "html": "<blockquote class=\"instagram-med... ",
    "thumbnail_url": "https://scontent-sjc3-1.cdni...",
    "thumbnail_width": 640,
    "thumbnail_height": 640
}

Embed.js

Embed HTML code contains post HTML and a reference to the Instagram embed.js JavaScript library. When the library loads, it scans the page for the post HTML and generates the fully rendered post. If you want to load the library separately, include the omitscript query string parameter in your request. To manually initialize the embed code, call the instgrm.Embeds.process() function after loading the library

Post Size

The embedded post is responsive and will adapt to the size of its container. This means that the height will vary depending on the container width and the length of the caption. You can set the maximum width by including the maxwidth query string parameter in your request.

GET /p/{post-url}/media

Redirects to one of three versions of the post’s image file. If loading the embed code is not an option and you embed an Instagram image this way, you must provide clear attribution next to the image, including attribution to the original author and to Instagram, and a link to the Instagram media page. Use the GET /oembed endpoint to determine author information.

Requirements

No access tokens or permissions are required.

Request Syntax

GET /p/{post-url}/media

Path Parameters

PlaceholderValue Description

{post-url}
Required

The post's URL.

Query String Parameters

KeyValue Description

size

The size of the post image you want returned. Supported values are t (thumbnail), m (medium), l (large). Defaults to m if parameter is not included in request.

breaking_change

Set to oembed to have the endpoint respond with an error code 400 and the message: This endpoint is deprecated, please go to https://developers.facebook.com/docs/instagram/oembed to learn how to migrate your endpoint.

Response

The post’s image file (JPG).

Sample Request

https://instagram.com/p/fA9uwTtkSN/media/?size=t

Sample Response

https://scontent-sjc3-1.cdninstagram.com/v/t51.2885-15/e15/s150x150/11358196_1472850273007829_614249870_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com&_nc_cat=105&_nc_ohc=FpsdQMVbM6AAX8zwNvs&oh=b42d2a9cc8d08acce945b675ef4e952f&oe=5E6BFACA