Registry / communication / discord-api-types

discord-api-types

JSON →
library0.38.47jsnpmunverified

discord-api-types provides comprehensive TypeScript definitions for the Discord API, covering various data structures, enumerators, and REST endpoints. Maintained by the Discord.js team, it is essential for developing Discord bots, clients, and tools with robust type safety. The package is currently at version 0.38.47 (as of April 2026) and receives frequent updates, often multiple times a month, to promptly reflect changes and additions to the official Discord API specification. Its key differentiator is its close alignment with Discord's rapidly evolving API, offering up-to-date and accurate type definitions that are critical for libraries built on top of the Discord API, such as discord.js itself. This package aims to be a single, reliable source of truth for Discord's API structure, facilitating more robust and error-resistant development.

npm install discord-api-types
INSTALL
IMPORT
SIG · DISCORD-API-TYPES
D
discord-api-types
communicationjavascriptv0.38.47
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

APIGuild
✓ import type { APIGuild } from 'discord-api-types/v10'
✗ import { APIGuild } = require('discord-api-types/v10')
Import types using `import type` for compile-time safety. All primary API types are under versioned subpaths (e.g., `/v10`).
Routes
✓ import { Routes } from 'discord-api-types/v10'
✗ import { Routes } from 'discord-api-types'
REST API routes are exported directly from the versioned subpath. Ensure you're using the correct API version (e.g., `v10`).
GatewayDispatchEvents
✓ import { GatewayDispatchEvents } from 'discord-api-types/v10'
Gateway event types and enumerations are found under the respective API version subpath.
RESTJSONErrorCodes
✓ import { RESTJSONErrorCodes } from 'discord-api-types/v10'
Error codes for REST API responses are also versioned.

This quickstart demonstrates importing and using core API types (APIGuild, APITextChannel) and an enum (ChannelType) to define data structures and compose a message payload. It also shows how to access a specific REST API route.

import type { APIGuild, APITextChannel, RESTPostAPIChannelMessageJSONBody, MessageFlags } from 'discord-api-types/v10'; import { ChannelType, Routes } from 'discord-api-types/v10'; interface MyGuild extends APIGuild { channels: APITextChannel[]; } const sampleGuild: MyGuild = { id: '123456789012345678', name: 'My Awesome Guild', owner_id: '987654321098765432', verification_level: 0, explicit_content_filter: 0, default_message_notifications: 0, mfa_level: 0, features: [], channels: [ { id: '111222333444555666', type: ChannelType.GuildText, guild_id: '123456789012345678', name: 'general', position: 0 } ] }; const messagePayload: RESTPostAPIChannelMessageJSONBody = { content: 'Hello, Discord API Types!', tts: false, flags: MessageFlags.SuppressEmbeds }; console.log(`Guild name: ${sampleGuild.name}`); console.log(`Example Channel ID: ${sampleGuild.channels[0].id}`); console.log(`Message content: ${messagePayload.content}`); console.log(`API Route for creating a channel: ${Routes.guildChannels(sampleGuild.id)}`);
Debug
Known issues
breakingThe `RESTJSONErrorCodes.ChannelSendRateLimit` enum member was renamed to `RESTJSONErrorCodes.ChannelWriteRateLimit` to better reflect its purpose.
fix
Update any references from `RESTJSONErrorCodes.ChannelSendRateLimit` to `RESTJSONErrorCodes.ChannelWriteRateLimit`.
affects: >=0.38.47
breakingThe type of `DMRecipient.recipient_id` was changed to `Snowflake` (string) to correctly align with Discord's API specification.
fix
Ensure your code handles `recipient_id` as a `Snowflake` string type, rather than potentially an incorrect previous type.
affects: >=0.38.45
breakingThe nullability of certain fields in `APIPatchGuildChannel` and other channel-related PATCH endpoints was corrected. This may cause type errors if your code relied on previously implicitly non-nullable fields becoming nullable.
fix
Review usages of channel PATCH payloads and add appropriate null checks or optional chaining (`?.`) where fields are now correctly marked as nullable.
affects: >=0.38.43
breakingThe type for the `timestamp` property in `GatewayInviteCreateDispatchData` was updated. Verify your handling of this timestamp if you process Gateway invite create events.
fix
Check how `timestamp` from `GatewayInviteCreateDispatchData` is parsed or used to ensure compatibility with the updated type.
affects: >=0.38.43
gotchaDue to Discord's API evolving rapidly, this package receives very frequent updates. Neglecting to update `discord-api-types` can lead to type mismatches and compile-time errors when interacting with newer API features or even existing ones that have been refined.
fix
Regularly update `discord-api-types` and your Discord library (e.g., `discord.js`) in sync to ensure type consistency. Run `npm update discord-api-types` or `yarn upgrade discord-api-types` frequently.
affects: All
gotchaEnsure the version of `discord-api-types` you are using is compatible with your `discord.js` version or any other Discord library. Mismatched versions can lead to compile errors as underlying API types may differ.
fix
Refer to the `discord.js` documentation or changelog for the recommended `discord-api-types` version. Typically, they are kept in close synchronization by the Discord.js team.
affects: All
Errors
Common errors & fixes
Property 'x' does not exist on type 'APISomeType'.
A property was either removed, renamed, or added to a Discord API type, and your code is attempting to access a non-existent property.
fix
Check the `discord-api-types` changelog and the official Discord API documentation for the latest type definitions. Update your code to reflect the current structure or handle optional properties. Consider updating the package itself.
Type 'SomeValue' is not assignable to type 'AnotherValue'.
The type of a Discord API field or an enum member has changed, or you are assigning an incorrect value type.
fix
Review the type definition in `discord-api-types` for the specific field. Adjust the value or expression to match the expected type. This often happens with number vs. string for IDs, or changes in enum variants.
Cannot find module 'discord-api-types/v10'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add a 'paths' mapping in 'tsconfig.json'?
TypeScript cannot resolve the module path, typically due to incorrect `tsconfig.json` settings, especially with `moduleResolution` or if the package is not installed.
fix
Ensure `discord-api-types` is installed (`npm install discord-api-types`). For modern module resolution, set `"moduleResolution": "bundler"` or `"nodenext"` in your `tsconfig.json`. Also, verify you're importing from the correct versioned subpath (e.g., `/v10`).
Cannot find name 'APISomeType'.
The type or interface was not correctly imported, or you might be trying to access a type that has been moved or removed from the public API.
fix
Verify that `APISomeType` is correctly exported and imported using `import type { APISomeType } from 'discord-api-types/v10';`. Check the changelog if it's a type you've used before to see if it was renamed or removed.
Upgrade
Version history
0.38.47latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
discord-api-types — npm install discord-api-types · libregistry