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.paymentLinks
paymentLinks
products
products
customers
customers
transactions
transactions
checkoutSessions
checkoutSessions
webhooks
webhooks
discountCodes
discountCodes
notifications
notifications
widgets
widgets
organization
organization
analytics
analytics
events
events
Pagination
Alllist methods accept optional pagination parameters and return a paginated response:
Auto-Pagination
For convenience, everylist method has a corresponding listAutoPaginate helper that returns an async iterator. It fetches pages behind the scenes as you consume items.
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-Afterduration
maxRetries option.
Idempotency
AllPOST 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:
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.
HypeDuel