# Discord Channel Messages Scraper (`felt/discord-message-scraper`) Actor

Scraping messages from Discord channels.

- **URL**: https://apify.com/felt/discord-message-scraper.md
- **Developed by:** [FELT Labs](https://apify.com/felt) (community)
- **Categories:** Social media, Automation, News
- **Features:** Limited permissions
- **Stats:** 140 total users, 7 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

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

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

## Discord Message Scraper

The **Discord Message Scraper** is a powerful tool for extracting structured message data from Discord channels. Whether you're conducting community research, performing content analysis, or archiving conversations, this scraper delivers comprehensive Discord channel data with precision and reliability.

### What Does This Actor Do?

This Actor allows you to:

1. **Extract Complete Channel Histories**
   - Scrape entire Discord channel message histories with full message data
   - Access messages from any channel you have permission to view

2. **Filter by Date and Message Range**
   - Set a starting date (`fromDate`) to extract messages from a specific time period
   - Use message ID cutoffs (`toMessageId`) for precise pagination control
   - Perfect for incremental scraping or updating existing datasets

3. **Retrieve Rich Message Data**
   - **Content**: Full message text and formatting
   - **Author Details**: Username, user ID, and profile information
   - **Timestamps**: Creation and edit times for chronological analysis
   - **Media & Attachments**: Images, videos, files, and embedded content
   - **Engagement**: Reactions, mentions, and interaction data
   - **Metadata**: Message IDs, channel IDs, and thread information

4. **Automated Pagination**
   - Handles Discord's API pagination automatically
   - Configurable batch sizes (default: 50 messages per request)
   - Built-in rate limiting (5-second delays) to respect Discord's API limits

5. **Structured JSON Output**
   - Clean, organized data exported to Apify datasets
   - Easy integration with downstream analysis tools
   - Ready for data science, sentiment analysis, or archival purposes

### How to Run This Actor

1. **Get Your Discord Token** (see detailed instructions below)
2. **Configure Input Parameters**:
   - Paste the Discord channel URL you want to scrape
   - Add your Discord token for authentication
   - Set optional filters like date range and message limits
3. **Run the Actor** and retrieve your data from the dataset

The Actor will automatically handle pagination, rate limiting, and data extraction, delivering structured JSON output ready for analysis.

### Input Parameters

| Parameter             | Type   | Description                                                                      | Example                                                              |
| --------------------- | ------ | -------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `channelUrl`          | string | Discord channel URL to scrape (must have access permissions)                     | <https://discord.com/channels/927873274136891392/927873274136891398> |
| `discordToken`        | string | Your Discord authentication token (required for API access)                      | Personal Discord token                                               |
| `maxMessagesPerCrawl` | number | Maximum number of messages to extract (vale between 1 and 100000)                | `1000`                                                               |
| `fromDate`            | string | Earliest message date to scrape (format: `YYYY-MM-DD`). Use 'none' for no limit  | `'2025-01-15'` (optional)                                            |
| `toMessageId`         | string | Message ID to start scraping before (useful for pagination and incremental runs) | `'1437533170466689165'` (optional)                                   |

### How to Get Your Discord Token

To use this Actor, you need a valid Discord authentication token. Follow these steps:

1. **Login to Discord** using Google Chrome or any Chromium-based browser
2. **Open Developer Tools** (Menu > More tools > Developer tools, or press `F12`)
3. **Navigate to the Console Tab**
4. **Paste the following code** and press ENTER:

```javascript
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');
```

5. You should see **"Worked!"** displayed in large text - your token is now copied to your clipboard!

**Security Note**: Keep your Discord token private. Anyone with your token can access your Discord account. Never share it publicly or commit it to version control.

### Output Format

The scraped data is organized in clean, structured JSON format with complete Discord API message data. Each message includes:

- **Message Content**: Full text, formatting, and embedded content
- **Author Information**: Username, discriminator, user ID, avatar URL
- **Timestamps**: Message creation time, last edit time
- **Media Assets**: Attachment URLs, embedded images, videos, and files
- **Engagement Metrics**: Reactions (emoji, count), mentions, replies
- **Metadata**: Message ID, channel ID, server ID, message type
- **Thread Data**: Parent message IDs, thread membership

### Use Cases

- **Community Research**: Analyze discussion patterns, engagement trends, and user behavior
- **Content Analysis**: Extract conversations for sentiment analysis or topic modeling
- **Moderation Insights**: Review historical messages for policy enforcement or community health
- **Data Archival**: Backup important channel conversations and community knowledge
- **Marketing Research**: Track brand mentions, product feedback, and customer sentiment

### Request New Features

We're continuously improving this scraper to meet your needs! If you have feature requests, suggestions, or encounter issues, please reach out through the Apify platform. Your feedback helps us enhance the Actor for the entire community.

***

**Start scraping today and unlock powerful insights from Discord communities!**

***

# Actor input Schema

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

URL of discord channel

## `discordToken` (type: `string`):

Discord user or bot token used in the Authorization header.

## `fromDate` (type: `string`):

Optional: Stop fetching messages older than this date (format YYYY-MM-DD).

## `toMessageId` (type: `string`):

Optional: Discord message ID to start fetching messages before (pagination).

## `maxMessagesPerCrawl` (type: `integer`):

Maximum number of messages that can be fetched by this crawler.

## Actor input object example

```json
{
  "channelUrl": "https://discord.com/channels/927873274136891392/927873274136891398",
  "fromDate": "",
  "toMessageId": "",
  "maxMessagesPerCrawl": 1000
}
```

# 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 = {
    "channelUrl": "https://discord.com/channels/927873274136891392/927873274136891398"
};

// Run the Actor and wait for it to finish
const run = await client.actor("felt/discord-message-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 = { "channelUrl": "https://discord.com/channels/927873274136891392/927873274136891398" }

# Run the Actor and wait for it to finish
run = client.actor("felt/discord-message-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 '{
  "channelUrl": "https://discord.com/channels/927873274136891392/927873274136891398"
}' |
apify call felt/discord-message-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,felt/discord-message-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/acX2sXnwXOYDP9tEz/builds/k7dfl78MjHyii0Prl/openapi.json
