{"id":13072,"library":"discord-api-types","title":"Discord API Types","description":"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.","status":"active","version":"0.38.47","language":"javascript","source_language":"en","source_url":"https://github.com/discordjs/discord-api-types","tags":["javascript","discord","discord api","types","discordjs"],"install":[{"cmd":"npm install discord-api-types","lang":"bash","label":"npm"},{"cmd":"yarn add discord-api-types","lang":"bash","label":"yarn"},{"cmd":"pnpm add discord-api-types","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Import types using `import type` for compile-time safety. All primary API types are under versioned subpaths (e.g., `/v10`).","wrong":"import { APIGuild } = require('discord-api-types/v10')","symbol":"APIGuild","correct":"import type { APIGuild } from 'discord-api-types/v10'"},{"note":"REST API routes are exported directly from the versioned subpath. Ensure you're using the correct API version (e.g., `v10`).","wrong":"import { Routes } from 'discord-api-types'","symbol":"Routes","correct":"import { Routes } from 'discord-api-types/v10'"},{"note":"Gateway event types and enumerations are found under the respective API version subpath.","symbol":"GatewayDispatchEvents","correct":"import { GatewayDispatchEvents } from 'discord-api-types/v10'"},{"note":"Error codes for REST API responses are also versioned.","symbol":"RESTJSONErrorCodes","correct":"import { RESTJSONErrorCodes } from 'discord-api-types/v10'"}],"quickstart":{"code":"import type { APIGuild, APITextChannel, RESTPostAPIChannelMessageJSONBody, MessageFlags } from 'discord-api-types/v10';\nimport { ChannelType, Routes } from 'discord-api-types/v10';\n\ninterface MyGuild extends APIGuild {\n  channels: APITextChannel[];\n}\n\nconst sampleGuild: MyGuild = {\n  id: '123456789012345678',\n  name: 'My Awesome Guild',\n  owner_id: '987654321098765432',\n  verification_level: 0,\n  explicit_content_filter: 0,\n  default_message_notifications: 0,\n  mfa_level: 0,\n  features: [],\n  channels: [\n    {\n      id: '111222333444555666',\n      type: ChannelType.GuildText,\n      guild_id: '123456789012345678',\n      name: 'general',\n      position: 0\n    }\n  ]\n};\n\nconst messagePayload: RESTPostAPIChannelMessageJSONBody = {\n  content: 'Hello, Discord API Types!',\n  tts: false,\n  flags: MessageFlags.SuppressEmbeds\n};\n\nconsole.log(`Guild name: ${sampleGuild.name}`);\nconsole.log(`Example Channel ID: ${sampleGuild.channels[0].id}`);\nconsole.log(`Message content: ${messagePayload.content}`);\nconsole.log(`API Route for creating a channel: ${Routes.guildChannels(sampleGuild.id)}`);\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Update any references from `RESTJSONErrorCodes.ChannelSendRateLimit` to `RESTJSONErrorCodes.ChannelWriteRateLimit`.","message":"The `RESTJSONErrorCodes.ChannelSendRateLimit` enum member was renamed to `RESTJSONErrorCodes.ChannelWriteRateLimit` to better reflect its purpose.","severity":"breaking","affected_versions":">=0.38.47"},{"fix":"Ensure your code handles `recipient_id` as a `Snowflake` string type, rather than potentially an incorrect previous type.","message":"The type of `DMRecipient.recipient_id` was changed to `Snowflake` (string) to correctly align with Discord's API specification.","severity":"breaking","affected_versions":">=0.38.45"},{"fix":"Review usages of channel PATCH payloads and add appropriate null checks or optional chaining (`?.`) where fields are now correctly marked as nullable.","message":"The 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.","severity":"breaking","affected_versions":">=0.38.43"},{"fix":"Check how `timestamp` from `GatewayInviteCreateDispatchData` is parsed or used to ensure compatibility with the updated type.","message":"The type for the `timestamp` property in `GatewayInviteCreateDispatchData` was updated. Verify your handling of this timestamp if you process Gateway invite create events.","severity":"breaking","affected_versions":">=0.38.43"},{"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.","message":"Due 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Ensure 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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"A property was either removed, renamed, or added to a Discord API type, and your code is attempting to access a non-existent property.","error":"Property 'x' does not exist on type 'APISomeType'."},{"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.","cause":"The type of a Discord API field or an enum member has changed, or you are assigning an incorrect value type.","error":"Type 'SomeValue' is not assignable to type 'AnotherValue'."},{"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`).","cause":"TypeScript cannot resolve the module path, typically due to incorrect `tsconfig.json` settings, especially with `moduleResolution` or if the package is not installed.","error":"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'?"},{"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.","cause":"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.","error":"Cannot find name 'APISomeType'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}