RevKeen Docs
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

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

FeatureTypeScriptPythonPHP
Package@revkeen/sdkrevkeenrevkeen/revkeen-php
StatusLiveLiveLive
AsyncPromisesasync/awaitSync + Guzzle
TypesTypeScriptType hintsPHP 8.1+ types
RuntimeNode.js 18+, Deno, BunPython 3.8+PHP 8.1+

Installation

npm
npm install @revkeen/sdk
pnpm
pnpm add @revkeen/sdk
yarn
yarn add @revkeen/sdk
pip
pip install revkeen
poetry
poetry add revkeen
composer
composer require revkeen/revkeen-php

Basic 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

TypeScript
// 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();
Python
# 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

TypeScript
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);
  }
}
Python
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

TypeScript
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 });
});
Python
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

TypeScript
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
});
Python
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.

On this page