# Discord Member Scraper (`khadinakbar/discord-member-scraper`) Actor

Scrape Discord server members via the official Bot API — usernames, roles, join dates, and Nitro boosts.

- **URL**: https://apify.com/khadinakbar/discord-member-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, MCP servers, Lead generation
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 member scrapeds

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

## Discord Member Scraper

Export the full member roster of a Discord server you own or manage — **using the official Discord Bot API**, not banned user-token tricks. Returns one clean record per member: username, server display name, roles (resolved to names), join date, Nitro-boost status, timeout status, and more.

This actor is **ToS-compliant by design**. It only reads servers where *you* have added *your own* bot with the **Server Members Intent** enabled. It will never get your Discord account banned and will not be pulled from the Store for abuse — unlike scrapers that ride on user account tokens.

> ⚙️ **MCP-ready.** Single server ID + bot token in, structured JSON out. Built for AI agents (Claude, ChatGPT) and no-code tools alike.

### What you get

| Field | Description |
|-------|-------------|
| `userId` | Discord user snowflake ID |
| `username` | Discord username (handle) |
| `globalName` | Account-wide display name |
| `displayName` | Server nickname → global name → username (best available) |
| `nickname` | Per-server nickname, if set |
| `isBot` | `true` for bot / application accounts |
| `avatarUrl` | CDN URL of the member's avatar |
| `roleIds` | Array of role snowflake IDs |
| `roleNames` | Array of human-readable role names (when resolution is on) |
| `joinedAt` | ISO-8601 timestamp the member joined |
| `premiumSince` | ISO-8601 timestamp Nitro-boosting started, if any |
| `isPending` | `true` if the member hasn't passed membership screening |
| `isTimedOut` | `true` if the member is currently timed out |
| `communicationDisabledUntil` | ISO-8601 timeout expiry, if any |
| `guildId` | The server this record came from |

A run summary (guild name, members scraped/scanned, filters, estimated cost) is written to the key-value store under `OUTPUT`.

### When to use it

- **Community managers / server owners** exporting their member list for analytics, CRM, or backups.
- **Moderation teams** auditing who holds which roles, who's timed out, who's pending screening.
- **Growth teams** tracking Nitro boosters and join cohorts over time.

**Not for:** scraping servers you don't control, reading messages, or harvesting emails (Discord's API does not expose member email addresses). For message history, use a dedicated Discord message scraper.

### Pricing (pay-per-event)

| Event | Price |
|-------|-------|
| Actor start | $0.001 per run |
| Member scraped | $0.004 per member returned |

A 5,000-member server costs about **$20**. You are billed only for members actually returned (after your exclude-bots and role filters), and `maxMembers` caps your spend. No subscription.

### Setup (one-time, ~3 minutes)

1. Go to the [Discord Developer Portal](https://discord.com/developers/applications) → **New Application**.
2. Open **Bot** → **Reset Token** → copy the token. Paste it into this actor's `botToken` input.
3. On the same Bot page, enable **Privileged Gateway Intents → Server Members Intent**. This is mandatory — without it Discord refuses to return members.
4. Open **OAuth2 → URL Generator**, tick **bot** scope, copy the URL, open it, and add the bot to your server. (You need *Manage Server* permission on that server.)
5. In Discord, enable Developer Mode (**User Settings → Advanced**), right-click your server icon → **Copy Server ID**. Paste it into `guildId`.

That's it. Run the actor.

### Input example

```json
{
  "botToken": "YOUR_BOT_TOKEN",
  "guildId": "974519864045756446",
  "maxMembers": 5000,
  "includeRoleNames": true,
  "excludeBots": true,
  "roleFilter": ["Moderator", "Verified"]
}
````

### Output example

```json
{
  "userId": "100000000000000001",
  "username": "jane_doe",
  "globalName": "Jane",
  "displayName": "Jane (mod)",
  "nickname": "Jane (mod)",
  "isBot": false,
  "avatarUrl": "https://cdn.discordapp.com/avatars/100000000000000001/abc.png?size=256",
  "roleIds": ["200000000000000001"],
  "roleNames": ["Moderator"],
  "joinedAt": "2023-04-01T12:00:00.000000+00:00",
  "premiumSince": null,
  "isPending": false,
  "isTimedOut": false,
  "guildId": "974519864045756446"
}
```

### Call it from code

**Apify JS client:**

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('khadinakbar/discord-member-scraper').call({
  botToken: 'YOUR_BOT_TOKEN',
  guildId: '974519864045756446',
  maxMembers: 5000,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**Python client:**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("khadinakbar/discord-member-scraper").call(run_input={
    "botToken": "YOUR_BOT_TOKEN",
    "guildId": "974519864045756446",
    "maxMembers": 5000,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

### How it works

The actor authenticates as your bot (`GET /users/@me`), confirms the bot can see the target server (`GET /guilds/{id}`), optionally fetches the role list once to resolve names (`GET /guilds/{id}/roles`), then paginates the official member endpoint (`GET /guilds/{id}/members?limit=1000&after=…`) until the whole roster — or your `maxMembers` cap — is collected. It respects Discord's rate limits (429 `Retry-After`, per-route buckets) and retries transient errors with backoff. HTTP-only; no browser, no proxy required.

### FAQ

**Do I need to host the bot anywhere?** No. The bot just needs to exist and be a member of your server. This actor does the API calls.

**Why only my own servers?** Discord's API only returns member lists to bots that are *in* the server with the Server Members Intent. There is no compliant way to read a server you haven't added a bot to — and the non-compliant ways get accounts banned.

**Can I get member emails or phone numbers?** No. Discord's API never exposes those. Any tool claiming to is either fabricating data or breaking Discord ToS.

**Why is my run failing with "SERVER MEMBERS INTENT is disabled"?** You skipped step 3 above. Enable the intent in the Developer Portal, then re-run.

**Large server (100k+ members)?** Raise `maxMembers`. The actor paginates 1,000 at a time and respects rate limits; very large servers take a few minutes.

### Legal & compliance

This actor uses Discord's official, documented Bot API and only accesses servers where you have added your own bot with the appropriate intent. You are responsible for ensuring your use complies with the [Discord Developer Terms of Service](https://discord.com/developers/docs/policies-and-agreements/developer-terms-of-service), the Discord Community Guidelines, and applicable data-protection law (e.g. GDPR/CCPA) when handling member data. Do not use scraped member data for spam, harassment, or unsolicited DMs.

# Actor input Schema

## `botToken` (type: `string`):

Your Discord bot token from the Developer Portal (your app → Bot → Reset Token). The bot must already be added to the target server AND have the SERVER MEMBERS INTENT enabled under Bot → Privileged Gateway Intents. Stored encrypted and never logged. This is NOT a user account token — only official bot tokens are supported (Discord ToS-compliant).

## `guildId` (type: `string`):

The numeric Discord server ID whose members you want to scrape (e.g. '974519864045756446'). Enable Developer Mode in Discord (User Settings → Advanced), then right-click the server icon and choose Copy Server ID. This is NOT a channel ID or an invite link.

## `maxMembers` (type: `integer`):

Maximum number of members to scrape and bill for. Pagination stops once this cap is reached. Defaults to 1000. Raise it for large servers — each returned member is billed individually, so this also caps your cost.

## `includeRoleNames` (type: `boolean`):

When true (default), the server's role list is fetched once and each member's role IDs are mapped to human-readable names (added as 'roleNames'). When false, only raw 'roleIds' are returned. Set false to skip one API call on very large servers.

## `excludeBots` (type: `boolean`):

When true, bot/application accounts are skipped and not billed. Defaults to false (bots included). Turn on to keep only human members.

## `roleFilter` (type: `array`):

Optional list of role names or role IDs (e.g. \['Moderator','Verified']). When set, only members holding at least one of these roles are returned and billed. Matching is case-insensitive. Leave empty to return every member.

## Actor input object example

```json
{
  "guildId": "974519864045756446",
  "maxMembers": 1000,
  "includeRoleNames": true,
  "excludeBots": false,
  "roleFilter": []
}
```

# Actor output Schema

## `members` (type: `string`):

All scraped Discord member records as JSON.

# 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 = {
    "maxMembers": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/discord-member-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 = { "maxMembers": 1000 }

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/discord-member-scraper").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 '{
  "maxMembers": 1000
}' |
apify call khadinakbar/discord-member-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=khadinakbar/discord-member-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Discord Member Scraper",
        "description": "Scrape Discord server members via the official Bot API — usernames, roles, join dates, and Nitro boosts.",
        "version": "1.0",
        "x-build-id": "hJV4yVbyuChtcuvLK"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/khadinakbar~discord-member-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-khadinakbar-discord-member-scraper",
                "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/khadinakbar~discord-member-scraper/runs": {
            "post": {
                "operationId": "runs-sync-khadinakbar-discord-member-scraper",
                "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/khadinakbar~discord-member-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-khadinakbar-discord-member-scraper",
                "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": [
                    "botToken",
                    "guildId"
                ],
                "properties": {
                    "botToken": {
                        "title": "Discord bot token",
                        "type": "string",
                        "description": "Your Discord bot token from the Developer Portal (your app → Bot → Reset Token). The bot must already be added to the target server AND have the SERVER MEMBERS INTENT enabled under Bot → Privileged Gateway Intents. Stored encrypted and never logged. This is NOT a user account token — only official bot tokens are supported (Discord ToS-compliant)."
                    },
                    "guildId": {
                        "title": "Server (guild) ID",
                        "type": "string",
                        "description": "The numeric Discord server ID whose members you want to scrape (e.g. '974519864045756446'). Enable Developer Mode in Discord (User Settings → Advanced), then right-click the server icon and choose Copy Server ID. This is NOT a channel ID or an invite link."
                    },
                    "maxMembers": {
                        "title": "Max members",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Maximum number of members to scrape and bill for. Pagination stops once this cap is reached. Defaults to 1000. Raise it for large servers — each returned member is billed individually, so this also caps your cost.",
                        "default": 1000
                    },
                    "includeRoleNames": {
                        "title": "Resolve role names",
                        "type": "boolean",
                        "description": "When true (default), the server's role list is fetched once and each member's role IDs are mapped to human-readable names (added as 'roleNames'). When false, only raw 'roleIds' are returned. Set false to skip one API call on very large servers.",
                        "default": true
                    },
                    "excludeBots": {
                        "title": "Exclude bot accounts",
                        "type": "boolean",
                        "description": "When true, bot/application accounts are skipped and not billed. Defaults to false (bots included). Turn on to keep only human members.",
                        "default": false
                    },
                    "roleFilter": {
                        "title": "Filter by role",
                        "type": "array",
                        "description": "Optional list of role names or role IDs (e.g. ['Moderator','Verified']). When set, only members holding at least one of these roles are returned and billed. Matching is case-insensitive. Leave empty to return every member.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
