DevelopersSDKs
SDKs
Official client 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 are always up-to-date and type-safe.
Available SDKs
TypeScript / JavaScript
@revkeen/sdk on npm -- For Node.js, Deno, Bun, and browser environments. Live.
Python
revkeen on PyPI -- For Python 3.8+ with async/await support. Live.
PHP
revkeen/revkeen-php on Packagist -- For Laravel, WordPress, and PHP 8.1+ applications. Live.
Why Use an SDK?
- Type Safety -- Full TypeScript types and Python type hints for all API operations. Catch errors at compile time.
- Automatic Retries -- Built-in retry logic with exponential backoff for transient errors.
- Pagination Helpers -- Easily iterate through paginated results with auto-pagination.
- Webhook Verification -- Built-in helpers to verify webhook signatures.
- Error Handling -- Structured error types for better error handling.
Quick Comparison
| Feature | TypeScript | Python | PHP |
|---|---|---|---|
| Package | @revkeen/sdk | revkeen | revkeen/revkeen-php |
| Status | Live | Live | Live |
| 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/sdkpnpm add @revkeen/sdkyarn add @revkeen/sdkpip install revkeenpoetry add revkeencomposer require revkeen/revkeen-phpBasic Usage
TypeScript
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',
});Python
from revkeen import RevKeen
import os
client = RevKeen(api_key=os.environ["REVKEEN_API_KEY"])
# List customers
customers = client.customers.list()
# Create a customer
customer = client.customers.create(
email="john@example.com",
name="John Doe"
)
# Create a subscription
subscription = client.subscriptions.create(
customer_id=customer.data.id,
product_id="prod_xxxxxxxx"
)PHP
<?php
use RevKeen\Client;
$client = new Client(getenv('REVKEEN_API_KEY'));
// List customers
$customers = $client->customers->list();
// Create a customer
$customer = $client->customers->create([
'email' => 'john@example.com',
'name' => 'John Doe',
]);
// Create a subscription
$subscription = $client->subscriptions->create([
'customer_id' => $customer->data->id,
'product_id' => 'prod_xxxxxxxx',
]);Auto-Pagination
// 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();# Iterate through all customers
async for customer in client.customers.list():
print(customer.id, customer.email)
# Or get all at once (sync)
all_customers = list(client.customers.list())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);
}
}from revkeen import RevKeen
from revkeen.errors import (
RevKeenError,
NotFoundError,
ValidationError,
RateLimitError
)
try:
customer = client.customers.retrieve("invalid")
except NotFoundError:
print("Customer not found")
except ValidationError as e:
print(f"Validation failed: {e.details}")
except RateLimitError as e:
print(f"Rate limited, retry after: {e.retry_after}")
except RevKeenError as e:
print(f"API error: {e.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);
switch (event.type) {
case 'invoice.paid':
await handleInvoicePaid(event.data);
break;
}
res.json({ received: true });
});from revkeen.webhooks import verify_webhook
@app.post("/webhooks")
async def webhook_handler(request: Request):
payload = await request.body()
signature = request.headers["x-revkeen-signature"]
event = verify_webhook(payload, signature, WEBHOOK_SECRET)
if event.type == "invoice.paid":
await handle_invoice_paid(event.data)
return {"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
});client = RevKeen(
api_key="rk_live_xxx",
# Optional configurations
base_url="https://api.revkeen.com", # Custom base URL
timeout=30.0, # Request timeout (seconds)
max_retries=3, # Max retry attempts
)Interactive API Reference
Explore the complete API with interactive examples, try requests directly from the documentation, and generate code snippets for multiple languages.