SDKs Overview
Official RevKeen SDK libraries for TypeScript, Python, and PHP
RevKeen provides official SDK libraries to make API integration easier. Our SDKs are auto-generated from our OpenAPI 3.1 specification using Fern, ensuring they're always up-to-date and type-safe.
Available SDKs
Why Use an SDK?
Full TypeScript types and Python type hints for all API operations. Catch errors at compile time.
Built-in retry logic with exponential backoff for transient errors.
Easily iterate through paginated results with auto-pagination.
Built-in helpers to verify webhook signatures.
Structured error types for better error handling.
Quick Comparison
| Feature | TypeScript | Python | PHP |
|---|---|---|---|
| Package | @revkeen/sdk | revkeen | revkeen/sdk-php |
| Version | 1.x | 1.x | 1.x |
| Async | Promises | async/await | Sync + Guzzle |
| Types | TypeScript | Type hints | PHP 8.1+ types |
| Runtime | Node.js 18+, Deno, Bun | Python 3.8+ | PHP 8.1+ |
Installation
npm install @revkeen/sdkBasic Usage
import RevKeen from '@revkeen/sdk';
const client = new RevKeen({
apiKey: process.env.REVKEEN_API_KEY,
});
// List customers
const customers = await client.customers.list();
// Create a customer
const customer = await client.customers.create({
email: 'john@example.com',
name: 'John Doe',
});
// Create a subscription
const subscription = await client.subscriptions.create({
customerId: customer.data.id,
productId: 'prod_xxxxxxxx',
});SDK Features
Auto-Pagination
Easily iterate through all results:
// Iterate through all customers
for await (const customer of client.customers.list()) {
console.log(customer.id, customer.email);
}
// Or get all at once
const allCustomers = await client.customers.list().all();Error Handling
import RevKeen, {
RevKeenError,
NotFoundError,
ValidationError,
RateLimitError
} from '@revkeen/sdk';
try {
const customer = await client.customers.retrieve('invalid');
} catch (error) {
if (error instanceof NotFoundError) {
console.log('Customer not found');
} else if (error instanceof ValidationError) {
console.log('Validation failed:', error.details);
} else if (error instanceof RateLimitError) {
console.log('Rate limited, retry after:', error.retryAfter);
} else if (error instanceof RevKeenError) {
console.log('API error:', error.message);
}
}Webhook Verification
import { verifyWebhook } from '@revkeen/sdk/webhooks';
app.post('/webhooks', async (req, res) => {
const payload = req.body;
const signature = req.headers['x-revkeen-signature'];
const event = verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET);
// Handle the verified event
switch (event.type) {
case 'invoice.paid':
await handleInvoicePaid(event.data);
break;
}
res.json({ received: true });
});Configuration Options
const client = new RevKeen({
apiKey: 'rk_live_xxx',
// Optional configurations
baseUrl: 'https://api.revkeen.com', // Custom base URL
timeout: 30000, // Request timeout (ms)
maxRetries: 3, // Max retry attempts
httpAgent: customAgent, // Custom HTTP agent
});Next Steps
Interactive API Reference
Explore our complete API with interactive examples, try requests directly from the documentation, and generate code snippets for multiple languages.