SDK / Getting started
SDK overview
What the TypeScript SDK, maxy-labs, does for you, what is in it, and how it maps onto the HTTP API. It is for developers choosing between the SDK and plain HTTP calls.
The SDK is the HTTP API with typed methods, plus the parts an order needs around it: wallet signers, flow helpers that run a whole order, and checks on every answer before the wallet is asked to sign. It is MIT-licensed, ESM only, and runs on Node 18+ and in browsers. Install it from npm: Install and signers.
What it checks for you
A server answer may choose among things the SDK already trusts, never add something new to sign or pay. Contract addresses, chain ids and signing domains are compiled in, and the SDK checks a solver against Maxy's published solver list. Before every wallet prompt, the full SDK's swap module, in your own process:
- computes the intent hash itself, and compares it with the settler's own
hashIntent, - reads the settler nonce on chain,
- bounds the deposit and the price,
- decodes the Bitcoin payout script from the address locally,
- simulates the escrow transaction.
A mismatch stops the order with nothing signed. The HTTP API runs the same checks on Maxy's side before it answers, so the core client and plain HTTP calls get them too. To check for yourself over HTTP, hash each steps[].typedData and compare it with steps[].hash: Security and compliance.
Two clients
| Import | createMaxyClient gives | Use it for |
|---|---|---|
maxy-labs/core | One method per HTTP route, the flow helpers, units, error classes. fetch only, 17 kB | A server, a browser page or an edge function that talks to the API |
maxy-labs | The same methods, plus swap, borrow and auth, with chain reads of its own | The checks above in your own process, step-by-step control, refunds and claims from the user's wallet |
import { createMaxyClient } from 'maxy-labs/core'; const maxy = createMaxyClient(); // reads MAXY_API_KEY const price = await maxy.prices.get({ from: 'ETH on base', to: 'BTC', amount: '0.01' }); console.log(price.formatted?.receive, price.meta?.requestId); // 0.00027834 BTC <the x-request-id> console.log(maxy.sandbox); // true with a test key
Every method is one route
| Resource | Methods | Route |
|---|---|---|
prices | get, stream | GET /price, GET /prices/stream |
pairs | list, get, refresh | GET /pairs |
quotes | get, batch, msUntilExpiry, refresh | GET /quote, POST /quotes/batch |
orders | create, submit, get, list, iterate, events, watch, resume, cancel, refund, deposit, claim, steps, follow | /orders… |
status | byTxHash, byIntentHash, byBitcoinTxid | GET /status |
addresses | validate | GET /addresses/validate |
limits, health, key | get | GET /limits, /health, /key |
webhooks | create, list, remove, test, events, replay | /webhooks… |
sandboxControls | advance, scenarios, rates | /sandbox/… |
Anything a method does can be done with curl, and the JSON is the API's own. Each answer adds a meta with requestId, status, latencyMs, retries and rateLimit, which stays out of JSON.stringify. Every failure is a MaxyError subclass with code, status, requestId and retryable: Error codes.
Entry points
| Import | Gives |
|---|---|
maxy-labs/evm | buyBtcWithEvm, for a viem wallet client or an EIP-1193 provider |
maxy-labs/solana | buyBtcWithSolana |
maxy-labs/bitcoin | sellBtc, bip21Uri, validateAddress |
maxy-labs/server | verifyWebhook, constructEvent, handleOnce, exportOrders, for Node and edge servers. A browser build refuses it |
maxy-labs/testing | Mock fetch, one fixture per error code, and a simulator that walks an order through any states |
The flow helpers run a whole order in one call: Flow helpers. Hooks for React and the same client for Python: React and Python. From a terminal: Command line.
SDK or HTTP
| Choose | When |
|---|---|
| The SDK | You write TypeScript, want the checks above done for you, and want one call for a whole order |
| Plain HTTP | Another language, or your own signing stack. The quote carries the typed data, its hash and the transaction, so you can check each one yourself |
Both use the same keys, the same sandbox and the same order states. Every option: Configure the SDK.
Hosts it calls
One host: openapi.maxy.co. The HTTP API, Maxy's functions and read views, chain reads, Bitcoin data, the Solana settlement gateway, and the LI.FI, Tron, Sui and Solana-swap legs all go through it, so a Content-Security-Policy needs connect-src 'self' https://openapi.maxy.co and nothing more. The SDK carries no key of its own: Maxy's host adds what its services need, and your API key is what Maxy counts and caps. The full list, with what each path carries: SDK hosts.