Instagram Scraper for Claude (and Any AI Assistant)

Published · 18 min read

Instagram Scraper for Claude (and Any AI Assistant)

An Instagram scraper for Claude is a read-only data tool the model can call. It is not code that runs inside the model. There are two portable ways to add one. The first is an MCP server, which works in Claude Desktop, Claude Code, Cursor, and other MCP clients without any code. The second is a tool-use (function-calling) definition in your own app. SocialLens supports both. It reads public Instagram profiles, posts, and comments with one API key and never logs in.

Key facts

This page is the Instagram-specific guide in our social media data for AI agents series.

The three ways to get Instagram data into an AI agent

Claude cannot browse Instagram reliably by itself. Most of Instagram's interface needs JavaScript to render, it pushes logged-out visitors toward a login wall, and it rate-limits anonymous traffic aggressively. To get dependable public data, you hand the model a tool. That tool can come from three places.

Official APIs (Instagram Graph API)

Meta's Instagram Platform is the authoritative, terms-compliant source. It is designed for accounts you own or manage. You need a Business or Creator account, a Meta app, access tokens, and often app review.

You can look up other accounts through Business Discovery, but only other Business or Creator accounts, and only a limited set of fields.

Self-run scrapers (headless browsers, actor platforms)

You can run a headless browser or rent a prebuilt "actor" on a platform such as Apify, or use proxy and dataset infrastructure from Bright Data. These approaches can reach almost any public page and handle very large volumes.

The trade-off is maintenance. Instagram changes its markup and its anti-bot defenses often. When it does, selectors break, proxies get blocked, and your agent gets empty fields with no error. If you write the scraper yourself, all of that upkeep is yours.

Read-only data API with an MCP server (SocialLens)

A managed data API absorbs the breakage. You call one stable endpoint and get structured JSON. SocialLens adds two things on top:

The trade-off is that you depend on a vendor. SocialLens also covers fewer sites than a general-purpose scraping platform: 17 networks, not "the whole web."

Can Claude scrape Instagram by itself? Not reliably. Claude has no persistent browser session, and Instagram blocks most anonymous automated traffic. Give Claude a tool instead. An MCP server such as sociallens-mcp, or a function-calling tool that hits a read-only Instagram API, returns structured public data that the model can reason over and cite.

What a social media MCP server is and how it works

The Model Context Protocol is an open standard for exposing tools to AI clients. You write a server once, and every compliant client can discover its tools, read their input schemas, and call them.

The sociallens-mcp server is a small local process that the client launches over stdio. It translates tool calls into HTTPS requests to the SocialLens API.

 You: "How many followers does @nasa have, exactly?"
   |
   v
+------------------+     tool call (JSON-RPC over stdio)    +---------------------+
|  AI agent        | -------------------------------------> | sociallens-mcp      |
|  (Claude, etc.)  |                                        | (local process,     |
|  via MCP client  | <------------------------------------- |  holds your API key)|
+------------------+     structured JSON result             +----------+----------+
                                                                       |
                                                                       | HTTPS + Bearer key
                                                                       v
                                                            +---------------------+
                                                            | api.sociallens.dev  |
                                                            +----------+----------+
                                                                       |
 ===================== READ-ONLY BOUNDARY: public data only, no login, no sessions ====
                                                                       |
                                                                       v
                                              Public profiles, posts, comments on 17 networks
                                              (Instagram, TikTok, YouTube, X, Reddit, ...)

Your API key stays in the server's environment. The model never sees it, and it never appears in a prompt. For a deeper look at how MCP servers for social data compare, see the best social media MCP server.

What can the AI read, and what can it not read

The agent CAN read The agent CANNOT read
Public Instagram profiles: followers, following, bio, verified status, category, external link Private accounts' posts, followers, or comments
Public posts: caption, publish time, likes, views, comments, shares Direct messages, in any form
Public comments on public posts, with author, likes, and reply counts Anything behind a login, including Stories viewer lists and Close Friends content
Counts with the is_exact flag (precise vs. rounded) Logged-in sessions. SocialLens never logs in as you or anyone else
The same fields on 16 other networks with one key Private insights such as reach, impressions, and saves (use the Graph API on your own account)

If an account is private, the profile read returns "private": true, and posts and comments stay unavailable. This is a design boundary, not a bug.

Comparison: Instagram data options for AI agents

Third-party details change often. Where we could not verify a claim, the table says so. Check each vendor's own documentation and pricing as of late 2026.

Approach / vendor Networks covered Auth complexity Data precision Read or publish Cost model MCP server
Instagram Graph API (official) Instagram only (Meta has separate APIs for its other apps) High: Meta app, Business/Creator account, tokens, often app review Platform-native for your own accounts; limited fields for others Read and publish (own accounts) Free, rate-limited No official one
Apify Very broad, through community and official actors Medium: platform account plus per-actor inputs Varies by actor; no standard exactness flag Read (scraping) Usage-based compute plus per-result actor pricing Yes, an official MCP server for actors
Bright Data Very broad: scraper APIs, datasets, proxies Medium Varies by product Read Per-record and subscription tiers Yes, offers one
EnsembleData Several major social networks Low: API token No exactness flag documented, as far as we know Read Unit-based plans Not verified
HikerAPI Instagram-focused Low: API key No exactness flag documented, as far as we know Read Per-request Not verified
Phyllo Many, through creator-consented account connections High: each creator must connect their account Platform-native for connected accounts Read, scoped by consent Contract or subscription Not verified
RapidAPI (marketplace) Depends on the individual provider Low to medium: one marketplace key, but provider-specific endpoints Varies by provider Read Per-provider subscription tiers Varies
Modash Major creator networks, with an influencer-discovery focus Low: web app, API on higher plans Analytics estimates plus public counts Read Subscription Not verified
HypeAuditor Major creator networks, with an influencer-audit focus Low: web app, API on request Analytics estimates, audience-quality scores Read Subscription Not verified
Data365 Several social networks Low: API key No exactness flag documented, as far as we know Read Subscription Not verified
SocialLens 17 networks, one key Low: one sk_live_ key Exact counts flagged with is_exact Read-only Pay-per-use Yes, open source (sociallens-mcp)

Where SocialLens loses:

Where SocialLens wins:

Connect SocialLens to your AI agent

Before you start

  1. Install Node.js 18 or newer. Check with node --version.
  2. Get a free API key at /register. Keys start with sk_live_.
  3. Put the key in a config file or an environment variable, never in a prompt or a chat message.

Claude Desktop

  1. Open Settings → Developer → Edit Config. This opens claude_desktop_config.json, which lives at ~/Library/Application Support/Claude/ on macOS and %APPDATA%\Claude\ on Windows.
  2. Paste this block. If the file already has mcpServers, merge sociallens into it instead of adding a second mcpServers key.
{
  "mcpServers": {
    "sociallens": {
      "command": "npx",
      "args": ["-y", "sociallens-mcp"],
      "env": {
        "SOCIALLENS_API_KEY": "sk_live_YOUR_KEY"
      }
    }
  }
}
  1. Replace sk_live_YOUR_KEY with your real key.
  2. Quit Claude Desktop completely and reopen it. Closing the window is not enough.
  3. Ask: "Get the Instagram profile for nasa and tell me if the follower count is exact."

The official MCP quickstart for Claude Desktop users covers the config file in more detail.

Claude Code

Run this one command in your terminal:

claude mcp add --env SOCIALLENS_API_KEY=sk_live_YOUR_KEY --transport stdio sociallens -- npx -y sociallens-mcp

If you would rather run the Python server from the same package:

claude mcp add --env SOCIALLENS_API_KEY=sk_live_YOUR_KEY --transport stdio sociallens -- python /absolute/path/to/sociallens-mcp/server.py

Confirm it is connected with claude mcp list, or run /mcp inside a session. Server scopes and management commands are documented in Claude Code's MCP docs. For more Claude-specific workflows, see connecting Claude to social media data.

Cursor

  1. Create or open ~/.cursor/mcp.json for a global setup, or .cursor/mcp.json inside a project.
  2. Paste the same JSON block shown in the Claude Desktop section, character for character.
  3. Open Cursor Settings → MCP and confirm that sociallens shows a green status with its tools listed.
  4. In Agent mode, ask Cursor to pull a profile.

Any other MCP client

The config block above is the same for every client that supports local stdio MCP servers, and that portability is the point of MCP. Agent frameworks that include an MCP client adapter take the same three values: the command npx, the args -y sociallens-mcp, and the env variable SOCIALLENS_API_KEY. Plug those in and the framework discovers the tools automatically.

ChatGPT and other remote-only clients

Some assistants, including ChatGPT's connector feature, accept only remote MCP servers over HTTP and cannot launch a local stdio process. You have two options:

Your own app (Claude API tool use)

When you control the code, define one tool and let the model decide when to call it. This example uses the official Anthropic SDK.

# pip install anthropic requests
# export ANTHROPIC_API_KEY=...   export SOCIALLENS_API_KEY=sk_live_YOUR_KEY
import json
import os

import anthropic
import requests

client = anthropic.Anthropic()
SOCIALLENS_KEY = os.environ["SOCIALLENS_API_KEY"]

tools = [{
    "name": "get_instagram_profile",
    "description": "Read a PUBLIC Instagram profile (read-only). Returns followers, "
                   "following, verified, bio, and is_exact (true = precise count).",
    "input_schema": {
        "type": "object",
        "properties": {
            "username": {"type": "string", "description": "Instagram handle without @"}
        },
        "required": ["username"],
    },
}]


def get_instagram_profile(username: str) -> dict:
    r = requests.get(
        "https://api.sociallens.dev/v1/profile",
        params={"platform": "instagram", "username": username},
        headers={"Authorization": f"Bearer {SOCIALLENS_KEY}"},
        timeout=30,
    )
    r.raise_for_status()
    return r.json()


messages = [{"role": "user",
             "content": "How many Instagram followers does nasa have? Is that exact?"}]

while True:
    response = client.messages.create(
        model="claude-sonnet-5-5",
        max_tokens=4096,
        thinking={"type": "adaptive"},
        tools=tools,
        messages=messages,
    )
    if response.stop_reason != "tool_use":
        break
    messages.append({"role": "assistant", "content": response.content})
    results = []
    for block in response.content:
        if block.type == "tool_use":
            data = get_instagram_profile(**block.input)
            results.append({"type": "tool_result", "tool_use_id": block.id,
                            "content": json.dumps(data)})
    messages.append({"role": "user", "content": results})

print("".join(b.text for b in response.content if b.type == "text"))

The tool is a plain HTTP call, so you can register the same get_instagram_profile schema with any other function-calling assistant. Only the SDK wrapper changes.

A real live read: Instagram @nasa

Here is the raw request. It works in any language and from any model's tool call.

curl -s "https://api.sociallens.dev/v1/profile?platform=instagram&username=nasa" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

This is the response from the live read on 2026-12-04, trimmed to the fields discussed here:

{
  "exists": true,
  "username": "nasa",
  "verified": true,
  "private": false,
  "followers": 104241747,
  "is_exact": true,
  "following": 91,
  "fetched_at": "2026-12-04T…"
}

The full payload also includes nickname, likes, videos, bio, avatar, id, category, external_link, cached, and source. Three fields deserve attention:

Same schema, different network

To read another network, change one parameter:

curl -s "https://api.sociallens.dev/v1/profile?platform=tiktok&username=nasa" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

The TikTok response uses the same field names: followers, is_exact, following, verified, fetched_at, and the rest. An agent that has learned to read one network's response can read all 17 without new parsing logic. That consistency is the practical advantage of one schema over a different scraper output for each site.

Pulling posts

curl -s "https://api.sociallens.dev/v1/profile-posts?platform=instagram&username=nasa&limit=12" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

The response returns exists, username, platform, count, has_more, next_cursor, and fetched_at, plus a posts[] array. Each post carries id, url, caption, published_at, likes, views, comments, shares, and likes_hidden.

When a creator hides like counts, likes_hidden is true. Your agent should report the count as unavailable rather than treating it as zero.

Pulling comments on a real NASA post

curl -s -G "https://api.sociallens.dev/v1/post-comments" \
  --data-urlencode "platform=instagram" \
  --data-urlencode "url=https://www.instagram.com/p/Df-NlR0PjmN/" \
  --data-urlencode "limit=20" \
  -H "Authorization: Bearer sk_live_YOUR_KEY"

The response has this shape (types shown, not live values):

{
  exists: bool, url: string, platform: "instagram",
  count: int, total: int, has_more: bool, next_cursor: string|null, fetched_at: string,
  comments: [
    { id, text, author: { username, name, verified }, likes, replies, published_at }
  ]
}

To paginate, pass next_cursor back as cursor= until has_more is false. total is the comment count the platform reports, and count is how many comments came back in this page.

Original data: what rounding hides on Instagram

Most dashboards abbreviate large counts, and so does the Instagram app itself. The table shows how much each common display convention distorts the exact figures SocialLens returned.

Account Exact followers (is_exact: true) Shown as "XM" (truncated) Hidden by truncation Shown as "X.XM" Hidden at one decimal Shown as nearest "XM" (rounded) Error when rounded
@nasa 104241747 104M 241,747 (0.23%) 104.2M 41,747 (0.04%) 104M 241,747 under
@cristiano 679519176 679M 519,176 (0.08%) 679.5M 19,176 (0.003%) 680M 480,824 over

Data last verified: 2026-12-04

Methodology: both profiles were read live through /v1/profile on 2026-12-04. The abbreviated columns apply standard truncation and rounding to those exact integers.

The @cristiano row shows why the flag matters. Depending on whether a tool truncates or rounds, the same account appears as 679M or 680M. Those two labels are 1,000,000 followers apart, and neither one is the real number.

Two derived figures from the same @nasa read: about 1,145,513.7 followers per account followed (104241747 ÷ 91), and about 20,691.1 followers per post (104241747 ÷ 5038). @cristiano has about 6.52 times as many followers as @nasa.

These numbers are dated. SocialLens also exposes a no-key live lookup for AI crawlers, so an assistant reading this page can fetch a current Instagram figure itself instead of repeating ours. Humans can do the same with the free tool pages.

What data you can pull

Capability Instagram Notes across the 17 networks
Profile (/v1/profile) Yes Available across the network set; identical schema
Profile posts (/v1/profile-posts) Yes Paginated with has_more and next_cursor
Post by URL Yes Fetch one public post directly
Post comments (/v1/post-comments) Yes Public comments only, with author and reply counts
Followers / following listing No TikTok only
Keyword search Varies Availability depends on the network
Video transcript Varies For video posts, where the platform supports it
Audience demographics Varies Aggregated, public-signal based

The 17 networks are TikTok, Instagram, YouTube, Facebook, X, Reddit, LinkedIn, Threads, Pinterest, Telegram, Bluesky, Truth Social, Cosmos, SoundCloud, Kwai, GitHub, and Spotify. Coverage differs by endpoint, so check the docs before you build a workflow around one capability on one network.

Typical agent tasks this enables:

What it costs and how pricing models differ

Five pricing models dominate this market, and the right one depends on your call pattern more than on the headline price.

Model How it bills Good for Watch out for
Pay-per-use Per successful request or record Agents with bursty, unpredictable calls High volume can exceed a flat plan
Units Each endpoint costs a set number of units from a plan Predictable pipelines Expensive endpoints drain units fast
Credits / compute Billed on compute time plus results (actor platforms) Large batch scrapes Cost depends on page complexity and retries
Per-request tiers Monthly quota of calls Steady, known volume Overage fees, or hard stops mid-month
Subscription seats Flat monthly fee for an app plus API Marketing teams using dashboards Paying for UI you may not use from an agent

How the vendors map, stated qualitatively as of late 2026 (check each pricing page):

SocialLens is pay-per-use, with one key and one price sheet across all 17 networks. You can start free at /register.

Agents tend to make many small, irregular calls, and pay-per-use matches that pattern well. If you plan to pull millions of Instagram records a month in a fixed batch, a bulk dataset vendor may be cheaper, and you should price both.

Is scraping public Instagram data legal? In the US, reading publicly accessible data without logging in is generally not "unauthorized access" under the CFAA, following hiQ v. LinkedIn. Contract claims, platform terms, and privacy laws such as GDPR and CCPA still apply. Read-only, public-only tools reduce risk but do not remove it. This is not legal advice.

The fuller picture:

This is not legal advice. Talk to counsel before you build a commercial dataset.

Troubleshooting

The server does not appear in Claude Desktop. The cause is almost always malformed JSON. Common culprits are a trailing comma, smart quotes pasted from a document, or two mcpServers keys in one file. Validate the file with python -m json.tool claude_desktop_config.json. Then check the logs at ~/Library/Logs/Claude/mcp*.log on macOS, which name the failing server.

You edited the config and nothing changed. Claude Desktop reads its config only at launch. Quit from the menu bar or system tray, not just the window, then reopen. Cursor sometimes needs a toggle off and on in its MCP settings, or a window reload.

Error: spawn npx ENOENT or "command not found." Desktop apps launched from the Dock or Start menu often do not inherit your shell's PATH. This is especially common with Node version managers. Run which npx (or where npx on Windows) in your terminal and use that absolute path as command. Also confirm node --version is 18 or newer.

Relative paths fail with the Python server. The client launches the process from its own working directory, so ./server.py resolves to the wrong place. Always use an absolute path, as in /absolute/path/to/sociallens-mcp/server.py.

The tool runs but returns 401. The API key is missing or wrong. Check three things:

Run claude mcp list to see whether the server is healthy.

Remote MCP servers return 401 or 403. Remote HTTP servers often use OAuth. A 401 usually means you never completed the sign-in. A 403 usually means the token lacks a scope or has expired. In Claude Code, run /mcp to authenticate or re-authenticate. This applies to remote servers only. sociallens-mcp runs locally, so it uses your API key, not OAuth.

Your client only supports remote servers. Clients that cannot spawn stdio processes need sociallens-mcp exposed through an HTTP bridge. The alternative is the tool-use path, which needs no MCP at all.

Cursor uses the wrong configuration. Cursor reads both the global ~/.cursor/mcp.json and the project-level .cursor/mcp.json. If you define sociallens in both with different keys, you can get confusing results depending on which workspace is open. Keep a single definition, usually the global one, and remove duplicates.

Counts look stale. Check fetched_at and cached in the response. A cached response is recent but not live to the second. If you need the freshest figure, re-query.

An account returns empty posts. Check private and exists first. Private accounts and deleted handles return no posts, and that is the expected behavior.

FAQ

What is the best Instagram scraper for Claude? The best option is a read-only tool Claude can call, not a scraper running inside the model. SocialLens provides an MCP server (npx -y sociallens-mcp) and an HTTP endpoint that return public Instagram profiles, posts, and comments, with exact counts flagged by is_exact.

Does this work with assistants other than Claude? Yes. The MCP server works in Cursor and any MCP client with the same config block. For your own app, the get_instagram_profile tool is a plain HTTP call, so any function-calling model can use it.

Can it read private Instagram accounts or DMs? No. SocialLens is read-only and public-data-only. It never logs in, stores no sessions, and cannot read private accounts, DMs, or anything behind a login. A private profile returns "private": true and no posts.

Does Claude see my API key? No. The key lives in the MCP config env block or in an environment variable read by your code. The model receives tool results, never credentials. Never paste a key into a prompt.

What does is_exact mean? It indicates whether a count is a precise integer (true) or a rounded figure the platform exposes (false). @nasa returned 104241747 followers with is_exact: true on 2026-12-04.

Can I download a list of an account's Instagram followers? Not with SocialLens. Follower and following listings are available for TikTok only. For Instagram, you get the follower count, public posts, and public comments.

Do I need to write code? No. With Claude Desktop, Claude Code, or Cursor, paste the config or run one command, then ask questions in plain language. Code is only needed if you are building your own app with tool use.

What are the requirements? Node.js 18 or newer for the npx server, or Python if you use the Python server. You also need a SocialLens API key starting with sk_live_. The server runs locally and talks to api.sociallens.dev over HTTPS.

Is scraping public Instagram data legal? Reading public data without logging in is generally not a CFAA violation in the US after hiQ v. LinkedIn. Platform terms, GDPR, and CCPA still apply to how you store and use the data. This is not legal advice.

How fresh is the data? Every response includes fetched_at, and the cached field shows whether it was served from a recent cache. The figures on this page were read live on 2026-12-04.

Can the same key read TikTok, YouTube, or X? Yes. One key covers 17 networks with the same schema. Change platform=instagram to another network and the field names stay the same.

Can the agent post or comment on Instagram for me? No. SocialLens cannot publish, like, follow, or message. For publishing to your own accounts, use the official Instagram Platform APIs.

Run these requests yourself

Every example on this page is a real call to the SocialLens API. A new account starts with 250 free reads, no card needed, and a read that fails is never charged.

Keep reading