{
  "openapi": "3.0.1",
  "info": {
    "title": "Discord Message Scraper",
    "description": "Scrape Discord channels, whole servers and threads with your own bot token via the official API. Messages, authors, attachments, reactions, replies, new-messages-only mode. MCP-ready.",
    "version": "0.2",
    "x-build-id": "1n1e7TDuDU6Wdi3AV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/khadinakbar~discord-message-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-khadinakbar-discord-message-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-message-scraper/runs": {
      "post": {
        "operationId": "runs-sync-khadinakbar-discord-message-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-message-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-khadinakbar-discord-message-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",
        "properties": {
          "discordToken": {
            "title": "Discord token",
            "type": "string",
            "description": "Your Discord BOT token (Developer Portal → your application → Bot → Reset Token). Stored as a secret, never logged. Needs the bot to be added to your server with View Channel + Read Message History, and 'Message Content Intent' switched on or message text comes back empty. NOT your account password, NOT a user token, NOT an invite link."
          },
          "accessMode": {
            "title": "Access mode",
            "enum": [
              "bot"
            ],
            "type": "string",
            "description": "How the Actor reads Discord. Only 'bot' is supported: your own bot token, read through Discord's official API. User tokens (self-bots) are not allowed because they break Discord's rules.",
            "default": "bot"
          },
          "channels": {
            "title": "Channel IDs or URLs",
            "type": "array",
            "description": "One or more Discord channels to scrape. Accepts a raw channel ID (e.g. '112233445566778899') or a full channel/message URL (e.g. 'https://discord.com/channels/9988.../1122...'). Enable Developer Mode in Discord, then right-click a channel and 'Copy Channel ID'. This is the channel, NOT a server invite or a guild ID.",
            "items": {
              "type": "string"
            }
          },
          "serverIds": {
            "title": "Server IDs or URLs (whole server)",
            "type": "array",
            "description": "Optional. Scrape every text channel the bot can read in these servers, plus threads if 'Include threads' is on. Accepts a server ID (e.g. '998877665544332211') or any discord.com/channels/<server>/... URL. Enable Developer Mode in Discord, right-click the server icon, 'Copy Server ID'. Use this OR Channel IDs, or both.",
            "items": {
              "type": "string"
            }
          },
          "includeThreads": {
            "title": "Include threads and forum posts",
            "type": "boolean",
            "description": "When true (default), also read active and archived public threads (and forum posts) under the channels/servers above. Each thread is returned as its own channel with isThread true and its parent channel name.",
            "default": true
          },
          "maxMessagesPerChannel": {
            "title": "Max messages per channel",
            "minimum": 1,
            "maximum": 1000000,
            "type": "integer",
            "description": "Upper bound of messages returned for each channel or thread, counted after filters. Default 100 keeps a first test small and cheap. Raise it for full history — total cost is roughly channels x this number x the per-message price.",
            "default": 100
          },
          "maxMessagesTotal": {
            "title": "Max messages in total (optional)",
            "minimum": 0,
            "maximum": 100000000,
            "type": "integer",
            "description": "Hard stop for the whole run across all channels. 0 or empty means no total cap. Use it with 'whole server' runs so cost can never surprise you.",
            "default": 0
          },
          "sinceLastRun": {
            "title": "Only new messages since last run",
            "type": "boolean",
            "description": "When true, the Actor remembers the newest message it saw in each channel (in your own account's storage) and on the next run with the same 'State name' returns only newer messages, oldest first. First run behaves normally. Great for scheduled monitoring.",
            "default": false
          },
          "stateKey": {
            "title": "State name",
            "type": "string",
            "description": "Name for the saved position used by 'Only new messages since last run'. Use different names for different jobs (e.g. 'support-channels'). Default 'default'.",
            "default": "default"
          },
          "concurrency": {
            "title": "Parallel channels",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "How many channels to read at the same time (1-10, default 4). Discord's rate limits are respected automatically; higher is faster for big servers but gains stop once Discord throttles.",
            "default": 4
          },
          "newestFirst": {
            "title": "Newest first",
            "type": "boolean",
            "description": "Output order within each channel. True (default) = newest first (Discord's native order). False = oldest first; this holds up to 20,000 messages per channel in memory. With 'Only new messages since last run' on later runs, output is always oldest first.",
            "default": true
          },
          "beforeDate": {
            "title": "Before date (optional)",
            "type": "string",
            "description": "Only return messages posted strictly before this moment. Accepts any ISO 8601 date or datetime, e.g. '2024-12-31' or '2024-12-31T23:59:59Z'. Acts as the upper bound / pagination start point. Leave empty to start from the most recent message."
          },
          "afterDate": {
            "title": "After date (optional)",
            "type": "string",
            "description": "Only return messages posted strictly after this moment. Accepts any ISO 8601 date or datetime, e.g. '2024-01-01'. Acts as the lower bound — paging stops once messages older than this are reached. Leave empty for no lower bound."
          },
          "beforeMessageId": {
            "title": "Before message ID (optional)",
            "type": "string",
            "description": "Only return messages older than this message snowflake ID (exclusive). Takes precedence over 'Before date' when both are set. Example: '1180000000000000000'. Use it to resume a previous scrape exactly where it stopped."
          },
          "afterMessageId": {
            "title": "After message ID (optional)",
            "type": "string",
            "description": "Only return messages newer than this message snowflake ID (exclusive). Takes precedence over 'After date' when both are set. Example: '1170000000000000000'. Use it for incremental scrapes that only pick up new messages."
          },
          "filterFromUserId": {
            "title": "Only from user ID (optional)",
            "type": "string",
            "description": "Keep only messages authored by this Discord user ID. Example: '223344556677889900'. Right-click a user with Developer Mode on and 'Copy User ID'. This is a user ID, NOT a username or display name."
          },
          "filterContains": {
            "title": "Contains text (optional)",
            "type": "string",
            "description": "Keep only messages whose content includes this substring (case-insensitive). Example: 'giveaway'. Matching happens client-side after fetching, so it does not reduce the number of API calls. Leave empty to keep all messages."
          },
          "onlyWithAttachments": {
            "title": "Only messages with attachments",
            "type": "boolean",
            "description": "When true, keep only messages that have at least one file/image/video attachment. Useful for harvesting media URLs. Defaults to false (all messages kept).",
            "default": false
          },
          "responseFormat": {
            "title": "Response format",
            "enum": [
              "detailed",
              "concise"
            ],
            "type": "string",
            "description": "Shape of each output record. 'detailed' (default) includes the full attachments, reactions, mentions, and sticker arrays. 'concise' keeps only counts (attachmentCount, reactionCount, embedCount) for a smaller, token-efficient payload — ideal for LLM/agent consumption.",
            "default": "detailed"
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}