API reference
Instagram API
Public profiles, followers, posts, reels, tagged posts, stories, single media, comments and replies, and search as JSON. No Instagram login needed.
| endpoint | Returns | Required |
|---|---|---|
| /user/by_username | Profile by username | username |
| /user/by_id | Profile by numeric ID | user_id |
| /user/quick_by_username | Same as /user/by_username | username |
| /medias/by_user_id | An account's posts | user_id |
| /reels/by_user_id | An account's reels | user_id |
| /medias/tagged_by_user_id | Posts the account is tagged in | user_id |
| /stories/by_username | An account's active stories | username |
| /followers/by_user_id | Accounts that follow a profile | user_id |
| /following/by_user_id | Accounts a profile follows | user_id |
| /media/by_shortcode | One post or reel | shortcode |
| /media/by_url | One post or reel | url |
| /comments/media_comments_by_id | Comments on a post | code_or_id_or_url |
| /comments/replies | Replies to a comment | code_or_id_or_url, comment_id |
| /search/users_by_keyword | Accounts | keyword |
| /search/hashtags_by_keyword | Hashtags | keyword |
| /search/places_by_keyword | Places | keyword |
| /search/global | Accounts, hashtags and places | keyword |
| /search/posts | Posts and reels | query |
| /media/shortcode_to_id | Media ID from a shortcode | shortcode |
| /media/id_to_shortcode | Shortcode from a media ID | id |
Response envelope
Successful calls return success, data, duration, statusCode and creditsUsed. Errors return success: false and an error message, for example Missing required parameter: username. An endpoint that isn't in this list fails with HTTP 500 and Failed to process Instagram request, and isn't charged.
Quick start
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/user/by_username", "params": {"username": "instagram"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/user/by_username", "params": {"username": "instagram"}, }, timeout=60, ) data = response.json() print(data["data"]["full_name"], data["data"]["follower_count"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/user/by_username", params: { username: "instagram" }, }), }); const data = await response.json(); console.log(data.data.full_name, data.data.follower_count);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/user/by_username", "params" => ["username" => "instagram"], ]), ]); $data = json_decode(curl_exec($ch), true); echo $data["data"]["full_name"], " ", $data["data"]["follower_count"], PHP_EOL;
Errors
{ "success": false, "error": "Missing required parameter: user_id" }
User profile
A public profile: bio, follower and following counts, verification, links and profile picture.
Parameters in params
- usernamestringFor
/user/by_username. With or without@. A profile URL works too, sent asusernameorurl. - user_idstringFor
/user/by_id: the numeric account ID (theidof a profile).
/user/by_id, or a numeric ID to /user/by_username? It's routed to the right lookup automatically. /user/quick_by_username is an alias of /user/by_username.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/user/by_username", "params": {"username": "instagram"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/user/by_username", "params": {"username": "instagram"}, }, timeout=60, ) data = response.json() print(data["data"]["follower_count"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/user/by_username", params: { username: "instagram" }, }), }); const data = await response.json(); console.log(data.data.follower_count);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/user/by_username", "params" => ["username" => "instagram"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["follower_count"]);
Response
{ "success": true, "data": { "id": "25025320", "username": "instagram", "full_name": "Instagram", "biography": "Discover what’s new on Instagram 🔎✨", "follower_count": 686587747, "following_count": 305, "is_verified": true, "is_private": false, "is_business": false, "external_url": "http://help.instagram.com", "profile_pic_url": "https://scontent-xxc1-1.cdninstagram.com/…", … }, "duration": "0.17", "statusCode": 200, "creditsUsed": 5 }
User posts
An account's posts, newest first, with captions, counts and media URLs.
Parameters in params
- user_idstringRequiredThe numeric account ID. Get it from User profile.
- countintegerDefault
12Posts per page, 1 to 50. Instagram decides the final page size. - end_cursorstringThe
page_info.end_cursorfrom the previous page.
page_info.end_cursor while page_info.has_next_page is true.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/medias/by_user_id", "params": {"user_id": "25025320", "count": 12} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/medias/by_user_id", "params": {"user_id": "25025320", "count": 12}, }, timeout=60, ) data = response.json() print(data["data"]["page_info"]["end_cursor"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/medias/by_user_id", params: { user_id: "25025320", count: 12 }, }), }); const data = await response.json(); console.log(data.data.page_info.end_cursor);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/medias/by_user_id", "params" => ["user_id" => "25025320", "count" => 12], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["page_info"]["end_cursor"]);
Response
{ "success": true, "data": { "count": 12, "edges": [ { "cursor": "3998430248382584993_25025320", "node": { "id": "3998430248382584993", "code": "Dd9RyBWBVih", "taken_at": 1790870385, "media_type": 2, "product_type": "clips", "is_video": true, "like_count": 466223, "comment_count": 6933, "caption": { "text": "DIY fish squishy 🐟 …" }, "display_url": "https://scontent-iad6-1.cdninstagram.com/…", … } }, … ], "page_info": { "end_cursor": "3993558187001191079_25025320", "has_next_page": true, … } }, "duration": "1.29", "statusCode": 200, "creditsUsed": 5 }
User reels
An account's reels with like and comment counts (play counts are often empty).
Parameters in params
- user_idstringRequiredThe numeric account ID.
- page_sizeintegerDefault
12Reels per page, 1 to 50.countis accepted too. - max_idstringThe
paging_info.max_idfrom the previous page.
paging_info.max_id while paging_info.more_available is true.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/reels/by_user_id", "params": {"user_id": "25025320", "page_size": 12} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/reels/by_user_id", "params": {"user_id": "25025320", "page_size": 12}, }, timeout=60, ) data = response.json() print(data["data"]["paging_info"]["more_available"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/reels/by_user_id", params: { user_id: "25025320", page_size: 12 }, }), }); const data = await response.json(); console.log(data.data.paging_info.more_available);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/reels/by_user_id", "params" => ["user_id" => "25025320", "page_size" => 12], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["paging_info"]["more_available"]);
Response
{ "success": true, "data": { "items": [ { "media": { "id": "3998430248382584993", "code": "Dd9RyBWBVih", "taken_at": 1790870385, "like_count": 466223, "comment_count": 6933, "caption": { "text": "DIY fish squishy 🐟 …" }, "video_versions": [ … ], … } }, … ], "paging_info": { "max_id": …, "more_available": true }, "status": "ok" }, "duration": "2.91", "statusCode": 200, "creditsUsed": 5 }
Tagged posts
Posts other accounts have tagged this account in.
Parameters in params
- user_idstringRequiredThe numeric account ID.
- countintegerDefault
12Up to 12 per page; larger values are rejected with400. Useend_cursorfor more. - end_cursorstringThe
page_info.end_cursorfrom the previous page.
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/medias/tagged_by_user_id", "params": {"user_id": "25025320", "count": 12} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/medias/tagged_by_user_id", "params": {"user_id": "25025320", "count": 12}, }, timeout=60, ) data = response.json() print(data["data"]["page_info"]["has_next_page"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/medias/tagged_by_user_id", params: { user_id: "25025320", count: 12 }, }), }); const data = await response.json(); console.log(data.data.page_info.has_next_page);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/medias/tagged_by_user_id", "params" => ["user_id" => "25025320", "count" => 12], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["page_info"]["has_next_page"]);
Response
{ "success": true, "data": { "edges": [ { "node": { … }, … }, … ], "page_info": { "end_cursor": "1248024676977729807", "has_next_page": true, … } }, "duration": "0.44", "statusCode": 200, "creditsUsed": 5 }
Stories
An account's active stories: image and video URLs, when each one was posted and when it expires.
Parameters in params
- usernamestringRequiredWith or without
@. A profile URL works too, sent asusernameorurl.
items list; that is still a successful call and costs 5 credits. Media URLs are signed and expire, so download what you need soon after the call.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/stories/by_username", "params": {"username": "nasa"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/stories/by_username", "params": {"username": "nasa"}, }, timeout=60, ) data = response.json() print(data["data"]["data"]["count"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/stories/by_username", params: { username: "nasa" }, }), }); const data = await response.json(); console.log(data.data.data.count);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/stories/by_username", "params" => ["username" => "nasa"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["data"]["count"]);
Response
{ "success": true, "data": { "data": { "additional_data": { "id": "528817151", "expiring_at": 1791060817, "user": { "username": "nasa", "full_name": "NASA", "is_verified": true, … }, … }, "count": 3, "items": [ { "id": "3999242754038286473", "code": "DeAKhiNAciJ", "media_type": 2, "taken_at": 1790966902, "expiring_at": 1791053302, "video_duration": 20.666, "image_versions": { "items": [ { "width": 640, "height": 1136, "url": "https://scontent-iad3-1.cdninstagram.com/…" }, … ] }, "video_versions": [ { "width": 720, "height": 1280, "url": "https://scontent-iad3-2.cdninstagram.com/…", … }, … ], … }, … ] } }, "duration": "3.05", "statusCode": 200, "creditsUsed": 5 }
media_type is 1 for a photo and 2 for a video. Photos have image_versions only; videos also have video_versions. additional_data describes the account.
Followers and following
The accounts that follow a profile, or that it follows. Use query to search the whole list by name.
Parameters in params
- user_idstringRequired
- querystringSearch the entire list by username or full name, for example to check whether one account follows another.
- max_idstringThe
next_max_idfrom the previous page.
next_max_id, sent back as max_id, while has_more is true. On /followers/by_user_id, user_count is the account's full follower count./followers/by_user_id returned "user_count": 104285158 with "page_size": 49 and "has_more": false. You can't page through such a list; use query to find a particular follower instead.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/following/by_user_id", "params": {"user_id": "528817151"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/following/by_user_id", "params": {"user_id": "528817151"}, }, timeout=60, ) data = response.json() print(data["data"]["users"][0]["username"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/following/by_user_id", params: { user_id: "528817151" }, }), }); const data = await response.json(); console.log(data.data.users[0].username);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/following/by_user_id", "params" => ["user_id" => "528817151"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["users"][0]["username"]);
Response
{ "success": true, "data": { "users": [ { "id": "461506226", "username": "chabotspace", "full_name": "Chabot Space & Science Center", "is_verified": false, "is_private": false, "profile_pic_url": "https://scontent-cph2-1.cdninstagram.com/…", … }, … ], "page_size": 17, "has_more": false, "status": "ok", … }, "duration": "1.14", "statusCode": 200, "creditsUsed": 5 }
The accounts NASA (user ID 528817151) follows: 17 in all, so a single page.
Post or reel
One post or reel: caption, counts, owner, image and video versions.
Parameters in params
- shortcodestringFor
/media/by_shortcode: the code ininstagram.com/p/shortcode/or/reel/shortcode/. - urlstringFor
/media/by_url: the full post or reel URL.
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/media/by_shortcode", "params": {"shortcode": "Dd9RyBWBVih"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/media/by_shortcode", "params": {"shortcode": "Dd9RyBWBVih"}, }, timeout=60, ) data = response.json() print(data["data"]["like_count"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/media/by_shortcode", params: { shortcode: "Dd9RyBWBVih" }, }), }); const data = await response.json(); console.log(data.data.like_count);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/media/by_shortcode", "params" => ["shortcode" => "Dd9RyBWBVih"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["like_count"]);
Response
{ "success": true, "data": { "id": "3998430248382584993", "code": "Dd9RyBWBVih", "media_type": 2, "product_type": "clips", "taken_at": 1790870385, "like_count": 466227, "comment_count": 6933, "caption": { "text": "DIY fish squishy 🐟 …", … }, "owner": { "id": "25025320", "username": "instagram", "is_verified": true, … }, "video_versions": [ { "width": 720, "height": 1280, "url": "https://scontent-iad6-1.cdninstagram.com/…", … }, … ], … }, "duration": "0.26", "statusCode": 200, "creditsUsed": 5 }
Comments
Comments on a post or reel.
Parameters in params
- code_or_id_or_urlstringRequiredA shortcode, a media ID or a post URL.
media_id,shortcodeorurlare accepted too. - pagination_tokenstringThe
pagination_tokenfrom the previous page, copied exactly.end_cursoris accepted too.
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/comments/media_comments_by_id", "params": {"code_or_id_or_url": "Dd9RyBWBVih"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/comments/media_comments_by_id", "params": {"code_or_id_or_url": "Dd9RyBWBVih"}, }, timeout=60, ) data = response.json() print(data["data"]["pagination_token"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/comments/media_comments_by_id", params: { code_or_id_or_url: "Dd9RyBWBVih" }, }), }); const data = await response.json(); console.log(data.data.pagination_token);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/comments/media_comments_by_id", "params" => ["code_or_id_or_url" => "Dd9RyBWBVih"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["pagination_token"]);
Response
{ "success": true, "data": { "data": { "items": [ { "id": "18109360262228610", "text": "No way instagram posted this", "created_at": 1790870561, "comment_like_count": 2364, "child_comment_count": 6, "user": { … }, … }, … ], "count": 15, "total": 6933, … }, "pagination_token": "D01NBBoTERtIfVFDaQpAE0QeVx9ZQF0fXitCNVtX…" }, "duration": "1.78", "statusCode": 200, "creditsUsed": 5 }
Comment replies
The replies to one comment on a post or reel.
Parameters in params
- code_or_id_or_urlstringRequiredThe post: a shortcode, a media ID or a post URL.
shortcode,media_idorurlare accepted too. - comment_idstringRequired
data.data.items and the parent comment is in data.data.additional_data. total is the number of replies; each call returns one page of them.Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/comments/replies", "params": { "code_or_id_or_url": "DdHyaYAifb6", "comment_id": "17932824945379446" } }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/comments/replies", "params": { "code_or_id_or_url": "DdHyaYAifb6", "comment_id": "17932824945379446", }, }, timeout=60, ) data = response.json() print(data["data"]["data"]["total"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/comments/replies", params: { code_or_id_or_url: "DdHyaYAifb6", comment_id: "17932824945379446", }, }), }); const data = await response.json(); console.log(data.data.data.total);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/comments/replies", "params" => [ "code_or_id_or_url" => "DdHyaYAifb6", "comment_id" => "17932824945379446", ], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["data"]["total"]);
Response
{ "success": true, "data": { "data": { "additional_data": { "id": "17932824945379446", "text": "The future of space looks so good on them 🚀✨…", "comment_like_count": 59, "user": { "username": "space.girl.ma", … }, … }, "count": 8, "items": [ { "id": "18146868499554664", "text": "@space.girl.ma 👏🪐", "comment_like_count": 3, "created_at": 1789138884, "parent_comment_id": "17932824945379446", "user": { "username": "cern_theory", "is_verified": true, … }, … }, … ], "total": 9 }, "pagination_token": null }, "duration": "0.71", "statusCode": 200, "creditsUsed": 5 }
Search
Accounts, hashtags or places matching a keyword.
Parameters in params
- keywordstringRequiredWhat to search for.
queryis accepted too.
| endpoint | Returned in data |
|---|---|
| /search/users_by_keyword | status, query, users |
| /search/hashtags_by_keyword | status, query, hashtags |
| /search/places_by_keyword | status, query, places |
| /search/global | all three lists |
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/search/users_by_keyword", "params": {"keyword": "nike"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/search/users_by_keyword", "params": {"keyword": "nike"}, }, timeout=60, ) data = response.json() print(data["data"]["users"][0]["user"]["username"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/search/users_by_keyword", params: { keyword: "nike" }, }), }); const data = await response.json(); console.log(data.data.users[0].user.username);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/search/users_by_keyword", "params" => ["keyword" => "nike"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["users"][0]["user"]["username"]);
Response
{ "success": true, "data": { "status": "ok", "query": "nike", "users": [ { "position": 0, "user": { "id": "13460080", "username": "nike", "full_name": "Nike", "is_verified": true, "profile_pic_url": "https://scontent-iad6-1.cdninstagram.com/…", … } }, … ] }, "duration": "0.33", "statusCode": 200, "creditsUsed": 5 }
Hashtag results look like {"position": 2, "hashtag": {"id": "17841562978125529", "name": "nikewomen", "media_count": 2031404}}.
Search posts
Posts and reels matching a keyword, with caption, author, like, comment and play counts, and media URLs.
Parameters in params
- querystringRequiredWhat to search for.
keywordis accepted too.
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/search/posts", "params": {"query": "espresso"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/search/posts", "params": {"query": "espresso"}, }, timeout=60, ) data = response.json() print(data["data"]["data"]["items"][0]["code"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/search/posts", params: { query: "espresso" }, }), }); const data = await response.json(); console.log(data.data.data.items[0].code);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/search/posts", "params" => ["query" => "espresso"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["data"]["items"][0]["code"]);
Response
{ "success": true, "data": { "data": { "count": 9, "items": [ { "id": "3964258599302207450", "code": "DcD4DFJMhfa", "media_type": 2, "product_type": "clips", "taken_at": 1786796775, "like_count": 258472, "comment_count": 1903, "play_count": 8345369, "caption": { "text": "POV : Every morning i wake up to make coffee ☕️ …", … }, "user": { "id": "64231005527", "username": "alfy.coffee", "full_name": "Alfy's Coffee ☕️", "is_verified": true, "follower_count": 225040, … }, "image_versions": { … }, "video_versions": [ … ], … }, … ] }, … }, "duration": "0.61", "statusCode": 200, "creditsUsed": 5 }
Each item has the same fields as Post or reel. Use its code with the comment endpoints.
Shortcode and ID
Convert between a post's shortcode and its numeric media ID. The answer is computed instantly and costs the usual 5 credits.
Parameters in params
- shortcodestringFor
/media/shortcode_to_id. Returns{"id": "…"}. - idstringFor
/media/id_to_shortcode. Returns{"shortcode": "…"}.
Request
curl -X POST "https://scrapingbot.io/api/v1/instagram" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/media/shortcode_to_id", "params": {"shortcode": "Dd9RyBWBVih"} }'
import requests response = requests.post( "https://scrapingbot.io/api/v1/instagram", headers={"x-api-key": "YOUR_API_KEY"}, json={ "endpoint": "/media/shortcode_to_id", "params": {"shortcode": "Dd9RyBWBVih"}, }, timeout=60, ) data = response.json() print(data["data"]["id"])
const response = await fetch("https://scrapingbot.io/api/v1/instagram", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ endpoint: "/media/shortcode_to_id", params: { shortcode: "Dd9RyBWBVih" }, }), }); const data = await response.json(); console.log(data.data.id);
<?php $ch = curl_init("https://scrapingbot.io/api/v1/instagram"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "x-api-key: YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "endpoint" => "/media/shortcode_to_id", "params" => ["shortcode" => "Dd9RyBWBVih"], ]), ]); $data = json_decode(curl_exec($ch), true); print_r($data["data"]["id"]);
Response
{ "success": true, "data": { "id": "3998430248382584993" }, "duration": "0.01", "statusCode": 200, "creditsUsed": 5 }
Stuck on something?
Try requests in the dashboard playgrounds, check every call in your usage log, or write to [email protected]. A real developer answers.