Skip to content

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.

POST/api/v1/instagramJSON body: {"endpoint", "params"}5 credits per request
Only successful calls are chargedTimes out after 45 seconds
endpointReturnsRequired
/user/by_usernameProfile by usernameusername
/user/by_idProfile by numeric IDuser_id
/user/quick_by_usernameSame as /user/by_usernameusername
/medias/by_user_idAn account's postsuser_id
/reels/by_user_idAn account's reelsuser_id
/medias/tagged_by_user_idPosts the account is tagged inuser_id
/stories/by_usernameAn account's active storiesusername
/followers/by_user_idAccounts that follow a profileuser_id
/following/by_user_idAccounts a profile followsuser_id
/media/by_shortcodeOne post or reelshortcode
/media/by_urlOne post or reelurl
/comments/media_comments_by_idComments on a postcode_or_id_or_url
/comments/repliesReplies to a commentcode_or_id_or_url, comment_id
/search/users_by_keywordAccountskeyword
/search/hashtags_by_keywordHashtagskeyword
/search/places_by_keywordPlaceskeyword
/search/globalAccounts, hashtags and placeskeyword
/search/postsPosts and reelsquery
/media/shortcode_to_idMedia ID from a shortcodeshortcode
/media/id_to_shortcodeShortcode from a media IDid

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.

POST/api/v1/instagramendpoints "/user/by_username", "/user/by_id"5 credits

Parameters in params

  • usernamestring
    For /user/by_username. With or without @. A profile URL works too, sent as username or url.
  • user_idstring
    For /user/by_id: the numeric account ID (the id of a profile).
Sent a username to /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

200 OK
{
  "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.

POST/api/v1/instagramendpoint "/medias/by_user_id"5 credits

Parameters in params

  • user_idstringRequired
    The numeric account ID. Get it from User profile.
  • countintegerDefault 12
    Posts per page, 1 to 50. Instagram decides the final page size.
  • end_cursorstring
    The page_info.end_cursor from the previous page.
Keep paging with 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

200 OK
{
  "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).

POST/api/v1/instagramendpoint "/reels/by_user_id"5 credits

Parameters in params

  • user_idstringRequired
    The numeric account ID.
  • page_sizeintegerDefault 12
    Reels per page, 1 to 50. count is accepted too.
  • max_idstring
    The paging_info.max_id from the previous page.
Keep paging with 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

200 OK
{
  "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.

POST/api/v1/instagramendpoint "/medias/tagged_by_user_id"5 credits

Parameters in params

  • user_idstringRequired
    The numeric account ID.
  • countintegerDefault 12
    Up to 12 per page; larger values are rejected with 400. Use end_cursor for more.
  • end_cursorstring
    The page_info.end_cursor from 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

200 OK
{
  "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.

POST/api/v1/instagramendpoint "/stories/by_username"5 credits

Parameters in params

  • usernamestringRequired
    With or without @. A profile URL works too, sent as username or url.
Stories disappear after 24 hours, so this returns only what is live right now. An account with no active story returns an empty 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

200 OK
{
  "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.

POST/api/v1/instagramendpoints "/followers/by_user_id", "/following/by_user_id"5 credits

Parameters in params

  • user_idstringRequired
    The numeric account ID: the id from User profile. A username is rejected with 400.
  • querystring
    Search the entire list by username or full name, for example to check whether one account follows another.
  • max_idstring
    The next_max_id from the previous page.
Keep paging with 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.
Very large accounts show only recent followers. For accounts with a very large audience, Instagram lists only about 50 recent followers and offers no further pages. For NASA, /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

200 OK
{
  "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.

POST/api/v1/instagramendpoints "/media/by_shortcode", "/media/by_url"5 credits

Parameters in params

  • shortcodestring
    For /media/by_shortcode: the code in instagram.com/p/shortcode/ or /reel/shortcode/.
  • urlstring
    For /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

200 OK
{
  "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.

POST/api/v1/instagramendpoint "/comments/media_comments_by_id"5 credits

Parameters in params

  • code_or_id_or_urlstringRequired
    A shortcode, a media ID or a post URL. media_id, shortcode or url are accepted too.
  • pagination_tokenstring
    The pagination_token from the previous page, copied exactly. end_cursor is 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

200 OK
{
  "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.

POST/api/v1/instagramendpoint "/comments/replies"5 credits

Parameters in params

  • code_or_id_or_urlstringRequired
    The post: a shortcode, a media ID or a post URL. shortcode, media_id or url are accepted too.
  • comment_idstringRequired
    The parent comment's id from Comments. Comments with replies have child_comment_count above 0.
Replies are in 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

200 OK
{
  "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 posts

Posts and reels matching a keyword, with caption, author, like, comment and play counts, and media URLs.

POST/api/v1/instagramendpoint "/search/posts"5 credits

Parameters in params

  • querystringRequired
    What to search for. keyword is accepted too.
Each call returns one page of results (9 in our test). There is no paging parameter.

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

200 OK
{
  "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.

POST/api/v1/instagramendpoints "/media/shortcode_to_id", "/media/id_to_shortcode"5 credits

Parameters in params

  • shortcodestring
    For /media/shortcode_to_id. Returns {"id": "…"}.
  • idstring
    For /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

200 OK
{
  "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.