Packages
- @unkey/api — Manage keys, APIs, and rate limits (requires root key)
- @unkey/ratelimit — Standalone rate limiting (requires root key)
Installation
Both packages support CommonJS and ES Modules. Compatible with Node.js 18+, Deno 1.25+, Bun 1.0+, Cloudflare Workers, and edge runtimes.
Initialization
Initialize the API client
Initialize the rate limiter
Verify API Keys
The most common operation — validate a user’s API key:Verification Response
Thedata object contains:
Verify with Permission Check
Create API Keys
Issue new keys for your users:Create Key with Permissions
Update Keys
Modify an existing key’s configuration:Delete Keys
Permanently revoke a key:Rate Limiting
Using @unkey/ratelimit
Standalone rate limiting without API keys:Cost-Based Rate Limiting
Expensive operations can consume more of the limit:Duration Options
Rate Limit Response
Error Handling
Use try/catch for error handling:Production-Ready Verification
TypeScript Types
The SDK is fully typed. Import types as needed:Framework Integration
Next.js
Use the @unkey/nextjs wrapper:Hono
Use the @unkey/hono middleware:Express
Cloudflare Workers
Advanced Usage
Managing APIs
Create and manage API namespaces:Identity Management
Link keys to your users:Custom Caching
Reduce latency with caching:Complete Examples
E-commerce API with Usage Limits
GitHub Repository
@unkey/api on GitHub
Complete auto-generated API reference and source code
Next Steps
Next.js SDK
Framework wrapper for Next.js
Hono SDK
Middleware for Hono apps
Rate Limiting Guide
Advanced rate limiting features
API Reference
REST API documentation