Unkey is an open-source API key management platform. It handles API key creation, validation, rate limiting, and analytics — all with a generous free tier and sub-millisecond validation at the edge.
What Makes Unkey Special?
- Free tier — 1,000 active keys, 150K validations/month
- Edge validation — sub-millisecond key verification globally
- Rate limiting — built-in, per-key rate limits
- Temporary keys — auto-expiring API keys
- Analytics — usage tracking per key
The Hidden API: Key Management
import { Unkey } from '@unkey/api';
const unkey = new Unkey({ rootKey: process.env.UNKEY_ROOT_KEY });
// Create an API key with rate limiting
const { result } = await unkey.keys.create({
apiId: 'api_xxx',
prefix: 'sk_live',
name: 'Production Key - Acme Corp',
meta: { customerId: 'cus_123', plan: 'pro' },
ratelimit: {
type: 'fast',
limit: 100,
refillRate: 10,
refillInterval: 1000
},
expires: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days
remaining: 10000 // usage limit
});
console.log('Key:', result.key); // sk_live_xxx
// Verify a key (edge-fast)
const { result: verification } = await unkey.keys.verify({
key: 'sk_live_xxx'
});
if (verification.valid) {
console.log('Remaining:', verification.remaining);
console.log('Meta:', verification.meta); // { customerId, plan }
}
Rate Limiting API
// Apply rate limiting to any identifier (not just API keys)
const { result } = await unkey.ratelimits.limit({
namespace: 'api.requests',
identifier: req.ip,
limit: 60,
duration: 60000 // 60 requests per minute
});
if (!result.success) {
return res.status(429).json({
error: 'Rate limited',
retryAfter: result.reset
});
}
Analytics API
// Get key usage analytics
const analytics = await fetch(
'https://api.unkey.dev/v1/apis.getApi?apiId=api_xxx',
{ headers: { Authorization: `Bearer ${rootKey}` } }
).then(r => r.json());
console.log('Total keys:', analytics.result.keys.total);
console.log('Active keys:', analytics.result.keys.active);
Quick Start
npm install @unkey/api
# Get your root key from https://app.unkey.com
Why API Builders Choose Unkey
A developer shared: "We were hand-rolling API key validation with Redis. Switched to Unkey and deleted 400 lines of code. The free tier handles our current scale, and edge validation is 10x faster than our Redis setup."
Building APIs or need automation tools? Email spinov001@gmail.com or check my developer solutions.
How do you manage API keys? Have you tried Unkey?
Top comments (0)