title: JavaScript SDK
description: Install and use the official Wontopos JavaScript/TypeScript SDK.
JavaScript SDK
The @wontopos/sdk package supports Node.js 18+, Deno, Bun, and edge runtimes.
Installation
npm install @wontopos/sdk Runtime support
Works in any environment with a global `fetch` implementation, including Vercel Edge and Cloudflare Workers.
Initialize the client
import Wontopos from "@wontopos/sdk";
const client = new Wontopos({
apiKey: process.env.WONTOPOS_API_KEY,
}); Configuration options
const client = new Wontopos({
apiKey: process.env.WONTOPOS_API_KEY,
timeout: 30_000,
maxRetries: 3,
baseURL: "https://api.wontopos.com",
}); Basic usage
List marketplace APIs
const apis = await client.marketplace.list({
category: "payments",
limit: 20,
});
for (const api of apis.data) {
console.log(api.id, api.name);
} Create a subscription
const subscription = await client.subscriptions.create({
apiId: "api_abc123",
plan: "pro",
}); Auto-pagination
for await (const api of client.marketplace.listAutoPaging()) {
console.log(api.name);
} TypeScript types
Full type definitions are included — no separate @types package needed.
import type { MarketplaceAPI, Subscription, Usage } from "@wontopos/sdk";
async function processSubscription(sub: Subscription): Promise<void> {
// Full intellisense and type checking
} Error handling
import { WontoposError, AuthenticationError, RateLimitError } from "@wontopos/sdk";
try {
const result = await client.marketplace.list();
} catch (err) {
if (err instanceof AuthenticationError) {
console.error("Invalid API key");
} else if (err instanceof RateLimitError) {
console.error("Retry after:", err.retryAfter);
} else if (err instanceof WontoposError) {
console.error(err.code, err.message);
}
} Automatic retries
The SDK retries `429` and `5xx` errors automatically with exponential backoff. Configure via `maxRetries`.