# Instagram Profile Searcher & Analyzer (`devrecated/instagram-profile-searcher`) Actor

Find Instagram profiles by name or username, rank matches, and analyze followers, engagement, comments, and media. Bring your own Instagram login or use publisher env credentials.

- **URL**: https://apify.com/devrecated/instagram-profile-searcher.md
- **Developed by:** [Devrecated Admin](https://apify.com/devrecated) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 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/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

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

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Instagram Profile Searcher & Analyzer

**Find Instagram profiles by @username or real name**, rank the best matches, then **analyze followers, following, engagement, comments, likers, and media** — all in one Apify Actor run.

Works from Apify Console, the Apify API, schedules, and integrations (Make, n8n, Zapier, MCP). Results land in a structured **dataset** you can export as JSON, CSV, or Excel.

### What does Instagram Profile Searcher do?

For each **username** or **search query**, the Actor:

1. Resolves exact `@handles` (direct lookup) and/or searches Instagram by name
2. Scores candidates (username, full name, fuzzy match)
3. Analyzes top profiles: bio, counts, recent-post engagement, comments, likers
4. Optionally scrapes **followers** / **following** (with mutual flags) and **downloads** photos, carousels, and reels

Built for lead research, influencer discovery, competitor audits, and OSINT-style profile enrichment.

### How to use it (quick start)

1. Open this Actor in [Apify Console](https://console.apify.com) and click **Try for free** / **Start**
2. Add at least one of:
   - **Usernames** — exact handles (e.g. `natgeo`)
   - **Search queries** — real names or fuzzy text (e.g. `Jane Doe`)
3. *(Recommended)* Enter your **Instagram login username** and **password** in the input form (password is stored encrypted). Or leave them empty if the Actor owner configured a shared service account via environment variables
4. Tune optional caps (posts, comments, followers, downloads)
5. Run → open the **Dataset** tab for profile rows

#### Input example

```json
{
  "instagramUsername": "your_scraper_account",
  "instagramPassword": "your_password",
  "usernames": ["natgeo"],
  "searchQueries": ["Jane Doe"],
  "maxProfilesToAnalyze": 5,
  "analyzeRecentPosts": 12,
  "includeComments": true,
  "includeLikers": true,
  "includeFollowers": true,
  "maxFollowers": 5000,
  "downloadPhotos": true,
  "maxPostsToDownload": 50
}
```

Full field reference (types, defaults, ranges): see the input form tooltips or [`PARAMETERS.md`](./PARAMETERS.md) in the source repo.

### Instagram login (required)

Instagram private/mobile APIs need a logged-in account. Provide credentials in **one** of these ways:

| Method | Fields | When to use |
| --- | --- | --- |
| **Run input** (bring your own) | `instagramUsername`, `instagramPassword` (secret), optional `instagramSessionId` | Best for Store users — each run uses *your* account |
| **Actor env vars** (publisher) | `INSTAGRAM_USERNAME`, `INSTAGRAM_PASSWORD`, … | Shared service account for the Actor owner |

**Notes**

- Password / session ID inputs are marked **secret** — Apify encrypts them at rest; the Actor reads them decrypted only during the run
- Input login **overrides** env vars when set
- If you use a different account than the publisher’s service account, the Actor **does not** write your session into the shared service key-value store
- Keep the password even after a successful login — Instagram may force re-auth
- Optional IMAP env vars can auto-submit email challenge codes for the *publisher* service account (see below)

Respect [Instagram’s Terms of Use](https://help.instagram.com/) and local law. Prefer official Meta APIs for regulated production use. This Actor uses [instagrapi](https://github.com/subzeroid/instagrapi) (unofficial mobile flows) and may hit challenges or rate limits.

### Input fields

#### Authentication

| Field | Required | Description |
| --- | --- | --- |
| `instagramUsername` | No\* | Instagram account used to **log in** (not a profile to scrape) |
| `instagramPassword` | No\* | Password (encrypted secret input) |
| `instagramSessionId` | No | Optional `sessionid` cookie instead of password |

\*Required for login unless a valid session / publisher env credentials are already available.

#### What to scrape

| Field | Description | Default |
| --- | --- | --- |
| `usernames` | Exact `@handles` to fetch directly | — |
| `searchQueries` | Names / fuzzy text to search | — |
| `maxSearchResultsPerQuery` | Candidates per search query | `15` |
| `maxProfilesToAnalyze` | Full analyses per **search** query | `5` |
| `analyzeRecentPosts` | Posts sampled for engagement (`0` = off) | `12` |
| `includeComments` / `maxCommentsPerPost` | Comment scrape + cap | `true` / `100` |
| `includeLikers` / `maxLikersPerPost` | Likers scrape + cap | `true` / `100` |
| `includeFollowers` / `maxFollowers` | Follower list + cap | `true` / `5000` |
| `includeFollowing` / `maxFollowing` | Following list + cap | `true` / `5000` |
| `downloadPhotos` / `maxPostsToDownload` | Download media files | `true` / `50` |
| `minMatchScore` | Min 0–1 score for search matches | `0.35` |
| `requestDelaySeconds` | Delay between Instagram API calls | `1` |

Provide **at least one** of `usernames` or `searchQueries`.

### Output (dataset)

Each dataset item is one profile (or a failed lookup row). Typical fields:

| Field | Meaning |
| --- | --- |
| `username`, `fullName`, `profileUrl` | Identity |
| `followerCount`, `followingCount`, `isPrivate`, `isVerified` | Public stats |
| `matchScore`, `query`, `inputType` | How this row was found |
| `analysis.recentPosts[]` | Sampled posts with engagement |
| `analysis.commenters[]` / `analysis.likers[]` | Aggregated people from sampled posts |
| `followers[]` / `following[]` | Network lists (`followsBack` / `isMutual` when both scraped) |
| `analysis.downloadedPhotos[]` | Paths / keys for saved media |

#### Output example (abbreviated)

```json
{
  "query": "natgeo",
  "inputType": "username",
  "status": "ok",
  "username": "natgeo",
  "fullName": "National Geographic",
  "followerCount": 280000000,
  "profileUrl": "https://www.instagram.com/natgeo/",
  "analysis": {
    "recentPosts": [],
    "commenters": [],
    "likers": [],
    "downloadedPhotos": []
  },
  "followers": [],
  "following": []
}
```

Private accounts skip posts, network lists, and downloads.

### Pricing

This Actor runs on Apify platform usage (compute, storage, proxies if configured). Final Store pricing depends on the monetization model set by the publisher (pay per event or pay per usage). Check the **Pricing** tab on this Actor’s Store page for current rates.

Tips to control cost:

- Prefer exact `usernames` over broad `searchQueries` when you already know the handle
- Lower `maxFollowers` / `maxFollowing` / `maxPostsToDownload` for large accounts
- Set `analyzeRecentPosts` to `0` if you only need profile metadata

### API, schedules, and integrations

- **API** — start runs with the [Apify API](https://docs.apify.com/api/v2) or official JS/Python clients; pass the same JSON input
- **Schedules** — re-run daily/weekly from Console to track follower growth
- **Integrations** — connect dataset results to webhooks, Google Sheets, Make, n8n, Zapier
- **MCP / agents** — discover and call this Actor from Apify’s MCP server

### Publisher: service account env vars

If you own this Actor and want a shared scraper account (instead of per-run input login), set in **Actor → Settings / Environment variables**:

| Variable | Secret? | Purpose |
| --- | --- | --- |
| `INSTAGRAM_USERNAME` | no | Default scraper username |
| `INSTAGRAM_PASSWORD` | yes | Default scraper password |
| `INSTAGRAM_SESSION_ID` | yes | Optional instead of password |
| `INSTAGRAM_PROXY_URL` | yes | Optional proxy |
| `INSTAGRAM_SESSION_KV_NAME` | no | Named KV for persisted session (default `instagram-profile-searcher-service-session`) |
| `INSTAGRAM_CHALLENGE_IMAP_*` | mixed | Auto-fetch email login codes |
| `INSTAGRAM_VERIFICATION_CODE` | yes | One-shot manual code |

After a successful service-account login, session JSON is stored under `INSTAGRAM_SESSION_SETTINGS` in that named key-value store (publisher storage, not the end-user run store).

### FAQ

#### Do I need my own Instagram account?

Yes for reliable runs. Use **run input** login, or rely on the publisher’s configured service account if they provide one.

#### Why did login fail / challenge appear?

Instagram may email a code or ask “Is this you?”. For publisher env accounts, configure IMAP challenge vars or approve the device in the Instagram app. For BYOA input login, complete challenges on that account and retry; use a residential proxy (`INSTAGRAM_PROXY_URL` / your own setup) if the IP is flagged.

#### Is scraping Instagram free / legal?

Apify platform usage is billed per your plan. Instagram’s terms restrict unauthorized automation — use responsibly and only for data you are allowed to collect.

#### Can I get results via API?

Yes. Every run writes to a dataset; use the dataset items URL from the run, or `Actor.push_data` consumers via the Apify API clients.

### Local development

```bash
make setup          # venv + deps + .env
## edit .env with INSTAGRAM_* credentials
make e2e            # validate + apify run + print results
make web            # optional local FastAPI UI
```

Or: copy `INPUT.example.json` → `storage/key_value_stores/default/INPUT.json`, source `.env`, then `apify run --no-purge`.

### Support

Open an Issue on the Actor’s page in Apify Console, or contact the publisher from the Store profile. Feature requests (extra fields, other networks) are welcome.

### License

Actor code: use under your Apify account terms. [instagrapi](https://github.com/subzeroid/instagrapi) is MIT licensed.

# Actor input Schema

## `instagramUsername` (type: `string`):

Instagram account used to authenticate API calls (not a profile to scrape). Overrides INSTAGRAM_USERNAME when set. Leave empty to use the Actor owner's configured service account.

## `instagramPassword` (type: `string`):

Password for instagramUsername. Stored encrypted. Keep even when a session already exists — Instagram may ask to re-login.

## `instagramSessionId` (type: `string`):

Optional alternative to password login (sessionid cookie). Stored encrypted. Overrides INSTAGRAM_SESSION_ID when set.

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

Exact Instagram @handles to fetch directly (with or without @). Skips name search — one profile lookup per username.

## `searchQueries` (type: `array`):

Real names or fuzzy text to search for. Instagram search + ranking; not a direct username fetch.

## `maxSearchResultsPerQuery` (type: `integer`):

Maximum account candidates collected from Instagram search endpoints for each search query.

## `maxProfilesToAnalyze` (type: `integer`):

Number of top-ranked search matches per query to fetch full profile details and engagement stats for. Direct usernames always analyze the one matched profile.

## `analyzeRecentPosts` (type: `integer`):

How many recent posts to scrape for engagement + comments (0 disables post analysis).

## `includeComments` (type: `boolean`):

For each recent post, scrape comment text, author, and timestamps.

## `maxCommentsPerPost` (type: `integer`):

Cap on comments pulled per recent post (parents + replies).

## `includeLikers` (type: `boolean`):

For each recent post, scrape who liked it (usernames + profile links). Instagram does not expose when each like happened.

## `maxLikersPerPost` (type: `integer`):

Cap on likers pulled per recent post. Popular posts will be truncated.

## `includeFollowers` (type: `boolean`):

Scrape the full follower list (up to maxFollowers). Large accounts will be truncated.

## `maxFollowers` (type: `integer`):

Safety cap. Instagram blocks or rate-limits unbounded scrapes; raise carefully.

## `includeFollowing` (type: `boolean`):

Scrape the full following list (up to maxFollowing).

## `maxFollowing` (type: `integer`):

Safety cap for accounts the profile follows.

## `downloadPhotos` (type: `boolean`):

Download photo, carousel, and reel/video files per profile into storage/media/{username}/{n}\_{YYYY-MM-DD}/ on disk (not the default key-value store).

## `maxPostsToDownload` (type: `integer`):

Maximum number of posts (photo, carousel, or reel) to download media from per profile. A carousel counts as one post; all of its slides are saved.

## `maxPhotosPerProfile` (type: `integer`):

Deprecated alias for maxPostsToDownload. Prefer maxPostsToDownload.

## `minMatchScore` (type: `number`):

Search results below this 0–1 score are ignored (unless no full profile fetch succeeds). Does not apply to direct usernames.

## `requestDelaySeconds` (type: `number`):

Pause between Instagram API calls to reduce rate limits.

## Actor input object example

```json
{
  "usernames": [
    "instagram"
  ],
  "searchQueries": [
    "Jane Doe"
  ],
  "maxSearchResultsPerQuery": 15,
  "maxProfilesToAnalyze": 5,
  "analyzeRecentPosts": 12,
  "includeComments": true,
  "maxCommentsPerPost": 100,
  "includeLikers": true,
  "maxLikersPerPost": 100,
  "includeFollowers": true,
  "maxFollowers": 5000,
  "includeFollowing": true,
  "maxFollowing": 5000,
  "downloadPhotos": true,
  "maxPostsToDownload": 50,
  "maxPhotosPerProfile": 50,
  "minMatchScore": 0.35,
  "requestDelaySeconds": 1
}
```

# Actor output Schema

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

No description

# 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": [
        "instagram"
    ],
    "searchQueries": [
        "Jane Doe"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("devrecated/instagram-profile-searcher").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": ["instagram"],
    "searchQueries": ["Jane Doe"],
}

# Run the Actor and wait for it to finish
run = client.actor("devrecated/instagram-profile-searcher").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 '{
  "usernames": [
    "instagram"
  ],
  "searchQueries": [
    "Jane Doe"
  ]
}' |
apify call devrecated/instagram-profile-searcher --silent --output-dataset

```

## MCP server setup

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

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/SctESa9Wd6NeUp9Ft/builds/cGIKHx3igqbZBnQaQ/openapi.json
