What you’ll need
- An account on SX Bet (for signing orders)
- An API key (for authenticated requests)
- USDC (to place a bet)
Base URL
All API requests go to:https://api.toronto.sx.bet for testnet. See Testnet & Mainnet.
Install dependencies
1
Create an account and an API key
Sign up at sx.bet with email or Google. Complete registration by choosing a username.Fetch your private key from the assets page — you’ll use it to sign orders. Then generate an API key from the API section of your account page; it is shown once.Store both in a
.env file:2
Deploy and fund your proxy wallet
Bets are placed from a proxy wallet your account owns. You can either deploy this proxy wallet programmatically, or
simply login to sx.bet and one will be deployed for you automatically.Once the proxy is deployed, fund it with USDC. Easiest path: deposit in the sx.bet UI.
Programmatically, transfer from your EOA (
cURL
FROM_EOA) with an EIP-2612 permit via
POST /user/transfer-to-proxy — full flow in
Funding.Confirm a spendable balance:cURL
3
Fetch a market
Fetch active markets with
GET /markets/active to find one you want to bet on. Copy the marketHash — you’ll need it in the next steps.4
Fetch the best price
Read the orderbook with
showTakerPerspective=true, which quotes each side as the price you would pay to bet that outcome. Index 0 is the best available. Copy the percentageOdds for the outcome you want — you submit it as-is in the next step.5
Place a bet
Sign an order for the market from step 3 at the price from step 4, and submit it with
timeInForce: "FOK" — fill completely and immediately, or nothing happens. Contract addresses and the chain id come from GET /metadata/obv3.The order id is the EIP-712 digest of what you signed, see EIP-712 order signing.6
Stream updates
Watch your order and the market in real time over a single WebSocket connection. Subscribe to two channels: Order book levels are always the maker frame. Convert to the price you’d pay with
orderbook_v3:{marketHash} is public and streams the complete resting book on every change, while account:orders_v3_#{address} is authenticated and pushes each of your own orders as it rests, fills, or goes inactive.Fetch a realtime JWT from GET /user/realtime-token-v3/api-key. The account channel suffix must equal your token’s sub, which is your user address — the account that signs orders (the maker from step 5), not the proxy wallet that holds the funds. Using the proxy address here silently returns nothing. See Real-time data, Order Book Updates, and Active Order Updates.takerOdds = 1 - percentageOdds / 10^20. See unit conversions.The exchange model
How the exchange and orderbook work, in depth.
Taking liquidity
Signing and submitting orders that execute immediately.