Skip to main content
Unkey provides two TypeScript packages:
  • @unkey/api: Manage keys, APIs, and rate limits (server-side, requires root key)
  • @unkey/ratelimit: Standalone rate limiting (server-side, requires root key)
For framework-specific wrappers, see @unkey/nextjs and @unkey/hono.

Installation

Quick Start

Initialize the client

Never expose your root key in client-side code. These SDKs are for server-side use only.

Verify an API Key

The most common operation, check if a user’s API key is valid:

Verification response

Check permissions during verification


Create API Keys

Issue new keys for your users:
The full API key is only returned once at creation. Unkey stores only a hash. Make sure to display it to your user immediately.

Update Keys

Modify an existing key’s configuration:

Delete Keys

Permanently revoke a key:
Or disable temporarily (can re-enable later):

Rate Limiting

Use @unkey/ratelimit for standalone rate limiting:

Cost-based rate limiting

Expensive operations can consume more of the limit:

Error Handling

Use try/catch to handle errors:

Resilient verification

For production, handle edge cases:

TypeScript Types

The SDK is fully typed. Import types as needed:

Framework Guides

Next.js

withUnkey wrapper for API routes

Hono

Middleware for Hono apps

Express Quickstart

Step-by-step Express guide

Bun Quickstart

Step-by-step Bun guide

Full Reference

GitHub

Complete auto-generated API reference
Last modified on May 6, 2026