# Instagram Followers And Following Scrapper (`scrapemesh/instagram-followers-and-following-scrapper`) Actor

📈 Instagram Followers & Following Scrapper extracts public follower/following data fast and accurately. 🚀 Great for market research, influencer discovery, lead generation & audience insights. 🔍 Automate growth with smarter targeting! #Instagram #DataScraping

- **URL**: https://apify.com/scrapemesh/instagram-followers-and-following-scrapper.md
- **Developed by:** [ScrapeMesh](https://apify.com/scrapemesh) (community)
- **Categories:** Social media, Lead generation, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.md):

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

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.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/platform/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

## Instagram Followers and Following Scraper

A robust Apify Actor for scraping **followers** or **following** lists from Instagram profiles. Supports bulk processing with intelligent proxy fallback and real-time data saving.

### Why Choose Us?

- **Dual Mode**: Choose between scraping followers or following lists
- **Bulk Processing**: Process multiple Instagram profiles in a single run
- **Intelligent Proxy Management**: Automatic fallback from no proxy → datacenter → residential proxies
- **Live Data Saving**: Results saved incrementally to prevent data loss
- **Comprehensive Error Handling**: Robust retry logic with exponential backoff
- **Detailed Logging**: Real-time progress updates and status information

### Key Features

- ✅ **Dual Mode Support**: Scrape followers OR following lists
- ✅ **Multiple Profile Support**: Process multiple Instagram profiles simultaneously
- ✅ **Proxy Fallback**: Automatic fallback from no proxy → datacenter → residential (with 3 retries)
- ✅ **Live Saving**: Data saved immediately as it's scraped
- ✅ **Retry Logic**: Up to 3 retry attempts with exponential backoff
- ✅ **Rich Metadata**: Extract comprehensive user information
- ✅ **Enhanced Followers Mode**: For followers mode, also extracts users from posts and comments

### Input

#### JSON Example

```json
{
  "scrapeMode": "followers",
  "startUrls": [
    {"url": "https://www.instagram.com/cristiano/"},
    {"url": "https://www.instagram.com/nike/"}
  ],
  "maxData": 1000,
  "sessionId": "your_session_id_here",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
````

#### Input Fields

- **scrapeMode** (required, string): Choose what to scrape
  - `"followers"` - Scrape followers of the profiles
  - `"following"` - Scrape accounts that the profiles are following
  - Default: `"followers"`

- **startUrls** (required, array): List of Instagram profile URLs or usernames
  - Example: `[{"url": "https://www.instagram.com/username/"}]` or `[{"url": "username"}]`

- **maxData** (optional, integer): Maximum number of items to collect per profile
  - Default: `100`
  - Range: 0-100000
  - `0` = unlimited (collect until pagination ends)

- **sessionId** (optional, string): Your Instagram session ID cookie value
  - Recommended for better success rates
  - Get this from your browser's cookies when logged into Instagram

- **proxyConfiguration** (optional, object): Proxy configuration settings
  - **useApifyProxy** (boolean): Enable Apify proxy
    - Default: `false` (no proxy)
    - If enabled, uses datacenter proxy with automatic fallback to residential

### Output

#### JSON Example

```json
[
  {
    "pk": "73320179592",
    "pk_id": "73320179592",
    "id": "73320179592",
    "username": "davabukandaffa5",
    "full_name": "arizki",
    "profile_pic_url": "https://instagram.fjsr11-1.fna.fbcdn.net/...",
    "is_verified": false,
    "is_private": true,
    "followed_by": "cristiano",
    "success": true
  }
]
```

#### Output Fields

- **pk**: Primary key (user ID)
- **pk\_id**: Primary key ID
- **id**: User ID
- **username**: Instagram username
- **full\_name**: Full name
- **profile\_pic\_url**: Profile picture URL
- **is\_verified**: Whether the account is verified
- **is\_private**: Whether the account is private
- **followed\_by**: The profile these users belong to
- **success**: Whether the data was successfully collected

### 🚀 How to Use the Actor (via Apify Console)

1. Log in at https://console.apify.com and go to *Actors*.
2. Find your actor (instagram-followers-and-following-scrapper) and click it.
3. Configure inputs:
   - **Select scrape mode**: Choose "followers" or "following"
   - Add Instagram profile URLs or usernames
   - Set maximum items per profile
   - Enter your Instagram session ID (recommended)
   - Configure proxy settings if needed
4. Run the actor.
5. Monitor logs in real time.
6. Access results in the OUTPUT tab.
7. Export results to JSON or CSV.

### Best Use Cases

- **Social Media Analytics**: Analyze follower/following demographics and engagement
- **Influencer Research**: Identify followers or following of specific accounts
- **Market Research**: Understand audience composition
- **Competitor Analysis**: Study competitor follower/following bases
- **Network Analysis**: Map social connections and relationships

### Frequently Asked Questions

**Q: What's the difference between followers and following mode?**\
A: Followers mode scrapes who follows the target profiles. Following mode scrapes who the target profiles follow.

**Q: Do I need a session ID?**\
A: It's optional but strongly recommended for better success rates and to avoid blocks.

**Q: How do I get my session ID?**\
A: Log into Instagram in your browser, open developer tools, go to Cookies, and copy the `sessionid` value.

**Q: What happens if Instagram blocks my requests?**\
A: The actor automatically falls back to datacenter proxy, then residential proxy with 3 retries.

**Q: Can I scrape private accounts?**\
A: No, only public accounts can be scraped. Private account data is not accessible.

**Q: Is there a rate limit?**\
A: The actor includes built-in delays and retry logic to respect Instagram's rate limits.

**Q: Does followers mode really get more data?**\
A: Yes! In followers mode, the actor also extracts users from posts and comments, providing more comprehensive results.

### Support and Feedback

For issues, questions, or feature requests, please contact the development team at dev.scraperengine@gmail.com.

### Cautions

- Data is collected only from *publicly available sources*.
- No data is taken from private accounts or password-protected content.
- The end user is responsible for ensuring legal compliance (spam laws, privacy, data protection, etc.).
- Respect Instagram's Terms of Service and rate limits.

# Actor input Schema

## `startUrls` (type: `array`):

📋 List of Instagram profile URLs or usernames to scrape.

💡 Examples:
• https://www.instagram.com/cristiano/
• https://www.instagram.com/nike/
• cristiano
• nike

✨ You can add multiple profiles to scrape in one run!

## `scrapeMode` (type: `string`):

Choose what to scrape:
• followers - Scrape followers of the profiles
• following - Scrape accounts that the profiles are following

## `maxData` (type: `integer`):

🎯 Set the maximum number of items to collect per profile.

📈 Range: 0-100,000 items
💡 Default: 100 items (recommended for faster results)

⚡ Tip: Lower values = faster scraping, Higher values = more comprehensive results

Note: 0 = unlimited (collect until pagination ends)

## `sessionId` (type: `string`):

🔐 Optional but strongly recommended for better success rates.

📝 How to get your Session ID:

1. Log into Instagram in your browser
2. Open Developer Tools (F12 or Right-click → Inspect)
3. Go to Application/Storage → Cookies → https://www.instagram.com
4. Find and copy the 'sessionid' value

💡 Example format: 80339464000%3AMwlUEdZkdshtFG%3A5%3AAYiJEi32U\_OOJkvXyc232wBhDZz1Q4zQOFhTFSTy3g

⚠️ Note: Without a session ID, the scraper may have limited access and lower success rates.

## `proxyConfiguration` (type: `object`):

🛡️ Configure proxy settings for enhanced reliability and bypassing restrictions.

🔄 Smart Fallback System:
1️⃣ No proxy (default) - Direct connection
2️⃣ Datacenter proxy - If configured
3️⃣ Residential proxy - Automatic fallback if blocked

✅ The actor automatically switches to residential proxy if requests are blocked (with 3 retries).

💡 Recommended: Enable proxy for better success rates!

## Actor input object example

```json
{
  "startUrls": [
    "https://www.instagram.com/cristiano/"
  ],
  "scrapeMode": "followers",
  "maxData": 100,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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 = {
    "startUrls": [
        "https://www.instagram.com/cristiano/"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemesh/instagram-followers-and-following-scrapper").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 = {
    "startUrls": ["https://www.instagram.com/cristiano/"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("scrapemesh/instagram-followers-and-following-scrapper").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 '{
  "startUrls": [
    "https://www.instagram.com/cristiano/"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call scrapemesh/instagram-followers-and-following-scrapper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapemesh/instagram-followers-and-following-scrapper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Followers And Following Scrapper",
        "description": "📈 Instagram Followers & Following Scrapper extracts public follower/following data fast and accurately. 🚀 Great for market research, influencer discovery, lead generation & audience insights. 🔍 Automate growth with smarter targeting! #Instagram #DataScraping",
        "version": "0.1",
        "x-build-id": "SnZfAhQfXXW6qIbSW"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapemesh~instagram-followers-and-following-scrapper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapemesh-instagram-followers-and-following-scrapper",
                "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/scrapemesh~instagram-followers-and-following-scrapper/runs": {
            "post": {
                "operationId": "runs-sync-scrapemesh-instagram-followers-and-following-scrapper",
                "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/scrapemesh~instagram-followers-and-following-scrapper/run-sync": {
            "post": {
                "operationId": "run-sync-scrapemesh-instagram-followers-and-following-scrapper",
                "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": [
                    "scrapeMode",
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "📋 Instagram Profile URLs or Usernames",
                        "type": "array",
                        "description": "📋 List of Instagram profile URLs or usernames to scrape.\n\n💡 Examples:\n• https://www.instagram.com/cristiano/\n• https://www.instagram.com/nike/\n• cristiano\n• nike\n\n✨ You can add multiple profiles to scrape in one run!",
                        "items": {
                            "type": "string"
                        }
                    },
                    "scrapeMode": {
                        "title": "🎯 Scrape Mode",
                        "enum": [
                            "followers",
                            "following"
                        ],
                        "type": "string",
                        "description": "Choose what to scrape:\n• followers - Scrape followers of the profiles\n• following - Scrape accounts that the profiles are following",
                        "default": "followers"
                    },
                    "maxData": {
                        "title": "📊 Maximum Items per Profile",
                        "minimum": 0,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "🎯 Set the maximum number of items to collect per profile.\n\n📈 Range: 0-100,000 items\n💡 Default: 100 items (recommended for faster results)\n\n⚡ Tip: Lower values = faster scraping, Higher values = more comprehensive results\n\nNote: 0 = unlimited (collect until pagination ends)",
                        "default": 100
                    },
                    "sessionId": {
                        "title": "🍪 Instagram sessionid (recommended)",
                        "type": "string",
                        "description": "🔐 Optional but strongly recommended for better success rates.\n\n📝 How to get your Session ID:\n1. Log into Instagram in your browser\n2. Open Developer Tools (F12 or Right-click → Inspect)\n3. Go to Application/Storage → Cookies → https://www.instagram.com\n4. Find and copy the 'sessionid' value\n\n💡 Example format: 80339464000%3AMwlUEdZkdshtFG%3A5%3AAYiJEi32U_OOJkvXyc232wBhDZz1Q4zQOFhTFSTy3g\n\n⚠️ Note: Without a session ID, the scraper may have limited access and lower success rates."
                    },
                    "proxyConfiguration": {
                        "title": "🔒 Proxy Configuration",
                        "type": "object",
                        "description": "🛡️ Configure proxy settings for enhanced reliability and bypassing restrictions.\n\n🔄 Smart Fallback System:\n1️⃣ No proxy (default) - Direct connection\n2️⃣ Datacenter proxy - If configured\n3️⃣ Residential proxy - Automatic fallback if blocked\n\n✅ The actor automatically switches to residential proxy if requests are blocked (with 3 retries).\n\n💡 Recommended: Enable proxy for better success rates!"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
