jsonscraper

How to scrape IG using Python

A production-oriented walkthrough with endpoint map, caching strategy, and implementation examples.

Editorial Policy Report an error

This guide shows a production-first IG data workflow using the jsonscraper endpoint map, with real response samples and practical architecture choices.

For production workloads, the key benefit is endpoint depth plus cache_timeout support on important routes, which helps reduce duplicate calls and quota burn.

What you will build

  • Signed IG requests in Python with license_key auth.
  • Route-by-route validation from Postman collection to production script.
  • Cursor-safe pagination flow with explicit cache_timeout control.

Fast start in Postman

Start from the official IG collection, set license_key once, and run requests in a few clicks before writing code.

Step 1

Fork

Use IG or TikTok Postman collection as your workspace baseline.

Step 2

Set key

Configure license_key once in an environment variable.

Step 3

Automate

Export snippets or run AI-agent workflows on top of ready requests.

All API requests

Full endpoint map from the collection. Expand each class and click any route to inspect parameters and sample responses.

User Media Story Highlight Location Hashtag Search FB Search Audio (Music) Web API (GraphQL)
User (30 endpoints)
Media (18 endpoints)
Story (6 endpoints)
Highlight (3 endpoints)
Location (6 endpoints)
Hashtag (8 endpoints)
Search (11 endpoints)
FB Search (2 endpoints)
Audio (Music) (2 endpoints)
Web API (GraphQL) (11 endpoints)
View full endpoint list in Postman

Python examples from the collection

These examples use the same auth pattern as Postman: license_key in query params.

Example 1: get user by username (GET /v1/user/by/username)

import requests

BASE_URL = "https://ig.jsonscraper.com"
LICENSE_KEY = "YOUR_LICENSE_KEY"

params = {
    "license_key": LICENSE_KEY,
    "username": "apple",
    "cache_timeout": 0,
}

r = requests.get(f"{BASE_URL}/v1/user/by/username", params=params, timeout=30)
r.raise_for_status()
data = r.json()

print(data["status"], data["ig"]["username"], data["ig"]["pk"])
{
  "status": "ok",
  "limits_info": {"requests_count": 7098, "requests_limit": 2000300},
  "rate_limit_reached": false,
  "ig": {"pk": 5821462185, "username": "apple", "full_name": "apple"}
}

Example 2: get user stories by username (GET /v1/user/stories/by/username)

import requests

BASE_URL = "https://ig.jsonscraper.com"
LICENSE_KEY = "YOUR_LICENSE_KEY"

params = {
    "license_key": LICENSE_KEY,
    "username": "applemusic",
    "cache_timeout": 0,
}

r = requests.get(f"{BASE_URL}/v1/user/stories/by/username", params=params, timeout=30)
r.raise_for_status()
data = r.json()

stories = data.get("ig", [])
print("stories:", len(stories))

Python request pattern (license key + pagination)

Use one shared request helper so every endpoint call is signed consistently and pagination state is persisted.

import requests

BASE_URL = "https://ig.jsonscraper.com"
LICENSE_KEY = "YOUR_LICENSE_KEY"

def call(endpoint: str, **params):
    q = {"license_key": LICENSE_KEY, "cache_timeout": 0, **params}
    res = requests.get(f"{BASE_URL}{endpoint}", params=q, timeout=30)
    res.raise_for_status()
    return res.json()

page1 = call("/v1/user/medias/chunk", user_id="5821462185")
next_max_id = page1.get("next_max_id")
if next_max_id:
    page2 = call("/v1/user/medias/chunk", user_id="5821462185", max_id=next_max_id)

Implementation notes

  • Always include license_key in every request.
  • Use cache_timeout intentionally for recurring checks.
  • Persist cursor fields with query context.
  • Scale route coverage class-by-class after baseline validation.

Ready to launch your API workflow?

Pick an API, test endpoints in Postman, and launch your workflow in minutes.

People

No people listed for this article yet.

Keep readingHow to scrape TikTok using Python
Read the next article

Turn what you read into a working integration

Explore jsonscraper's social-data APIs, test requests and build your next workflow.

Explore APIs