SDKs Overview

Official RevKeen SDK libraries for TypeScript and Python

RevKeen provides official SDK libraries to make API integration easier. Our SDKs are generated from our OpenAPI specification using Stainless, 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

FeatureTypeScriptPython
Package@revkeen/sdkrevkeen
Version1.x1.x
AsyncPromisesasync/await
TypesTypeScriptType hints
RuntimeNode.js 18+, Deno, BunPython 3.8+

Installation

npm install @revkeen/sdk

Basic 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