# Instagram Story & Mentions Fetcher (`barefoot_year/instagram-story-mentions-fetcher`) Actor

Fetches active Instagram stories and @mention stickers for one or more usernames. Returns story media URLs, metadata, and mention details.

- **URL**: https://apify.com/barefoot\_year/instagram-story-mentions-fetcher.md
- **Developed by:** [Ghost Rider](https://apify.com/barefoot_year) (community)
- **Categories:** Social media
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 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 Story & Mentions Fetcher

Apify actor that fetches active Instagram stories and @mention stickers for one or more usernames.

### Features

- Fetch active stories for multiple Instagram usernames in one run
- Extract `@mention` stickers with username, user ID, full name, and profile picture
- Return image/video URLs in multiple resolutions
- Handle accounts with no active stories gracefully

### Input

| Field | Required | Description |
|-------|----------|-------------|
| `usernames` | Yes | Array of Instagram usernames (without `@`) |
| `sessionId` | Yes | Instagram `sessionid` cookie |
| `csrfToken` | Yes | Instagram `csrftoken` cookie |
| `proxyConfiguration` | No | Defaults to Apify **residential proxy, India (IN)** |
| `requestDelayMs` | No | Delay between accounts in ms (default: 1500) |

#### How to get Instagram cookies

1. Log in to [instagram.com](https://www.instagram.com) in Chrome
2. Press `F12` → **Application** tab → **Cookies** → `https://www.instagram.com`
3. Copy `sessionid` and `csrftoken` values
4. Use a test account — not your main personal account

#### Default cookies on Apify

After `apify push`, open the actor in Apify Console → **Input** tab → paste your `sessionId` and `csrfToken` → click **Save & Start** once. Apify remembers them as the default input for future runs.

For local runs, copy `INPUT.json.example` to `INPUT.json` and fill in your cookies there (`INPUT.json` is gitignored).

### Schemas

| File | Purpose |
|------|---------|
| `.actor/input_schema.json` | Apify input form with sample usernames, cookies, and India residential proxy |
| `.actor/output_schema.json` | Links run output to the dataset in Apify Console |
| `.actor/dataset_schema.json` | Documents every output field with examples |

### Output

Each dataset item is either a full story record or a minimal "no stories" record.

#### Story with mentions

```json
{
  "storyId": "3912892102384725364",
  "userId": "3054343568",
  "username": "arya_jain_",
  "mediaType": "video",
  "imageUrl": "https://...",
  "videoUrl": "https://...",
  "storyBloksStickersCount": 1,
  "storyBloksStickers": [
    {
      "stickerType": "mention",
      "mentionUsername": "magnetomall",
      "mentionAccountId": "6282740940",
      "mentionFullName": "Magneto Mall",
      "mentionProfilePicUrl": "https://..."
    }
  ]
}
````

#### No active stories

```json
{
  "username": "explorewithsparsh",
  "mediaType": "none",
  "storiesCount": 0,
  "takenAtFormatted": "No active stories",
  "success": true
}
```

### Local development

```bash
npm install
```

Create `INPUT.json` in the project root:

```json
{
  "usernames": ["natgeo"],
  "sessionId": "YOUR_SESSION_ID",
  "csrfToken": "YOUR_CSRF_TOKEN"
}
```

Run locally with Apify CLI:

```bash
apify run
```

### Deploy to Apify

```bash
apify push
```

### Limitations

- Requires valid Instagram session cookies (expire every few weeks)
- Private accounts only work if the logged-in user follows them
- Instagram may rate-limit or block requests — use Apify proxy
- Scraping Instagram is against their Terms of Service — use at your own risk

# Actor input Schema

## `usernames` (type: `array`):

List of Instagram usernames to fetch stories from (without @).

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

Instagram sessionid cookie from browser DevTools → Application → Cookies → instagram.com.

## `csrfToken` (type: `string`):

Instagram csrftoken cookie from the same browser login session as sessionid.

## `mid` (type: `string`):

Optional but recommended. Copy mid cookie from instagram.com in DevTools. Helps avoid redirect errors.

## `igDid` (type: `string`):

Optional but recommended. Copy ig\_did cookie from instagram.com in DevTools.

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

Apify residential proxy (India) enabled by default to reduce Instagram rate limits.

## `requestDelayMs` (type: `integer`):

Wait time between processing each username to avoid rate limits.

## Actor input object example

```json
{
  "usernames": [
    "wassup.raipur",
    "explorewithsparsh",
    "arya_jain_",
    "raipur.inn_",
    "cafe_foodies07",
    "raipurwale__",
    "raipurfoodstuff",
    "anand.unfiltered"
  ],
  "sessionId": "34904493140%3AVpGAz1lgPn7ZGH%3A5%3AAYiPOXUuWqhcmzgpI569HWRBsvPYmFth6mGROYyTQ6s",
  "csrfToken": "tlRQZfaXuW3OcAoIzYANpcX1HQSsCcXa",
  "mid": "aQBxBQALAAF7qwnWgeTTxrB01TVe",
  "igDid": "18E1D099-5B68-4C25-9562-48E64897B4A2",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "IN"
  },
  "requestDelayMs": 1500
}
```

# Actor output Schema

## `stories` (type: `string`):

All scraped stories and no-story placeholders for each username.

# 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 = {
    "usernames": [
        "wassup.raipur",
        "explorewithsparsh",
        "arya_jain_",
        "raipur.inn_",
        "cafe_foodies07",
        "raipurwale__",
        "raipurfoodstuff",
        "anand.unfiltered"
    ],
    "sessionId": "34904493140%3AVpGAz1lgPn7ZGH%3A5%3AAYiPOXUuWqhcmzgpI569HWRBsvPYmFth6mGROYyTQ6s",
    "csrfToken": "tlRQZfaXuW3OcAoIzYANpcX1HQSsCcXa",
    "mid": "aQBxBQALAAF7qwnWgeTTxrB01TVe",
    "igDid": "18E1D099-5B68-4C25-9562-48E64897B4A2",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "IN"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("barefoot_year/instagram-story-mentions-fetcher").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 = {
    "usernames": [
        "wassup.raipur",
        "explorewithsparsh",
        "arya_jain_",
        "raipur.inn_",
        "cafe_foodies07",
        "raipurwale__",
        "raipurfoodstuff",
        "anand.unfiltered",
    ],
    "sessionId": "34904493140%3AVpGAz1lgPn7ZGH%3A5%3AAYiPOXUuWqhcmzgpI569HWRBsvPYmFth6mGROYyTQ6s",
    "csrfToken": "tlRQZfaXuW3OcAoIzYANpcX1HQSsCcXa",
    "mid": "aQBxBQALAAF7qwnWgeTTxrB01TVe",
    "igDid": "18E1D099-5B68-4C25-9562-48E64897B4A2",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "IN",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("barefoot_year/instagram-story-mentions-fetcher").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 '{
  "usernames": [
    "wassup.raipur",
    "explorewithsparsh",
    "arya_jain_",
    "raipur.inn_",
    "cafe_foodies07",
    "raipurwale__",
    "raipurfoodstuff",
    "anand.unfiltered"
  ],
  "sessionId": "34904493140%3AVpGAz1lgPn7ZGH%3A5%3AAYiPOXUuWqhcmzgpI569HWRBsvPYmFth6mGROYyTQ6s",
  "csrfToken": "tlRQZfaXuW3OcAoIzYANpcX1HQSsCcXa",
  "mid": "aQBxBQALAAF7qwnWgeTTxrB01TVe",
  "igDid": "18E1D099-5B68-4C25-9562-48E64897B4A2",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "IN"
  }
}' |
apify call barefoot_year/instagram-story-mentions-fetcher --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram Story & Mentions Fetcher",
        "description": "Fetches active Instagram stories and @mention stickers for one or more usernames. Returns story media URLs, metadata, and mention details.",
        "version": "1.0",
        "x-build-id": "xiWsEgHw2McmWgLBC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/barefoot_year~instagram-story-mentions-fetcher/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-barefoot_year-instagram-story-mentions-fetcher",
                "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/barefoot_year~instagram-story-mentions-fetcher/runs": {
            "post": {
                "operationId": "runs-sync-barefoot_year-instagram-story-mentions-fetcher",
                "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/barefoot_year~instagram-story-mentions-fetcher/run-sync": {
            "post": {
                "operationId": "run-sync-barefoot_year-instagram-story-mentions-fetcher",
                "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": [
                    "usernames",
                    "sessionId",
                    "csrfToken"
                ],
                "properties": {
                    "usernames": {
                        "title": "Instagram usernames",
                        "minItems": 1,
                        "type": "array",
                        "description": "List of Instagram usernames to fetch stories from (without @).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sessionId": {
                        "title": "Instagram sessionid cookie",
                        "type": "string",
                        "description": "Instagram sessionid cookie from browser DevTools → Application → Cookies → instagram.com."
                    },
                    "csrfToken": {
                        "title": "Instagram csrftoken cookie",
                        "type": "string",
                        "description": "Instagram csrftoken cookie from the same browser login session as sessionid."
                    },
                    "mid": {
                        "title": "Instagram mid cookie (optional)",
                        "type": "string",
                        "description": "Optional but recommended. Copy mid cookie from instagram.com in DevTools. Helps avoid redirect errors."
                    },
                    "igDid": {
                        "title": "Instagram ig_did cookie (optional)",
                        "type": "string",
                        "description": "Optional but recommended. Copy ig_did cookie from instagram.com in DevTools."
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify residential proxy (India) enabled by default to reduce Instagram rate limits."
                    },
                    "requestDelayMs": {
                        "title": "Delay between accounts (ms)",
                        "minimum": 0,
                        "maximum": 30000,
                        "type": "integer",
                        "description": "Wait time between processing each username to avoid rate limits.",
                        "default": 1500
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
