{
  "openapi": "3.0.1",
  "info": {
    "title": "Discord Message Scraper",
    "description": "Scrape Discord channel and DM messages through Discord's API with your own bot or user token, including content, author, timestamps, attachments, reactions and replies. Works with Apify MCP and the API.",
    "version": "0.1",
    "x-build-id": "6uywAt6jkavWy3Ghq"
  },
  "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",
        "required": [
          "channels"
        ],
        "properties": {
          "discordToken": {
            "title": "Discord token",
            "type": "string",
            "description": "Your Discord authentication token used to read messages via the official API. Provide a bot token (recommended — create one at discord.com/developers, give it the 'Read Message History' permission, and add it to the target server) or a user token. Stored as a secret and never written to logs. This is NOT your account password and NOT a server invite link."
          },
          "tokenType": {
            "title": "Token type",
            "enum": [
              "bot",
              "user"
            ],
            "type": "string",
            "description": "Whether the token above is a bot token or a user token. Bot tokens are the legitimate, Discord-sanctioned path and only read channels the bot was added to. User tokens (self-botting) can read any channel the account already sees but VIOLATE Discord's Terms of Service and can get the account banned — use at your own risk. Defaults to 'bot'.",
            "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"
            }
          },
          "maxMessagesPerChannel": {
            "title": "Max messages per channel",
            "minimum": 1,
            "maximum": 1000000,
            "type": "integer",
            "description": "Upper bound on how many messages to return for each channel, counted after filters are applied. The scraper pages newest-first until this cap, the channel's history ends, or the date/ID range is exceeded. Defaults to 1000. Lower it to control cost — total cost is roughly channels x this number x $0.0005.",
            "default": 1000
          },
          "newestFirst": {
            "title": "Newest first",
            "type": "boolean",
            "description": "Output order within each channel. True returns newest messages first (Discord's native order); false reverses each channel's batch to oldest-first chronological order. Does not change which messages are returned, only their order in the dataset. Defaults to true.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}