You need an API to get post data from Instagram—specifically, to input a public post URL and return the media, dimensions, and identifiers you can ship into your app this week. By the end of this guide, you’ll be able to fetch Instagram post/publication data from a URL, pull account data by username, and get reel metrics by shortcode using the Instagram Data API on Zyla API Hub, with copy-pasteable curl and Python examples.
What this API gives you and when to use it
The Instagram Data API exposes three focused read endpoints:
- Get Post Data: provide a public Instagram post URL and receive the post/publication data, including media URLs, dimensions, and identifiers.
- Get Account Data: provide a username and receive the Instagram account data, including biography and bio links.
- Get Reel Data: provide a post/reel shortcode and receive public engagement metrics like likes, comments, and video_view_count.
Typical uses include content ingestion pipelines, link unfurling, media preview generation, analytics dashboards, and moderation queues. You send the exact URL or shortcode you already have; the API returns the structured fields to power your UI or workflow.
The API is available on Zyla API Hub, a marketplace with more than 10,000 public APIs, unified under one account, one API key, and a subscription + quota model (not pay-per-call). For this API, the first subscription offers a 7-day trial; check the listing for current access options and pricing.
Getting started on Zyla API Hub
- Open the Instagram Data API listing: Start 7-day trial on Instagram Data API.
- Click Subscribe (or Start Free Trial when available) and obtain your API key.
- Use the key in the Authorization header as: Authorization: Bearer YOUR_API_KEY.
All requests in this article target the Zyla Hub endpoint URLs. No origin hosts, SDKs, or extra auth params are required—just send HTTPS GET requests with your bearer token and the documented query parameters.
Endpoint: Get Post Data (by URL)
Retrieve Instagram post/publication data by passing the public post URL. Useful when your system stores or receives a link (e.g., from a user submission) and you need identifiers, media URLs, and dimensions for rendering or downstream processing.
- Method: GET
- URL: https://zylalabs.com/api/855/instagram-data-api/630/get-post-data
- Required query param:
- link (string): a public Instagram post URL, for example https://www.instagram.com/p/BsOGulcndj- (must be URL-encoded in the query string)
curl example (copy-paste)
curl -s -X GET "https://zylalabs.com/api/855/instagram-data-api/630/get-post-data?link=https%3A%2F%2Fwww.instagram.com%2Fp%2FBsOGulcndj-" \
-H "Authorization: Bearer YOUR_API_KEY"
Official sample response
{
"status": true,
"__typename": "GraphImage",
"id": "1949525278281554174",
"shortcode": "BsOGulcndj-",
"dimensions": {
"height": 584,
"width": 584
},
"gating_info": null,
"fact_check_overall_rating": null,
"fact_check_information": null,
"sensitivity_friction_info": null,
"sharing_friction_info": {
"should_have_sharing_friction": false,
"bloks_app_url": null
},
"media_overlay_info": null,
"media_preview": null,
"display_url": "https://instagram.fbcn2-1.fna.fbcdn.net/v/t51.82787-15/625727639_18338153224242257_3827527793310630488_n.jpg?stp=dst-jpg_e15_tt6&_nc_ht=instagram.fbcn2-1.fna.fbcdn.net&_nc_cat=105&_nc_oc=Q6cZ2gHBlHY2RHKNTgCNzMelAyz56Toi4DI7VUNsrK7XJAsoGT6ka4w7PVJ6IEqS7PD9Ulw&_nc_ohc=jwkKyc7eqGAQ7kNvwHmuCEW&_nc_gid=BiA9YpCodvi1HtqMj6W-Vg&edm=AOmX9WgBAAAA&ccb=7-5&ig_cache_key=MTk0OTUyNTI3ODI4MTU1NDE3NA%3D%3D.3-ccb7-5&oh=00_AQONRzWv-s9IPALJK9qeJ5FVyMcHbwpYaGsJhb7fdlV1nA&oe=6ACE9A40&_nc_sid=bfaa47",
"display_resources": [
{
"src": "https://instagram.fbcn2-1.fna.fbcdn.net/v/t51.82787-15/625727639_18338153224242257_3827527793310630488_n.jpg?stp=dst-jpg_e35_s360x360_sh2.08_tt6&_nc_cat=104&_nc_map=urlgen_bucketless&ig_cache_key=MTk0OTUyNTI3ODI4MTU1NDE3NA%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=58cdad&efg=eyJ2ZW5jb2RlX3RhZyI6IkZFRUQueHBpZHMuNTg0LnNkci5yZWd1bGFyX3Bob3RvLkMzIn0%3D&_nc_ohc=53XaOqCZWBYQ7kNvwFfkQTV&_nc_oc=AdprbrBLkElSfmNNOrQHEYQuCIz8F8lIlYN7TENXKNGCcZVnybmvx0uXH6fzElyfwak&_nc_ad=z-m&_nc_cid=0&_nc_zt=23&_nc_ht=instagram.fbcn2-1.fna&_nc_gid=BiA9YpCodvi1HtqMj6W-Vg&_nc_ss=7a3ba&oh=00_AQNBRrpvxf3JGSktIaicSqaD4UtCuDo9I8feI6acpRs9Eg&oe=6ACE9A40",
"config_width": 360,
"config_height": 360
},
{
"src": "https://instagram.fbcn2-1.fna.fbcdn.net/v/t51.82787-15/625727639_18338153224242257_3827527793310630488_n.jpg?stp=dst-jpg_e35_tt6&_nc_cat=104&_nc_map=urlgen_bucketless&ig_cache_key=MTk0OTUyNTI3ODI4MTU1NDE3NA%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=58cdad&efg=eyJ2ZW5jb2RlX3RhZyI6IkZFRUQueHBpZHMuNTg0LnNkci5yZWd1bGFyX3Bob3RvLkMzIn0%3D&_nc_ohc=53XaOqCZWBYQ7kNvwFfkQTV&_nc_oc=AdprbrBLkElSfmNNOrQHEYQuCIz8F8lIlYN7TENXKNGCcZVnybmvx0uXH6fzElyfwak&_nc_ad=z-m&_nc_cid=0&_nc_zt=23&_nc_ht=instagram.fbcn2-1.fna&_nc_gid=BiA9YpCodvi1HtqMj6W-Vg&_nc_ss=7a3ba&oh=00_AQMhFQizLfIe4bAcskLHhT2nCDcjFGyldOq2Cp7IMLuVxg&oe=6ACE9A40",
"config_width": 584,
"config_height": 584
}
],
"accessibility_caption…
Key fields you’ll typically use:
- id and shortcode: stable identifiers for de-duplication and indexing.
- __typename: post type (e.g., GraphImage).
- dimensions.height and dimensions.width: render planning and responsive sizing.
- display_url: direct media URL for previews or processing.
- display_resources: alternative sizes; pick the closest to your target viewport.
Python example
This example calls Get Post Data with the exact URL and reads identifiers, dimensions, and media URL. Note: the link parameter must be URL-encoded. The code below uses the same encoded URL as the curl example.
import requests
API_URL = "https://zylalabs.com/api/855/instagram-data-api/630/get-post-data"
LINK_PARAM = "https%3A%2F%2Fwww.instagram.com%2Fp%2FBsOGulcndj-"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
resp = requests.get(f"{API_URL}?link={LINK_PARAM}", headers=HEADERS, timeout=30)
resp.raise_for_status()
data = resp.json()
# Extract fields commonly used in apps
post_id = data.get("id")
shortcode = data.get("shortcode")
typename = data.get("__typename")
dims = data.get("dimensions") or {}
height = dims.get("height")
width = dims.get("width")
display_url = data.get("display_url")
print({
"id": post_id,
"shortcode": shortcode,
"type": typename,
"height": height,
"width": width,
"display_url": display_url
})
Implementation notes that save time
- URL encoding: encode the link parameter when constructing the query. If you’re constructing URLs dynamically, prefer built-in URL encoders to avoid double-encoding.
- Caching: store post id and shortcode alongside the display_url to avoid refetching the same post repeatedly in list views.
- Media variants: pick a display_resources size close to your target dimensions to reduce client-side resizing.
- Error handling: if a post becomes unavailable or private, anticipate nulls or missing fields in your rendering pipeline.
Endpoint: Get Account Data (by username)
Fetch Instagram account data using a username. Useful for profile cards, link previews, and onboarding verifications.
- Method: GET
- URL: https://zylalabs.com/api/855/instagram-data-api/631/get-account-data
- Required query param:
- username (string): the Instagram handle, e.g., leomessi
curl example
Official sample response (truncated)
Fields to consider in UI:
- biography: show in profile header or hovercard.
- bio_links: render a verified list of external links; prefer url for direct navigation.
Endpoint: Get Reel Data (by shortcode)
Retrieve metrics for a public Instagram post or reel using its shortcode. Ideal for analytics tiles, ranking lists, and KPI monitoring.
- Method: GET
- URL: https://zylalabs.com/api/855/instagram-data-api/32007/get-reel-data
- Required query param:
- shortcode (string): for example, DctYV2qt6S5
curl example
Official sample response
Practical notes:
- Use video_view_count and play_count to drive engagement visualizations; if present together, keep both for parity with your historic datasets.
- code is the same value you passed as shortcode; store alongside your content key to avoid re-resolving it later.
Designing your integration
Minimal ingestion flow for post URLs
- Receive a public Instagram URL from a user or feed.
- Call Get Post Data with the URL-encoded link.
- Persist id, shortcode, dimensions, and display_url in your database.
- Render from display_resources where available to match your layout.
Resolving unknown shortcodes
If you have only a URL and need the shortcode for downstream analytics (e.g., to call Get Reel Data), first call Get Post Data. The response contains shortcode; store it so you can fetch metrics using Get Reel Data when needed.
Retries and timeouts
- Client timeouts: set a conservative timeout (e.g., 30s as shown) and retry idempotent GETs once if your app is latency-tolerant.
- Backoff: implement exponential backoff for transient network issues.
Security and production readiness
- Authorization: always send Authorization: Bearer YOUR_API_KEY over HTTPS.
- Key management: keep your key in a secrets manager or env variable. Do not ship it to the client.
- Quota: the API uses a subscription + quota model (not pay-per-call). Monitor usage in your Zyla dashboard and cache popular results to reduce repeat calls.
Calling this API from an AI agent (MCP)
You can call these same Hub endpoints from AI agents through Zyla’s Model Context Protocol endpoint. This works with MCP-compatible clients like Claude Code, Cursor, and Windsurf.
- MCP server endpoint: https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY
- Within your agent, configure the MCP server and authorize it with the same API key.
- From the agent’s tools, issue GET requests to the Hub URLs shown in this article with the required query parameters and the Authorization header.
For more about MCP usage, see: MCP.
Real-world use cases
- Moderation queue: when a user submits an Instagram link, call Get Post Data to fetch media and dimensions for a reviewer UI without manual screenshotting.
- Link unfurling: in chat or comments, detect Instagram URLs and enrich the preview with display_url and dimensions for crisp thumbnails.
- Creator dashboards: store shortcode per reel and periodically refresh Get Reel Data to update like_count, comment_count, and video_view_count tiles.
- Profile onboarding: on account connect, call Get Account Data by username to hydrate a profile card with biography and bio_links.
Troubleshooting checklist
- 401 Unauthorized: verify the Authorization header exactly as Authorization: Bearer YOUR_API_KEY.
- Empty or partial fields: ensure the link or shortcode is valid and public; private or removed content will not return complete data.
- Bad query parameter: confirm you used link for Get Post Data, username for Get Account Data, and shortcode for Get Reel Data, with proper URL encoding where applicable.
- Over-quota behavior: this API uses subscription + quota; check your dashboard and the API listing for current allocation and options.
End-to-end snippet: link in, preview out
Combine the link-to-post flow into a helper that you can drop into a backend route. This uses the same endpoint and parameters demonstrated above.
import os
import urllib.parse
import requests
API_KEY = os.getenv("ZYLA_API_KEY")
BASE_URL = "https://zylalabs.com/api/855/instagram-data-api/630/get-post-data"
def fetch_instagram_post(link: str):
params = {"link": urllib.parse.quote(link, safe="")}
url = f'{BASE_URL}?link={params["link"]}'
headers = {"Authorization": f"Bearer {API_KEY}"}
r = requests.get(url, headers=headers, timeout=30)
r.raise_for_status()
data = r.json()
return {
"id": data.get("id"),
"shortcode": data.get("shortcode"),
"type": data.get("__typename"),
"width": (data.get("dimensions") or {}).get("width"),
"height": (data.get("dimensions") or {}).get("height"),
"display_url": data.get("display_url"),
}
# Example usage:
# preview = fetch_instagram_post("https://www.instagram.com/p/BsOGulcndj-")
# print(preview)
FAQ
What authentication is required?
Send Authorization: Bearer YOUR_API_KEY with every request.
Do I need to derive a shortcode from the URL?
No. For Get Post Data, pass the full post URL in link. If you later need metrics that use a shortcode, read shortcode from the Get Post Data response and pass it to Get Reel Data.
Is there a free plan?
No free plan. The API uses a subscription + quota model. The listing offers a 7-day trial; check the API page for current access options and pricing.
Which fields should I cache?
Cache id, shortcode, dimensions, and display_url for posts; for reels, cache shortcode with like_count, comment_count, and video_view_count if you’re building analytics or trending lists.
Can I call the API from AI coding tools?
Yes. Use the MCP endpoint with your API key, and have the agent issue the same GET requests to the Hub URLs described here.
Ready to ship? Create your account, get an API key, and start your 7-day trial on the Instagram Data API here: Start 7-day trial on Instagram Data API. Explore more APIs anytime at Zyla API Hub.