MCPcopy Index your code
hub / github.com/discordjs/discord-api-types

github.com/discordjs/discord-api-types @0.38.49

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.38.49 ↗ · + Follow
4,800 symbols 4,927 edges 546 files 877 documented · 18% 12 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Discord API Types

discord-api-types

GitHub npm deno Patreon Donate Ko-fi Donate GitHub Sponsors Powered by Vercel

Simple type definitions for the Discord API.

Installation

Install with npm / yarn / pnpm:

npm install discord-api-types
yarn add discord-api-types
pnpm add discord-api-types

Usage

You can only import this module by specifying the API version you want to target. Append /v* to the import path, where the * represents the API version. Below are some examples

const { APIUser } = require('discord-api-types/v10');
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v10';

You may also import just certain parts of the module that you need. The possible values are: globals, gateway, gateway/v*, payloads, payloads/v*, rest, rest/v*, rpc, rpc/v*, utils, utils/v*, voice, and voice/v*. Below are some examples

const { GatewayVersion } = require('discord-api-types/gateway/v10');
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v10';

Note: The v* exports (discord-api-types/v*) include the appropriate version of gateway, payloads, rest, rpc, and utils you specified, alongside the globals exports

Deno

We also provide typings compatible with the deno runtime. You have 3 ways you can import them:

  1. Directly from GitHub
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v10.ts';
  1. From deno.land/x
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types/v10.ts';
  1. From skypack.dev
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v10?dts';

Project Structure

The exports of each API version is split into three main parts:

  • Everything exported with the API prefix represents a payload you may get from the REST API or the Gateway.

  • Everything exported with the Gateway prefix represents data that ONLY comes from or is directly related to the Gateway.

  • Everything exported with the REST prefix represents data that ONLY comes from or is directly related to the REST API.

    • For endpoint options, they will follow the following structure: REST<HTTP Method><Type><Query|(JSON|FormData)Body|Result> where the type represents what it will return.

      • For example, RESTPostAPIChannelMessageJSONBody or RESTGetAPIGatewayBotInfoResult.

      • Some exported types (specifically OAuth2 related ones) may not respect this entire structure due to the nature of the fields. They will start with either RESTOAuth2 or with something similar to REST<HTTP Method>OAuth2

    • If a type ends with Result, then it represents the expected result by calling its accompanying route.

      • Types for a Result that will be a 204 No Content will be typed as undefined. This does not account for errors
  • Anything else that is miscellaneous will be exported based on what it represents (for example the REST route object).

  • There may be types exported that are identical for all versions. These will be exported as is and can be found in the globals file. They will still be prefixed accordingly as described above.

A note about how types are documented: This package will add types only for known and documented properties that are present in Discord's API Documentation repository, that are mentioned in an open pull request, or known through other means and have received the green light to be used. Anything else will not be documented (for example client only types).

With that aside, we may allow certain types that are not documented in the API Documentation repository on a case by case basis. They will be documented with an @unstable tag and are not subject with the same versioning rules.

Extension points exported contracts — how you extend this code

AuditLogChangeData (Interface)
* @internal * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please upda
payloads/v6/auditLog.ts
APIGuildScheduledEventBase (Interface)
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
payloads/v8/guildScheduledEvent.ts
AuditLogChangeData (Interface)
* @internal * @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please upda
deno/payloads/v6/auditLog.ts
MessageReactionRemoveData (Interface)
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
deno/gateway/v8.ts
MessageReactionRemoveData (Interface)
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
gateway/v8.ts
BasePayload (Interface)
* @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8.
gateway/v6.ts
RESTError (Interface)
(no doc)
payloads/common.ts
APIInvite (Interface)
(no doc)
payloads/v9/invite.ts

Core symbols most depended-on inside this repo

fileToESMWrapperCall
called by 7
scripts/versions.mjs
handleClickInstallButton
called by 6
website/src/components/Home/InstallButton/InstallTabs.tsx
formatNumber
called by 4
website/src/utils/Intl.ts
shouldRun
called by 2
eslint.config.ts
isDMInteraction
called by 2
utils/v8.ts
isGuildInteraction
called by 2
utils/v8.ts
isDMInteraction
called by 2
utils/v9.ts
isGuildInteraction
called by 2
utils/v9.ts

Shape

Interface 3,219
Function 954
Enum 626
Method 1

Languages

TypeScript100%

Modules by API surface

rpc/v10.ts278 symbols
deno/rpc/v10.ts278 symbols
rest/v9/index.ts146 symbols
rest/v10/index.ts146 symbols
deno/rest/v9/mod.ts146 symbols
deno/rest/v10/mod.ts146 symbols
gateway/v9.ts84 symbols
gateway/v10.ts84 symbols
deno/gateway/v9.ts84 symbols
deno/gateway/v10.ts84 symbols
rest/v8/index.ts83 symbols
deno/rest/v8/mod.ts83 symbols

For agents

$ claude mcp add discord-api-types \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page