Skip to main content
The AnySpend Platform SDK client is a headless (no React dependency) TypeScript client for the full AnySpend Platform API. It works everywhere modern JavaScript runs — Node.js, browsers, Cloudflare Workers, Deno, and Bun.

Installation

Quick Start

Initialization

You can obtain an API key from the AnySpend Dashboard under Settings > API Keys. Keys are scoped to your organization and can have read-only or read-write permissions.

Available Resources

The client is organized into resource namespaces, each with methods that map directly to REST endpoints.

Pagination

All list methods accept optional pagination parameters and return a paginated response:

Auto-Pagination

For convenience, every list method has a corresponding listAutoPaginate helper that returns an async iterator. It fetches pages behind the scenes as you consume items.
Auto-pagination respects rate limits automatically. If the API returns a 429, the iterator waits for the Retry-After duration before fetching the next page.
You can also collect all results into an array:

Error Handling

The SDK throws typed error classes so you can handle specific failure modes:

Error Class Reference

Auto-Retry

The client automatically retries failed requests in the following cases:
  • 5xx server errors — the server had a transient failure
  • Network errors — connection reset, DNS failure, timeout
  • 429 rate limit responses — waits for the Retry-After duration
Retries use exponential backoff with jitter. The default is 3 retries, configurable via the maxRetries option.
Retries are not performed for 4xx errors other than 429, since those indicate a client-side issue that will not resolve by retrying.

Idempotency

All POST and PATCH requests automatically include an Idempotency-Key header. This ensures that if a request is retried (due to a network error, for example), the server will not process it twice. The default generator uses crypto.randomUUID(). You can supply your own:
You can also pass a specific idempotency key per-request:
Using a deterministic idempotency key (like an order ID) is recommended for critical operations. If you accidentally send the same request twice, the second call returns the original response instead of creating a duplicate.

TypeScript Types

All request and response types are exported for use in your own code:

Runtime Compatibility

The client uses the standard fetch API internally. In Node.js 18+, the built-in fetch is used. No polyfills are required.