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-typesVerified import paths — ran on the pinned version, not inferred.
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.
Update any references from `RESTJSONErrorCodes.ChannelSendRateLimit` to `RESTJSONErrorCodes.ChannelWriteRateLimit`.
Ensure your code handles `recipient_id` as a `Snowflake` string type, rather than potentially an incorrect previous type.
Review usages of channel PATCH payloads and add appropriate null checks or optional chaining (`?.`) where fields are now correctly marked as nullable.
Check how `timestamp` from `GatewayInviteCreateDispatchData` is parsed or used to ensure compatibility with the updated type.
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.
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.
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.
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.
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`).
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.No dependency data recorded yet.