Addtowallet TypeScript Client
@basetime/a2w-api-ts is a Node.js and TypeScript client for the Addtowallet platform. Construct a Client, authenticate with API keys or OAuth, and call typed helpers for campaigns, passes, templates, scanners, workflows, and more.
Features
- Full API coverage — Campaigns, passes, enrollments, templates, organizations, scanners, workflows, images, barcodes, and widgets.
- Typed endpoints — Each API resource has a dedicated helper on
client(for example,client.campaigns.getAll()). - Runtime validation — Every response type has a matching Zod schema. The client validates responses with
safeParseand logs shape mismatches without throwing; callSchema.parse(...)yourself when you need strict validation. - Flexible auth —
KeysProviderfor API key/secret exchange, orOAuthProviderfor OAuth flows. Tokens are cached and refreshed automatically. - Shared HTTP layer — All endpoints share one
HttpRequester(client.http) for base URL, auth, user agent, and ad-hocfetchcalls.
Requirements
Node.js 18 or later.
Quick start
Install the package:
bash
pnpm add @basetime/a2w-api-tsCreate an API key and secret in your organization's AddToWallet dashboard, then wire up a client:
ts
import { Client, KeysProvider } from '@basetime/a2w-api-ts';
const auth = new KeysProvider(process.env.A2W_API_KEY!, process.env.A2W_API_SECRET!);
const client = new Client(auth);
const campaigns = await client.campaigns.getAll();
console.log(campaigns);See Setup for authentication details, custom base URLs, and OAuth.
Documentation
| Topic | Description |
|---|---|
| Installing | Install with npm, yarn, or pnpm |
| Setup | API credentials, auth providers, and client options |
| Usage | Client methods and per-resource endpoint reference |
API reference
| Resource | Link |
|---|---|
| Campaigns | Usage → Campaigns |
| Passes | Usage → Passes |
| Enrollments | Usage → Enrollments |
| Wallets | Usage → Wallets |
| Campaign workflows | Usage → Campaign workflows |
| Templates | Usage → Templates |
| Organizations | Usage → Organizations |
| Images | Usage → Images |
| Scanners | Usage → Scanners |
| Workflows | Usage → Workflows |
| Barcodes | Usage → Barcodes |
| Widgets | Usage → Widgets |
Source and issues
The package is published on npm as @basetime/a2w-api-ts. Source, releases, and issue tracking live on GitHub.

