# Instagram Following Scraper & Suggested Similar Accounts (`scrapebase/instagram-following-scraper`) Actor

📸 Instagram Following Scraper & Suggested Similar Accounts extracts public following lists—usernames, names, bios, profile URLs & IDs—with filters, pagination & CSV/JSON export. 🔎 Ideal for influencer research, competitor analysis, lead gen & growth campaigns. ⚖️ Public data only.

- **URL**: https://apify.com/scrapebase/instagram-following-scraper.md
- **Developed by:** [ScrapeBase](https://apify.com/scrapebase) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 19 total users, 0 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/actors/running/actors-in-store.md#pay-per-event

## 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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Following Scraper & Suggested Similar Accounts

An Apify Actor that scrapes the **Instagram following list** of one or more public profiles — and, for each
followed account, also pulls the **suggested / similar accounts** Instagram itself offers for it. Built for
influencer-marketing and partnerships research: instead of only cataloguing who a profile already follows,
you also get the accounts Instagram's own recommender puts next to each one, so you can find the next
creators to approach instead of only the ones already taken.

### What it scrapes

1. **Following list** — every account a given Instagram profile follows (`GET
   /api/v1/friendships/{user_id}/following/`), paginated, pushed to the dataset live as it's collected.
2. **Suggested / similar accounts** (optional, on by default) — for each followed account, Instagram's own
   "Suggested for you / Similar accounts" list (`GET /api/v1/discover/chaining/?target_id={pk}`), attached
   to that row as `suggested_accounts`.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `urls` | array (required) | prefill `["https://www.instagram.com/mrbeast/"]` | Full profile URLs, `@handle`, or bare `handle`. Any number of profiles for a bulk run. |
| `maxItems` | integer | `10` | Max accounts to collect **per profile** from the following list. `0` = no cap. |
| `sessionId` | string | — | Your Instagram `sessionid` cookie. The following list (and the suggested-accounts call) return HTTP 401 without it — effectively required even though the field is marked optional. |
| `proxyConfiguration` | object | `{"useApifyProxy": false}` | Optional Apify Proxy settings. The actor falls back direct → datacenter → residential automatically when Instagram pushes back. |
| `includeSuggestedAccounts` | boolean | `true` | For every followed account collected, also fetch Instagram's suggested/similar accounts for it. Costs one extra request per followed row. |
| `maxSuggestedPerAccount` | integer | `10` | How many suggested accounts to keep per followed account. `0` = keep everything Instagram returns (Instagram typically hands back roughly 30–80 per account in one response, with no further pages). |
| `hideAlreadyFollowedSuggestions` | boolean | `true` | Drop any suggested account that the profile already follows (compared against the following list collected in the same run only — nothing is stored between runs). |

Example input:

```json
{
  "urls": ["https://www.instagram.com/nasa/"],
  "maxItems": 10,
  "sessionId": "YOUR_SESSIONID_COOKIE_VALUE",
  "proxyConfiguration": { "useApifyProxy": false },
  "includeSuggestedAccounts": true,
  "maxSuggestedPerAccount": 10,
  "hideAlreadyFollowedSuggestions": true
}
```

### Output

Each dataset item is one followed account, with the base 17 fields plus `suggested_accounts`:

```jsonc
{
  "pk": "19511341806",
  "pk_id": "19511341806",
  "id": "19511341806",
  "full_name": "Jonny Kim",
  "is_private": false,
  "fbid_v2": "17841419614188917",
  "third_party_downloads_enabled": 1,
  "strong_id__": "19511341806",
  "profile_pic_id": "3600032490686429836_19511341806",
  "profile_pic_url": "https://instagram.f<cdn-node>.fna.fbcdn.net/v/t51.2885-19/...",
  "is_verified": true,
  "username": "jonnykimusa",
  "has_anonymous_profile_picture": false,
  "account_badges": [],
  "latest_reel_media": 0,
  "is_favorite": false,
  "followed_by": "nasa",

  "suggested_accounts": [
    {
      "pk": "1506607755",
      "pk_id": "1506607755",
      "id": "1506607755",
      "strong_id__": "1506607755",
      "username": "leonardodicaprio",
      "full_name": "Leonardo DiCaprio",
      "is_private": false,
      "is_verified": true,
      "profile_pic_id": "..._1506607755",
      "profile_pic_url": "https://instagram.f<cdn-node>.fna.fbcdn.net/v/t51.2885-19/...",
      "social_context": "Leonardo DiCaprio",
      "chaining_info": { "sources": "", "algorithm": null }
    }
  ]
}
```

`suggested_accounts` is only present on the row when `includeSuggestedAccounts` is `true`. It is an empty
array `[]` when Instagram doesn't offer suggestions for that particular account, or when every suggestion
was filtered out by `hideAlreadyFollowedSuggestions` — never a fabricated value.

### How it works

1. Resolves each seed profile's numeric user id from its logged-out profile HTML.
2. Pages the `following/` API (12 accounts per request) and pushes each row to the dataset immediately.
3. If `includeSuggestedAccounts` is on, calls `discover/chaining/?target_id={pk}` for the account just
   collected, drops any suggestion that's the seed profile itself or (optionally) already followed by the
   seed, keeps up to `maxSuggestedPerAccount`, and attaches the result to that same row before pushing.
4. Falls back automatically from a direct connection to an Apify datacenter proxy, then to a sticky
   residential proxy, if Instagram starts rejecting requests.

### Notes / honest limits

- The actor scrapes only **publicly available** data reachable through Instagram's own web API with a
  logged-in session cookie you provide.
- Suggested accounts are offered by Instagram for **most, not necessarily every**, followed account —
  accounts Instagram doesn't consider eligible come back with an empty `suggested_accounts` list, logged as
  such, and never fail the run.
- Neither the following list nor the suggested-accounts list has a documented stable order between
  identical calls — treat both as "N of the list", not "the top/most-recent N".
- `chaining_info` and `social_context` are passed through exactly as Instagram returns them; on the accounts
  measured during development, `chaining_info` came back empty and `social_context` often matched the
  account's own display name, so neither should be relied on as a distinct label.
- The end user is responsible for compliance with applicable laws and platform rules.

# Actor input Schema

## `urls` (type: `array`):

✅ Full profile links work great
✅ Plain `@handle` or `handle` works too
✅ Add as many as you need for a **bulk** run

💜 *Example:* `https://www.instagram.com/mrbeast/`

## `maxItems` (type: `integer`):

🔢 **Limit** how many accounts to collect **for each** profile in your list.

✨ `0` = **no cap** (keep going until the list ends)
🧪 Not sure? Start with **100–500** and adjust next time

⏱️ Bigger numbers = longer runs — plan accordingly!

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

📌 **Strongly recommended**

🧭 Copy the `sessionid` value from your Instagram cookies in the browser where you’re already logged in, and paste it here.

🙈 It stays private to your run — never share it publicly.

💤 You *can* leave this empty, but runs may be less reliable.

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

🎛️ **Default:** run without a special proxy (simple & direct).

🔧 Need Apify Proxy? Toggle it here and pick the options that match your plan.

✨ The actor adapts automatically when the platform is picky — you’ll see friendly notes in the log.

## `includeSuggestedAccounts` (type: `boolean`):

✨ For **every account** the profile follows, also pull the accounts Instagram suggests as similar to it — the same "Suggested for you / Similar accounts" list Instagram shows on a profile.

🎯 This is what turns a list of accounts they already follow into a list of accounts to approach next.

⏱️ Costs one extra request per followed account, so keep an eye on **Max following count** above.

ℹ️ Some accounts are not eligible for suggestions; those rows come back with an empty list.

## `maxSuggestedPerAccount` (type: `integer`):

📦 How many suggested accounts to keep for **each** followed account.

✨ `0` = keep every suggestion Instagram returns
🧪 Instagram hands back roughly **30–80** per account in a single response and offers no "next page", so this simply slices the top of that list

💡 Leave it at **10** for a fast, readable run; raise it when you want the full neighbourhood.

## `hideAlreadyFollowedSuggestions` (type: `boolean`):

🆕 Drop any suggested account that the profile **already follows**, so what is left is genuinely new names to approach.

🔍 The comparison is made against the following list collected **in this same run** — nothing is stored between runs and no previous run is read.

📊 Measured on a real profile, about **a third** of the head of the suggestion list was already being followed, so this filter does real work.

## Actor input object example

```json
{
  "urls": [
    "https://www.instagram.com/mrbeast/"
  ],
  "maxItems": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "includeSuggestedAccounts": true,
  "maxSuggestedPerAccount": 10,
  "hideAlreadyFollowedSuggestions": true
}
```

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

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

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

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

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

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.instagram.com/mrbeast/"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call scrapebase/instagram-following-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapebase/instagram-following-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/3dHCF8qLxffpWxXbM/builds/cauaejqYDNBB0jiM1/openapi.json
