Documentation

Five minutes from git clone to first paid call.

The Switch docs are the same docs we use internally. Open source SDKs, runnable examples, and an API reference that ships with every release.

Quickstart

Three commands. One paid HTTP call.

step 01

Install the SDK

terminal
sh
1# pick your runtime
2npm install @switch/sdk
3# or
4pnpm add @switch/sdk
5# or
6bun add @switch/sdk
step 02

Mint a key in the dashboard

terminal
sh
1# log in at https://switch.finance/dashboard
2# create a Store, add a Solana receiving wallet,
3# then create an API key and copy the secret.
4
5# stash it in your env
6$ echo "SWITCH_KEY=sk_test_AB12CD34EF56" >> .env
step 03

Pay your first 402

index.ts
ts
1import { Switch } from '@switch/sdk';
2
3const switch_ = new Switch({
4 apiKey: process.env.SWITCH_KEY,
5 budget: { max: '1.00', asset: 'USDC', period: '1h' },
6});
7
8const res = await switch_.fetch('https://api.example.com/forecast');
9const data = await res.json();
10
11console.log('paid:', res.headers.get('x-payment-receipt'));
12console.log('data:', data);
Need a hand

Real engineers, in your Discord.

The Switch team responds in our community Discord, on GitHub issues, and to every support email. Average first response: 19 minutes.