What if managing API keys — creation, revocation, rate limiting, usage analytics — was a single API call instead of a custom database schema?
Unkey is an open-source API key management platform. It handles the entire lifecycle of API keys so you can focus on your product.
Why Unkey
- Key management — create, verify, revoke, expire keys via API
- Rate limiting — per-key rate limits with sliding window
- Usage analytics — track API usage per key automatically
- Temporary keys — auto-expiring keys for trials or sessions
- Remaining uses — keys that auto-revoke after N uses
- Open source — self-host or use the cloud service
- Free tier — 2,500 key verifications/month
Quick Start
npm install @unkey/api
import { Unkey } from "@unkey/api";
const unkey = new Unkey({ rootKey: process.env.UNKEY_ROOT_KEY });
// Create an API key
const { result } = await unkey.keys.create({
apiId: "api_123",
prefix: "sk",
meta: { userId: "user_456", plan: "pro" },
expires: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days
ratelimit: {
type: "fast",
limit: 100,
refillRate: 10,
refillInterval: 1000,
},
});
console.log(result.key); // sk_1234567890abcdef
Verify Keys in Your API
// In your API middleware
const { result } = await unkey.keys.verify({ key: req.headers["x-api-key"] });
if (!result.valid) {
return new Response("Invalid API key", { status: 401 });
}
// Access metadata
const userId = result.meta.userId;
const plan = result.meta.plan;
// Rate limit info
const remaining = result.ratelimit?.remaining; // 95
Real Use Case
A developer built an API product and spent 2 weeks building custom key management — database schema, hashing, rate limiting middleware, usage tracking, admin dashboard. After discovering Unkey, they deleted 1,500 lines of custom code. The entire key management system was replaced by 10 API calls.
When to Use Unkey
- SaaS APIs that need key management
- Metered API products (track usage per customer)
- Trial access with auto-expiring keys
- Rate limiting per API consumer
Get Started
Visit unkey.dev — open source, free tier, TypeScript-first.
Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.
Top comments (0)