# SocialGrid — Instagram Scraper (`fulinlabs/socialgrid-instagram-scraper`) Actor

Unified-schema Instagram profile data via a residential proxy AND an authenticated session (Instagram requires both — logged-out GraphQL queries are rejected regardless of IP, see PLAN.md). Reduced-surface MVP: profile only; posts/comments/search/trending are deferred.

- **URL**: https://apify.com/fulinlabs/socialgrid-instagram-scraper.md
- **Developed by:** [Giovanni](https://apify.com/fulinlabs) (community)
- **Categories:** Social media
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## SocialGrid — Instagram Scraper

> **Unofficial community Actor.** Not affiliated with, endorsed by, or sponsored by Instagram or Meta.

Unified-schema Instagram profile data — flat, agent-ready JSON extracted via a real Playwright browser session, never a raw GraphQL response dump. Requires both a residential proxy and an authenticated Instagram session (see Input below) — Instagram rejects logged-out profile queries outright, regardless of IP or browser fingerprint.

### Why this vs. a raw-blob scraper

Instagram's `web_profile_info`/GraphQL response is a deeply nested internal object (`edge_followed_by`, `hd_profile_pic_url_info`, dozens of feature flags) built for Instagram's own web client, not for downstream consumption. This actor extracts the same `Author` shape used across SocialGrid's YouTube/TikTok/Instagram scrapers, so an LLM agent or analytics pipeline can treat every platform identically. Fields Instagram doesn't expose (e.g. `total_likes` — Instagram has no such aggregate) come back as `null`, never `0`.

### What it does — and honestly, what it doesn't (yet)

**Implemented and live-verified:**

| Mode | Description | Key input |
|---|---|---|
| `profile` | Account profile: display name, bio, avatar, follower/following/post counts, verified, private flag, external links | `handle` |

**Explicitly NOT implemented in this MVP** — `posts`, `comments`, `search`, and `trending` are deferred, not attempted this pass. This actor is single-purpose (profile lookup) for now.

### Why authentication is required (not just a proxy)

Modern Instagram no longer server-renders profile data into the page HTML at all — it's a client-side-only app shell. The real data lives behind an internal GraphQL/`web_profile_info` endpoint that returns `"Unauthorized logged out query."` for any request without a real, logged-in session — independent of proxy quality or browser fingerprint. There is no unauthenticated path to this data anymore.

**This actor never automates Instagram's login form** — that flow is far more bot-defended than viewing profiles and risks the account. Instead, you provide three cookies from your own real, manual browser login:

1. Log in to instagram.com normally, in a real browser.
2. Open DevTools → Application/Storage → Cookies → `https://www.instagram.com`.
3. Copy the values of `sessionid`, `ds_user_id`, and `csrftoken`.
4. Pass them as `igSessionId`, `igDsUserId`, `igCsrfToken` in the actor input (marked as secret fields — they're never logged or echoed).

These cookies belong to a real Instagram account, so treat them like any other credential: expect them to expire or be invalidated by Instagram at any time (password change, suspicious-activity flag, manual logout elsewhere), at which point the actor starts failing with the same "Unauthorized logged out query" error and the cookies need refreshing from a fresh manual login.

### Example output (`mode: "profile"`)

```json
{
  "success": true,
  "platform": "instagram",
  "mode": "profile",
  "data": {
    "platform": "instagram",
    "id": "25025320",
    "handle": "instagram",
    "display_name": "Instagram",
    "bio": "Discover what's new on Instagram 🔎✨",
    "avatar_url": "https://scontent...cdninstagram.com/...",
    "verified": true,
    "followers": 685839159,
    "following": 256,
    "post_count": 8522,
    "total_likes": null,
    "external_links": [
      "https://www.youtube.com/watch?v=H6G9PcvHjj4",
      "https://open.spotify.com/episode/..."
    ],
    "is_private": false
  }
}
````

### Input

- `mode` (required): `profile` — the only implemented mode
- `handle` (required for `profile`): account handle (`instagram`) or full profile URL
- `proxyGroup` (default `RESIDENTIAL`): Apify proxy group — Instagram requires a residential proxy to work at all
- `igSessionId`, `igDsUserId`, `igCsrfToken` (all required, secret): cookies from a real, human-completed login — see above

### Usage

#### Apify CLI

```bash
apify actors call fulinlabs/socialgrid-instagram-scraper \
  --input '{"mode": "profile", "handle": "instagram", "igSessionId": "...", "igDsUserId": "...", "igCsrfToken": "..."}'
```

#### REST API

```bash
curl "https://api.apify.com/v2/acts/fulinlabs~socialgrid-instagram-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode": "profile", "handle": "instagram", "igSessionId": "...", "igDsUserId": "...", "igCsrfToken": "..."}'
```

### Pricing

Benchmarked against comparable Store Instagram profile scrapers (Apify's official Instagram Profile Scraper at ~$1.60–2.60/1,000 profiles, third-party alternatives from $0.50–$20/1,000). Because this actor runs a full headless-Chromium session per call (heavier compute than a plain HTTP scraper) and depends on a maintained authenticated session, pricing sits at the higher end of that band:

- `profile`: **$2.00 per 1,000 results**

### Reliability & known risks

- **Standing operational dependency:** the Instagram account behind the session cookies is real and subject to Meta's ban/challenge risk for automation-adjacent activity. Session expiry requires a human to manually re-log-in and refresh the cookies — this is not a one-time setup cost.
- Runs on Apify's official `apify/actor-node-playwright-chrome:22` base image with a real Chromium browser — slower and more resource-intensive per call than a plain HTTP-based scraper.
- A 6-hour canary schedule re-runs the live test suite (`getProfile` against a known fixture + a nonexistent-handle error case) and alerts on failure.

# Actor input Schema

## `mode` (type: `string`):

Which operation to run. Only profile is implemented in this MVP — see description.

## `handle` (type: `string`):

e.g. 'instagram' or a full profile URL. Required for mode=profile.

## `proxyGroup` (type: `string`):

Instagram requires a residential proxy for this actor to work at all.

## `igSessionId` (type: `string`):

From a real, human-completed login — see PLAN.md for how to obtain it. Required; automating the login form itself is not supported (heavily bot-defended, risks the account).

## `igDsUserId` (type: `string`):

From the same real, human-completed login session as igSessionId.

## `igCsrfToken` (type: `string`):

From the same real, human-completed login session as igSessionId.

## Actor input object example

```json
{
  "mode": "profile",
  "proxyGroup": "RESIDENTIAL"
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items containing the requested Instagram profile result wrapper, including success state, data, or an error.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("fulinlabs/socialgrid-instagram-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("fulinlabs/socialgrid-instagram-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call fulinlabs/socialgrid-instagram-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=fulinlabs/socialgrid-instagram-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "SocialGrid — Instagram Scraper",
        "description": "Unified-schema Instagram profile data via a residential proxy AND an authenticated session (Instagram requires both — logged-out GraphQL queries are rejected regardless of IP, see PLAN.md). Reduced-surface MVP: profile only; posts/comments/search/trending are deferred.",
        "version": "0.1",
        "x-build-id": "1r6Vw7BFKnmp7BdGx"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/fulinlabs~socialgrid-instagram-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-fulinlabs-socialgrid-instagram-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/fulinlabs~socialgrid-instagram-scraper/runs": {
            "post": {
                "operationId": "runs-sync-fulinlabs-socialgrid-instagram-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/fulinlabs~socialgrid-instagram-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-fulinlabs-socialgrid-instagram-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "mode",
                    "igSessionId",
                    "igDsUserId",
                    "igCsrfToken"
                ],
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "profile"
                        ],
                        "type": "string",
                        "description": "Which operation to run. Only profile is implemented in this MVP — see description.",
                        "default": "profile"
                    },
                    "handle": {
                        "title": "Account handle or profile URL",
                        "type": "string",
                        "description": "e.g. 'instagram' or a full profile URL. Required for mode=profile."
                    },
                    "proxyGroup": {
                        "title": "Apify proxy group",
                        "type": "string",
                        "description": "Instagram requires a residential proxy for this actor to work at all.",
                        "default": "RESIDENTIAL"
                    },
                    "igSessionId": {
                        "title": "Instagram sessionid cookie",
                        "type": "string",
                        "description": "From a real, human-completed login — see PLAN.md for how to obtain it. Required; automating the login form itself is not supported (heavily bot-defended, risks the account)."
                    },
                    "igDsUserId": {
                        "title": "Instagram ds_user_id cookie",
                        "type": "string",
                        "description": "From the same real, human-completed login session as igSessionId."
                    },
                    "igCsrfToken": {
                        "title": "Instagram csrftoken cookie",
                        "type": "string",
                        "description": "From the same real, human-completed login session as igSessionId."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
