Welcome to DiscordKit
DiscordKit is a powerful TypeScript SDK for Discord’s API that provides type-safe request handlers, built-in input validation with Valibot, and first-class support for React Query and tRPC.Why DiscordKit?
DiscordKit stands out by offering multiple integration patterns for the same Discord API endpoints, allowing you to choose the approach that best fits your application architecture.Type-Safe by Default
Built with TypeScript and Valibot schemas for compile-time and runtime type safety across all Discord API endpoints.
Multiple Integration Patterns
Use vanilla request handlers, React Query hooks, or tRPC procedures - all generated from the same source.
Automatic Rate Limiting
Built-in rate limit handling with automatic request queuing, retry logic, and global/per-route limit tracking.
Input Validation
Every endpoint includes Valibot schemas to validate inputs before making requests, preventing common API errors.
Available Exports per Endpoint
For each Discord API endpoint, DiscordKit exports four complementary functions. Here’s an example using the Get Guild endpoint:All
GET endpoints export query functions for React Query, while mutation endpoints (POST, PATCH, DELETE) export appropriate mutation handlers.Feature Highlights
Comprehensive API Coverage
DiscordKit covers all major Discord API resources:- Guilds - Server management, roles, channels, members
- Users - User profiles, relationships, connections
- Channels - Messages, threads, permissions
- Applications - Commands, interactions, webhooks
- Voice - Voice regions, channels
- And more - Auto-moderation, events, stickers, polls, entitlements
Built-in Rate Limiting
The DiscordSession class automatically handles:- Global rate limits (50 requests/second)
- Per-route rate limit buckets
- Automatic retry with exponential backoff
- Invalid request tracking to prevent temporary bans
Validation Schemas
Every endpoint includes Valibot schemas for:- Request input validation
- Response validation
- Type inference
- Runtime safety
Quick Example
Here’s how simple it is to fetch a Discord guild:Get Started
Installation
Install DiscordKit and its peer dependencies
Quickstart
Make your first API call in minutes
Open Source
DiscordKit is open source and released under the MIT license. Contributions, issues, and feedback are welcome on GitHub.Endpoint documentation is sourced from Discord’s Official API Documentation.