Skip to content

Logo

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 safeParse and logs shape mismatches without throwing; call Schema.parse(...) yourself when you need strict validation.
  • Flexible authKeysProvider for API key/secret exchange, or OAuthProvider for 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-hoc fetch calls.

Requirements

Node.js 18 or later.

Quick start

Install the package:

bash
pnpm add @basetime/a2w-api-ts

Create 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

TopicDescription
InstallingInstall with npm, yarn, or pnpm
SetupAPI credentials, auth providers, and client options
UsageClient methods and per-resource endpoint reference

API reference

ResourceLink
CampaignsUsage → Campaigns
PassesUsage → Passes
EnrollmentsUsage → Enrollments
WalletsUsage → Wallets
Campaign workflowsUsage → Campaign workflows
TemplatesUsage → Templates
OrganizationsUsage → Organizations
ImagesUsage → Images
ScannersUsage → Scanners
WorkflowsUsage → Workflows
BarcodesUsage → Barcodes
WidgetsUsage → Widgets

Source and issues

The package is published on npm as @basetime/a2w-api-ts. Source, releases, and issue tracking live on GitHub.