# Discord Scraper - Members and Messages (`curious_coder/discord-data-scraper`) Actor

Scrape discord server members and channel messages.

- **URL**: https://apify.com/curious_coder/discord-data-scraper.md
- **Developed by:** [Curious Coder](https://apify.com/curious_coder) (community)
- **Categories:** Automation, Social media
- **Stats:** 1,315 total users, 34 monthly users, 20.9% runs succeeded, 49 bookmarks
- **User rating**: 4.96 out of 5 stars

## Pricing

from $0.10 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

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

### Important points to consider when using this actor

1. You can save costs by configuring this actor to run on low memory, as low as 512MB. Increasing memory won't make it faster or better.
2. If the actor stops before scraping all records due to unexpected error, you can simply ressurect the actor to resume scraping.

### Features

1. Scrape messages from any discord server channel
2. Scrape members of any discord server

### How to get Token

To get the token follow these steps:

1. Login to your discord account using google chrome
2. Open Developer tools (3 Dots Menu > More tools > Developer tools)
3. Goto 'Console' Tab and paste following code and press ENTER. It will copy the token to your clipboard automatically. (You should get message that says "Worked!" if the token was copied successfully)

```js
window.webpackChunkdiscord_app.push([
	[Symbol()],
	{},
	req => {
		if (!req.c) return;
		for (let m of Object.values(req.c)) {
			try {
				if (!m.exports || m.exports === window) continue;
				if (m.exports?.getToken) return copy(m.exports.getToken());
				for (let ex in m.exports) {
					if (m.exports?.[ex]?.getToken && m.exports[ex][Symbol.toStringTag] !== 'IntlMessagesProxy') return copy(m.exports[ex].getToken());
				}
			} catch {}
		}
	},
]);

window.webpackChunkdiscord_app.pop();
console.log('%cWorked!', 'font-size: 50px');
console.log(`%cYou now have your token in the clipboard!`, 'font-size: 16px');

```

Here is the sample output of this actor:

### Messages

```json
{
	"id": "1131713979111186482",
	"type": 19,
	"content": "**high definition photo of a modern powder bathroom in a high-end home in the desert. bright daytime light and a skylight. white oak and natural materials and woven textures with desert inspirted colors, modern desert-inspired spanish tile. Matte black hardware. Modern light sconces around the vanity mirror. Include some natural desert elements into the design. (fast)** - Image #2 <@1122599062454157382>",
	"channel_id": "1008571020480876554",
	"author": {
		"id": "936929561302675456",
		"username": "Midjourney Bot",
		"avatar": "f6ce562a6b4979c4b1cbc5b436d3be76",
		"discriminator": "9282",
		"public_flags": 589824,
		"flags": 589824,
		"bot": true,
		"banner": null,
		"accent_color": null,
		"global_name": null,
		"avatar_decoration": null,
		"display_name": null,
		"banner_color": null
	},
	"attachments": [
		{
			"id": "1131713978821791776",
			"filename": "camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_f58fa448-1620-4aca-9621-005ef9f3b383.png",
			"size": 1433631,
			"url": "https://cdn.discordapp.com/attachments/1008571020480876554/1131713978821791776/camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_f58fa448-1620-4aca-9621-005ef9f3b383.png",
			"proxy_url": "https://media.discordapp.net/attachments/1008571020480876554/1131713978821791776/camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_f58fa448-1620-4aca-9621-005ef9f3b383.png",
			"width": 1024,
			"height": 1024,
			"content_type": "image/png"
		}
	],
	"embeds": [],
	"mentions": [
		{
			"id": "1122599062454157382",
			"username": "camcooke",
			"avatar": null,
			"discriminator": "0",
			"public_flags": 0,
			"flags": 0,
			"banner": null,
			"accent_color": null,
			"global_name": "camcam",
			"avatar_decoration": null,
			"display_name": "camcam",
			"banner_color": null
		}
	],
	"mention_roles": [],
	"pinned": false,
	"mention_everyone": false,
	"tts": false,
	"timestamp": "2023-07-20T22:27:18.849000+00:00",
	"edited_timestamp": null,
	"flags": 0,
	"components": [
		{
			"type": 1,
			"components": [
				{
					"type": 2,
					"custom_id": "MJ::JOB::high_variation::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"label": "Vary (Strong)",
					"emoji": {
						"name": "🪄"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::JOB::low_variation::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"label": "Vary (Subtle)",
					"emoji": {
						"name": "🪄"
					}
				}
			]
		},
		{
			"type": 1,
			"components": [
				{
					"type": 2,
					"custom_id": "MJ::Outpaint::50::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"label": "Zoom Out 2x",
					"emoji": {
						"name": "🔍"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::Outpaint::75::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"label": "Zoom Out 1.5x",
					"emoji": {
						"name": "🔍"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::CustomZoom::f58fa448-1620-4aca-9621-005ef9f3b383",
					"style": 2,
					"label": "Custom Zoom",
					"emoji": {
						"name": "🔍"
					}
				}
			]
		},
		{
			"type": 1,
			"components": [
				{
					"type": 2,
					"custom_id": "MJ::JOB::pan_left::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"emoji": {
						"name": "⬅️"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::JOB::pan_right::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"emoji": {
						"name": "➡️"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::JOB::pan_up::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"emoji": {
						"name": "⬆️"
					}
				},
				{
					"type": 2,
					"custom_id": "MJ::JOB::pan_down::1::f58fa448-1620-4aca-9621-005ef9f3b383::SOLO",
					"style": 2,
					"emoji": {
						"name": "⬇️"
					}
				}
			]
		},
		{
			"type": 1,
			"components": [
				{
					"type": 2,
					"custom_id": "MJ::BOOKMARK::f58fa448-1620-4aca-9621-005ef9f3b383",
					"style": 2,
					"emoji": {
						"name": "❤️"
					}
				},
				{
					"type": 2,
					"style": 5,
					"label": "Web",
					"url": "https://www.midjourney.com/app/jobs/f58fa448-1620-4aca-9621-005ef9f3b383/"
				}
			]
		}
	],
	"message_reference": {
		"channel_id": "1008571020480876554",
		"message_id": "1131713804179362064",
		"guild_id": "662267976984297473"
	},
	"referenced_message": {
		"id": "1131713804179362064",
		"type": 19,
		"content": "**high definition photo of a modern powder bathroom in a high-end home in the desert. bright daytime light and a skylight. white oak and natural materials and woven textures with desert inspirted colors, modern desert-inspired spanish tile. Matte black hardware. Modern light sconces around the vanity mirror. Include some natural desert elements into the design. (fast)** - Variations (Strong) by <@1122599062454157382> (fast)",
		"channel_id": "1008571020480876554",
		"author": {
			"id": "936929561302675456",
			"username": "Midjourney Bot",
			"avatar": "f6ce562a6b4979c4b1cbc5b436d3be76",
			"discriminator": "9282",
			"public_flags": 589824,
			"flags": 589824,
			"bot": true,
			"banner": null,
			"accent_color": null,
			"global_name": null,
			"avatar_decoration": null,
			"display_name": null,
			"banner_color": null
		},
		"attachments": [
			{
				"id": "1131713803940274198",
				"filename": "camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_3eaa7c0c-9825-4110-9c89-02c4e463a8d0.png",
				"size": 6647039,
				"url": "https://cdn.discordapp.com/attachments/1008571020480876554/1131713803940274198/camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_3eaa7c0c-9825-4110-9c89-02c4e463a8d0.png",
				"proxy_url": "https://media.discordapp.net/attachments/1008571020480876554/1131713803940274198/camcooke_high_definition_photo_of_a_modern_powder_bathroom_in_a_3eaa7c0c-9825-4110-9c89-02c4e463a8d0.png",
				"width": 2048,
				"height": 2048,
				"content_type": "image/png"
			}
		],
		"embeds": [],
		"mentions": [
			{
				"id": "1122599062454157382",
				"username": "camcooke",
				"avatar": null,
				"discriminator": "0",
				"public_flags": 0,
				"flags": 0,
				"banner": null,
				"accent_color": null,
				"global_name": "camcam",
				"avatar_decoration": null,
				"display_name": "camcam",
				"banner_color": null
			}
		],
		"mention_roles": [],
		"pinned": false,
		"mention_everyone": false,
		"tts": false,
		"timestamp": "2023-07-20T22:26:37.142000+00:00",
		"edited_timestamp": null,
		"flags": 0,
		"components": [
			{
				"type": 1,
				"components": [
					{
						"type": 2,
						"custom_id": "MJ::JOB::upsample::1::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 1,
						"label": "U1"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::upsample::2::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 1,
						"label": "U2"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::upsample::3::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 1,
						"label": "U3"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::upsample::4::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 1,
						"label": "U4"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::reroll::0::3eaa7c0c-9825-4110-9c89-02c4e463a8d0::SOLO",
						"style": 2,
						"emoji": {
							"name": "🔄"
						}
					}
				]
			},
			{
				"type": 1,
				"components": [
					{
						"type": 2,
						"custom_id": "MJ::JOB::variation::1::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 2,
						"label": "V1"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::variation::2::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 2,
						"label": "V2"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::variation::3::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 2,
						"label": "V3"
					},
					{
						"type": 2,
						"custom_id": "MJ::JOB::variation::4::3eaa7c0c-9825-4110-9c89-02c4e463a8d0",
						"style": 2,
						"label": "V4"
					}
				]
			}
		],
		"message_reference": {
			"channel_id": "1008571020480876554",
			"message_id": "1131713484078461018",
			"guild_id": "662267976984297473"
		}
	}
}
```

### Discord server members

```json
{
	"id": "211868139443453952",
	"bot": false,
	"system": false,
	"flags": 0,
	"connectedAccounts": [],
	"premiumSince": null,
	"premiumGuildSince": null,
	"bio": null,
	"pronouns": null,
	"application": null,
	"username": "notani.",
	"globalName": "-Ani-",
	"discriminator": "0",
	"avatar": null,
	"avatarDecoration": null,
	"createdTimestamp": 1470583700763,
	"defaultAvatarURL": "https://cdn.discordapp.com/embed/avatars/3.png",
	"tag": "notani.",
	"avatarURL": null,
	"displayAvatarURL": "https://cdn.discordapp.com/avatars/211868139443453952/1019233d0aec84e3472a25eeabfa26bb.webp",
	"guildId": "797239171730505839",
	"joinedTimestamp": 1653433130270,
	"premiumSinceTimestamp": null,
	"nickname": null,
	"pending": false,
	"communicationDisabledUntilTimestamp": null,
	"userId": "211868139443453952",
	"displayName": "-Ani-",
	"roles": [
		"797239171730505839"
	]
}
```

# Changelog

This Actor's version history is a separate document: https://apify.com/curious_coder/discord-data-scraper/changelog.md

# Actor input Schema

## `token` (type: `string`):

Token used to authenticate your discord account. Read the actor's information page to learn how to get the token

## `action` (type: `string`):

Actor will decide what kind of data it needs to scrape and from where it should scrape it based on selected action

## `scrapeMessages.channelUrl` (type: `string`):

Click on the required discord group, then right click on a channel in the group. Click 'Copy Link' option

## `cursor` (type: `string`):

Use this field if you want to resume scraping from where the scraper stopped last time. You can find this value in default storage of scraper runs under **cursor** key

## `scrapeChannelMembers.channelUrl` (type: `string`):

Click on the required discord group, then right click on a channel in the group. Click 'Copy Link' option

## `count` (type: `integer`):

Leave this field empty if you want to scrape all items data

## `proxy` (type: `object`):

You can use proxy from your account's country if needed for extra safety.

## `minDelay` (type: `integer`):

Minimum duration in seconds to wait before scraping next page

## `maxDelay` (type: `integer`):

Maximum duration in seconds to wait before scraping next page

## Actor input object example

```json
{
  "action": "scrapeMessages",
  "scrapeMessages.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
  "scrapeChannelMembers.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
  "minDelay": 1,
  "maxDelay": 3
}
```

# 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 = {
    "action": "scrapeMessages",
    "scrapeMessages.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
    "scrapeChannelMembers.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
    "minDelay": 1,
    "maxDelay": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("curious_coder/discord-data-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 = {
    "action": "scrapeMessages",
    "scrapeMessages.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
    "scrapeChannelMembers.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
    "minDelay": 1,
    "maxDelay": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("curious_coder/discord-data-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "action": "scrapeMessages",
  "scrapeMessages.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
  "scrapeChannelMembers.channelUrl": "https://discord.com/channels/662267976984297473/976997370132848640",
  "minDelay": 1,
  "maxDelay": 3
}' |
apify call curious_coder/discord-data-scraper --silent --output-dataset

```

## MCP server setup

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

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

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/AxFvOpSpBwSnI0Iyy/builds/1L9TmDKbijWrh0Aei/openapi.json
