Skip to main content

instagram-hindsight

PyPI Python License: MIT GitHub

$ pip install instagram-hindsight

$ instagram-hindsight profile

instagram-hindsight scrapes public Instagram profiles using a guest web session — no Instagram login required.

  • fetches public profile metadata (followers, bio, verification, …),
  • paginates posts via Instagram’s web GraphQL timeline,
  • paginates reels via the clips API,
  • normalizes likes, comments, views, captions, and permalinks,
  • optionally routes traffic through a proxy,
  • on HTTP 401/403 during pagination, opens a new guest session and retries the same page.
instagram-hindsight [--max-pages N] [--posts-only | --reels-only]
                    [--proxy PROXY_URL] [-o OUTPUT.json]
                    profile

Install

From PyPI:

pip install instagram-hindsight

From a local checkout:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Requires Python 3.9+.


Command-line usage

Scrape a public profile (profile JSON, posts, and reels):

instagram-hindsight instagram

Limit pagination depth (each “page” is typically ~12 items):

instagram-hindsight instagram --max-pages 5

Posts only or reels only:

instagram-hindsight nasa --posts-only
instagram-hindsight nasa --reels-only

Use a proxy (or set PROXY_URL):

instagram-hindsight instagram --proxy "http://user:pass@host:port"

Proxy tips

Free / shared datacenter proxies almost always get HTTP 429 (Too Many Requests) on Instagram’s guest endpoints — even when a guest session cookie is obtained successfully. For reliable scrapes, use rotating residential proxies.

Proxy type Typical result
None (direct) Works for light use; rate-limits quickly
Free / shared datacenter Session may open; profile/media calls return 429
Rotating residential Best reliability for pagination and retries

You can also pass a pool to the Python client (proxy_pool=[...]); on auth failures the client opens a new guest session and may pick another proxy from the pool.

Write to a specific file:

instagram-hindsight instagram -o out.json --max-pages 2

Equivalent module form:

python -m instagram_hindsight instagram --max-pages 2 -v

Python API

One-shot helper:

from instagram_hindsight import scrape_account

data = scrape_account("instagram", max_pages=2)
print(data["profile"]["followers_count"])
print(len(data["posts"]), len(data["reels"]))

Reusable client:

from instagram_hindsight import InstagramGuestClient

client = InstagramGuestClient(
    proxy="http://user:pass@host:port",  # optional
    max_pages=10,
    delay=1.0,
)
data = client.scrape_account("nasa", include_posts=True, include_reels=True)

Lower-level building blocks are also exported:

from instagram_hindsight import (
    get_guest_session,
    fetch_profile,
    fetch_all_media,
    fetch_reels_only,
)

Return shape

{
  "profile": {
    "username": "...",
    "user_id": "...",
    "followers_count": 0,
    "following_count": 0,
    "posts_count": 0,
    "biography": "...",
    "is_private": False,
    "is_verified": False,
    # ...
  },
  "posts": [
    {
      "id": "...",
      "shortcode": "...",
      "type": "image" | "carousel" | "video",
      "likes": 0,
      "comments": 0,
      "views": None,
      "caption": "...",
      "link": "https://www.instagram.com/p/...",
      "date": "2026-01-01T00:00:00+00:00",
    },
    # ...
  ],
  "reels": [
    {
      "id": "...",
      "shortcode": "...",
      "type": "reel",
      "likes": 0,
      "comments": 0,
      "views": 0,
      "shares": 0,
      "link": "https://www.instagram.com/reel/...",
      # ...
    },
    # ...
  ],
}

How it works

instagram-hindsight does not use the official Meta Graph API and does not require --login.

It opens an anonymous guest session against Instagram’s website, then calls public web endpoints:

Data Endpoint
Profile /api/v1/users/web_profile_info/
Posts /graphql/query/ (timeline media)
Reels /api/v1/clips/user/

Sessions are short-lived cookie jars (csrftoken + guest headers). They are not persisted to disk. If a page returns 401/403, a new guest session is created and that page is retried (with or without a proxy).

Private profiles are not supported.


Contributing

This is an open-source project. Issues and pull requests that improve reliability, docs, or packaging are welcome.

Suggested local setup:

pip install -e ".[dev]"
python -m instagram_hindsight instagram --max-pages 1 -v
python -m build

Disclaimer

instagram-hindsight is in no way affiliated with, authorized, maintained, or endorsed by Instagram, Meta Platforms, Inc., or any of their affiliates or subsidiaries. This is an independent and unofficial project. Use at your own risk.

Automated access to Instagram may violate Instagram’s Terms of Use. You are solely responsible for how you use this software and for complying with applicable laws and third-party terms.

instagram-hindsight is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for instagram-hindsight 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for instagram-hindsight 0.1.1
File Size Uploaded
instagram_hindsight-0.1.1.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for instagram-hindsight 0.1.1
File Interpreter ABI Platform
instagram_hindsight-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / instagram_hindsight-0.1.1.tar.gz

Download URL instagram_hindsight-0.1.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3d51458115cd47ae87d1fd400a69a09af9cc39bbea1704bbdc83c62807295928
BLAKE2b-256 checksum
How to use checksums
e90e3d03ef959cd8250f15de4bc868285e08353ec9de2b60231b1db0829b0a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / instagram_hindsight-0.1.1-py3-none-any.whl

Download URL instagram_hindsight-0.1.1-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfb00f799c89f9164cacd63b006ea3e2d137c72065c57d619b770a9fc2145365
BLAKE2b-256 checksum
How to use checksums
b67c4a565b2316eab68fd16756d37d40d7d032374cfd3bc1d710f93881fef8b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page