api-staging.kash.bot, Base Sepolia) — going live is the same code against api.kash.bot.
Use the
@kashdao/sdk TypeScript client, not raw HTTP. It handles auth, retries, idempotency, typed errors, and webhook signature verification for you. Everything below is SDK-first; the one place you’ll drop to fetch is redemptions (not yet in the SDK — see step 8).Building on the self-orchestrated surface instead — you run your own signer / market-making infra? Use the Protocol SDK (and the Hummingbot connector). This tutorial is the managed REST path.What you’ll build
A long-running loop that:- Reads a market and quotes a position size.
- Places a trade with an idempotency key (safe to retry).
- Confirms the trade if it trips the high-value gate.
- Learns the outcome asynchronously via a signed webhook (or by polling).
- Tracks open positions.
- Redeems winnings once the market resolves.
1. Prerequisites
- A Kash account — sign up at staging.kash.bot.
- An API key with these scopes (see Authentication):
markets:read,markets:quote,trades:read,trades:write,portfolio:read,webhooks:manage. Keys are created in the webapp (Settings → API Keys) and shown once — capture the plaintext. Akash_test_*key targets staging automatically. - Node 22+.
2. Construct the client
The SDK auto-routes to staging for akash_test_ key and to production for a kash_live_ key — you don’t hard-code a base URL.
3. Read a market and quote
Pick a market, then quote before you trade so you size against real on-chain liquidity.amountUsdcAtomic is USDC in atomic units (6 decimals → 10_000_000 = 10 USDC).
4. Place a trade (idempotent)
Pass anidempotencyKey: if the request times out and your bot retries, you get the same trade back rather than a duplicate. The response carries idempotent: true when it’s a replay.
5. Confirm high-value trades
Trades above your key’s per-trade threshold return a one-timeconfirmation token instead of executing immediately (the trade sits in pending_confirmation). Confirm it to release execution.
6. Learn the outcome — webhooks (preferred) or poll
Webhooks are the production path: Kash POSTs a signed event to your endpoint when the trade completes. Verify the signature with the SDK and dedupe on the event id — never trust an unverified body.7. Track positions
positions is not paginated in v1 — it returns everything, filterable by marketId.
8. Claim winnings (redeem)
When a market resolves, your winning outcome tokens sit in your smart account until you claim them. Create a redemption for the(market, outcome) you hold; the existing payout pipeline settles it on-chain and your USDC balance increases.
Redemptions aren’t in
@kashdao/sdk yet, so call the endpoint directly. It reuses your trades:write scope and is idempotent — one open claim per (market, outcome); a repeat returns the original with 200.GET /v1/portfolio until the USDC balance reflects the payout. See the POST /v1/redemptions reference and the POSITION_NOT_CLAIMABLE / REDEMPTIONS_NOT_ENABLED codes.
9. Handle errors and rate limits
Every failure is a typedKashError subclass — branch on the class, not the message.
10. Going live
- Swap the key for a
kash_live_*key — the SDK re-routes toapi.kash.botautomatically. - Point
webhook_urlat your production endpoint and set the productionKASH_WEBHOOK_SECRET. - Review rate limits for your tier and the webapp → REST migration notes.
See also
TypeScript SDK reference
Full
@kashdao/sdk surface: clients, types, and error classes.Endpoint reference
Every route, request/response shape, and status code.
Webhooks
Event catalog, signing scheme, retries, and secret rotation.
Protocol SDK (self-orchestrated)
Run your own signer / market-making infra instead of the managed REST path.