# Instagram Account Validation (`dwi_wahyu/instagram-account-validation`) Actor

Validates Instagram usernames and returns account existence, status (active, private, not_found, suspended, unknown), and profile metrics.

- **URL**: https://apify.com/dwi_wahyu/instagram-account-validation.md
- **Developed by:** [Dwi Wahyu](https://apify.com/dwi_wahyu) (community)
- **Stats:** 2 total users, 1 monthly users, 100.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 Account Validation Actor

An Apify Actor built in TypeScript that validates Instagram usernames in batches, determines whether each account exists, and returns its public profile status and metadata.

***

### Features

- **Batch Username Validation**: Accepts one or more plain Instagram usernames (`"nasa"` or `"@nasa"`), normalizes (strips leading `@`, trims whitespace, lowercases), and deduplicates them.
- **Strict Input Validation**: Rejects URLs, usernames with spaces, usernames over 30 characters, or disallowed characters with an error record in the output dataset without crashing the run.
- **Embedded Profile JSON Extraction**: Extracts profile data directly from Instagram's embedded SSR JSON (`xig_user_by_igid_v2`) and profile embed JSON (`contextJSON`), falling back to a headless Puppeteer browser only if embedded JSON is unavailable.
- **Conservative Concurrency & Backoff**: Processes usernames with modest concurrency (3–5) and retries failed requests up to 3 times with exponential backoff. Retry-exhausted requests are marked `"unknown"` with an error message rather than `"not_found"`.

***

### Input

| Field | Type | Required | Default | Description |
| :--- | :--- | :---: | :---: | :--- |
| `usernames` | `string[]` | Yes | `["nasa", "alex123", "nonexistent_user_xyz_987654"]` | Plain Instagram usernames to validate (e.g. `"nasa"` or `"@nasa"`). URLs are not accepted. |
| `proxyConfiguration` | `object` | No | `{ "useApifyProxy": true }` | Apify Proxy configuration. Use `"RESIDENTIAL"` proxy group if plain/datacenter requests are blocked. |
| `maxConcurrency` | `integer` | No | `4` | Maximum concurrent checks (between `1` and `5`). |
| `sessionCookie` | `string` (secret) | No | — | Optional Instagram `sessionid` cookie to unlock authenticated `isBusinessAccount` detection if needed. Never logged or stored. |

#### Example Input

```json
{
  "usernames": [
    "nasa",
    "@alex123",
    "nonexistent_user_xyz_987654",
    "invalid username with spaces"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "maxConcurrency": 4
}
```

***

### Output

Every unique normalized input username produces **exactly one item** in the default dataset. Results are configured via `.actor/dataset_schema.json` to render as a table in Apify Console.

#### Output Fields

```json
{
  "username": "nasa",
  "exists": true,
  "accountStatus": "active",
  "isPrivate": false,
  "isVerified": true,
  "isBusinessAccount": null,
  "fullName": "NASA",
  "followersCount": 104384844,
  "followingCount": 90,
  "postsCount": 4967,
  "profileUrl": "https://www.instagram.com/nasa/",
  "checkedAt": "2026-10-19T05:38:00.000Z",
  "error": null
}
```

#### Account Status Meanings (`accountStatus`)

| Status | `exists` | Meaning |
| :--- | :---: | :--- |
| `"active"` | `true` | The account exists and is a public profile (`isPrivate: false`). |
| `"private"` | `true` | The account exists and has the private flag enabled (`isPrivate: true`). |
| `"not_found"` | `false` | Instagram indicates the account does not exist (`httpErrorPage` / `PolarisErrorRoot` / 404). |
| `"suspended"` | `true` | Instagram indicates the account has been suspended, disabled, or restricted. |
| `"unknown"` | `null` | The account could not be classified due to an invalid input format, login wall, or retry-exhausted network error (details in `error`). |

> **Note on `null` fields**: This Actor never guesses values. If a field cannot be read publicly without authentication (such as `isBusinessAccount` on unauthenticated public HTML), it returns `null`.

***

### Example Output Dataset

```json
[
  {
    "username": "nasa",
    "exists": true,
    "accountStatus": "active",
    "isPrivate": false,
    "isVerified": true,
    "isBusinessAccount": null,
    "fullName": "NASA",
    "followersCount": 104384844,
    "followingCount": 90,
    "postsCount": 4967,
    "profileUrl": "https://www.instagram.com/nasa/",
    "checkedAt": "2026-10-19T05:38:00.000Z",
    "error": null
  },
  {
    "username": "alex123",
    "exists": true,
    "accountStatus": "private",
    "isPrivate": true,
    "isVerified": false,
    "isBusinessAccount": null,
    "fullName": "Alex Pohl",
    "followersCount": 5448,
    "followingCount": 450,
    "postsCount": 292,
    "profileUrl": "https://www.instagram.com/alex123/",
    "checkedAt": "2026-10-19T05:38:01.000Z",
    "error": null
  },
  {
    "username": "nonexistent_user_xyz_987654",
    "exists": false,
    "accountStatus": "not_found",
    "isPrivate": null,
    "isVerified": null,
    "isBusinessAccount": null,
    "fullName": null,
    "followersCount": null,
    "followingCount": null,
    "postsCount": null,
    "profileUrl": "https://www.instagram.com/nonexistent_user_xyz_987654/",
    "checkedAt": "2026-10-19T05:38:01.500Z",
    "error": null
  },
  {
    "username": "invalid username with spaces",
    "exists": null,
    "accountStatus": "unknown",
    "isPrivate": null,
    "isVerified": null,
    "isBusinessAccount": null,
    "fullName": null,
    "followersCount": null,
    "followingCount": null,
    "postsCount": null,
    "profileUrl": "https://www.instagram.com/invalid%20username%20with%20spaces/",
    "checkedAt": "2026-10-19T05:38:00.000Z",
    "error": "Invalid username: spaces are not allowed in Instagram usernames."
  }
]
```

***

### Local Development & Deployment

```bash
## Install dependencies and build
npm install
npm run build

## Run locally with Apify CLI
apify run

## Authenticate and deploy to Apify Cloud
apify login
apify push
```

# Actor input Schema

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

List of Instagram usernames to validate (plain usernames only, e.g. "nasa" or "@nasa"). URLs are not accepted.

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

Apify Proxy settings. Residential proxy is strongly recommended on Apify platform because Instagram blocks datacenter IP addresses with HTTP 429.

## `onlyExisting` (type: `boolean`):

If enabled, only accounts that exist (status active, private, or suspended) are saved to the dataset. Non-existent, invalid, or failed accounts are excluded, keeping the dataset clean and empty if no valid accounts are found.

## `maxConcurrency` (type: `integer`):

Maximum number of usernames validated in parallel (conservative default: 4).

## `sessionCookie` (type: `string`):

Optional Instagram 'sessionid' cookie value if authenticated access is needed. Stored encrypted and never logged.

## Actor input object example

```json
{
  "usernames": [
    "nasa",
    "alex123",
    "nonexistent_user_xyz_987654"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "onlyExisting": true,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `overview` (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": [
        "nasa",
        "alex123",
        "nonexistent_user_xyz_987654"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("dwi_wahyu/instagram-account-validation").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": [
        "nasa",
        "alex123",
        "nonexistent_user_xyz_987654",
    ],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("dwi_wahyu/instagram-account-validation").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": [
    "nasa",
    "alex123",
    "nonexistent_user_xyz_987654"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call dwi_wahyu/instagram-account-validation --silent --output-dataset

```

## MCP server setup

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

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/J7ec1OXAn0fkMEhnO/builds/dKhuzMvFFA5tkaYyY/openapi.json
