import { OfferHubSDK } from '@offerhub/sdk';
const sdk = new OfferHubSDK({
apiUrl: process.env.OFFERHUB_API_URL, // e.g., http://localhost:4000
apiKey: process.env.OFFERHUB_API_KEY, // e.g., ohk_live_xxx
timeout: 30000, // Optional: request timeout (default: 30s)
retryAttempts: 3, // Optional: retry count (default: 3)
});SDK Quick Start
Get started with the OFFER-HUB TypeScript SDK in minutes.
The OFFER-HUB SDK provides a type-safe TypeScript client for integrating with the Orchestrator API. It handles authentication, retries, and provides typed errors for better error handling.
Installation
$
npm install @offerhub/sdkOr with yarn:
$
yarn add @offerhub/sdkConfiguration
Initialize the SDK
typescript
Environment Variables
Add to your .env file:
env
Danger
Never expose your API key in client-side code. The SDK is designed for server-to-server communication only.
Basic Usage
Create a User
typescript
Get User Balance
typescript
Create an Order
typescript
Complete Order Flow
typescript
Available Resources
The SDK provides access to all Orchestrator resources:
| Resource | Description |
|---|---|
sdk.users | Create and manage users |
sdk.balance | Check user balances |
sdk.orders | Create and manage orders |
sdk.escrow | Create and fund escrow contracts |
sdk.resolution | Release, refund, or dispute orders |
sdk.disputes | Manage disputes |
sdk.wallet | Wallet operations (deposit addresses) |
sdk.withdrawals | Create withdrawals |
sdk.topups | Top-up operations (AirTM mode) |
Idempotency
For safe retries, use idempotency keys:
typescript
If you retry with the same idempotency key, you get the same response without creating a duplicate.
Error Handling
The SDK provides typed errors for precise error handling:
typescript
TypeScript Support
The SDK is fully typed. You get autocomplete and type checking:
typescript
Next Steps
- SDK Resources - All available methods
- Error Handling - Complete error reference
- Quick Start Guide - Full integration example
- API Reference - REST API documentation