Trade your main account (advanced)
For developers who want venue-level control: limit orders, cancels, live books and fills, webhooks. These endpoints trade your main account directly (not the API wallet), with a trading key Slay keeps for it. Most scripts don't need this: start with Trade from a script.
1. Turn it on (once)
Open [slay.money/api/keys](/api/keys) signed in:
- Create an API key. It's shown once: keep it like a password, in an environment variable, never in code you share. Tick Read only for a key that can see your account, quotes, orders, the stream and webhooks but can never place or cancel an order (for dashboards).
- Turn on API trading. One approval on each venue for the trading key Slay keeps for your account. It can place and cancel orders and can never move or withdraw your money.
- Set your limits: the most one order may spend and the most per day (from $100 and $500 until you change them).
export SLAY_API_KEY=spk_... curl -s https://www.slay.money/api/trade/account -H "authorization: Bearer $SLAY_API_KEY"
apiTrading.on should be true.
2. Find a market and quote it
curl -s "https://www.slay.money/api/data/markets?venue=both&category=sports" | jq '.markets[0] | {id, title, options: [.options[].label]}'
curl -s "https://www.slay.money/api/trade/quote?market=q-669&option=0&outcome=yes&side=buy&usd=20" \
-H "authorization: Bearer $SLAY_API_KEY"The quote has both venues (shares, average price, fees) and best.
3. Place an order
curl -s -X POST https://www.slay.money/api/trade/order \
-H "authorization: Bearer $SLAY_API_KEY" -H "content-type: application/json" \
-d '{"market":"q-669","option":0,"outcome":"yes","side":"buy","usd":20}'The answer says what happened: status is filled, partial, resting or unfilled, with filledShares, avgPrice, the venue and the orderId.
- Market order (default):
usdto buy,sharesto sell. Fills what it can now; the rest is cancelled. Addpricefor the worst price you accept. - Limit order:
"type":"limit",priceandshares. It rests until filled or cancelled. - Venue:
"venue":"hyperliquid"or"polymarket"to choose; by default the better quote. - Retries: send your own
"clientOrderId"(e.g."my-script-0001") and reuse it when you retry after a timeout. A retry gets the first order's answer ("duplicate": true), never a second order. A new order needs a new id. - Hyperliquid trades whole shares, $10 minimum. Polymarket prices move in its tick (usually 1c).
Python:
import os, requests
API = "https://www.slay.money/api"
H = {"authorization": f"Bearer {os.environ['SLAY_API_KEY']}"}
r = requests.post(f"{API}/trade/order", headers=H, json={"market": "q-669", "outcome": "yes", "side": "buy", "usd": 20, "clientOrderId": "my-script-0001"}, timeout=30)
print(r.status_code, r.json())4. Cancel, and see your orders
curl -s https://www.slay.money/api/trade/orders -H "authorization: Bearer $SLAY_API_KEY"
curl -s -X POST https://www.slay.money/api/trade/cancel -H "authorization: Bearer $SLAY_API_KEY" \
-H "content-type: application/json" -d '{"venue":"hyperliquid","coin":"#383330","orderId":"610114878428"}'5. Live books and fills
One Server-Sent Events stream for both venues: books for the markets you pick, and your own fills.
import { EventSource } from "eventsource"; // npm i eventsource (browsers have it built in)
const es = new EventSource("https://www.slay.money/api/trade/stream?markets=q-669", {
fetch: (url, init) => fetch(url, { ...init, headers: { ...init.headers, authorization: `Bearer ${process.env.SLAY_API_KEY}` } }),
});
es.addEventListener("book", (e) => { const b = JSON.parse(e.data); /* b.venue, b.coin, b.bids, b.asks */ });
es.addEventListener("fill", (e) => { const f = JSON.parse(e.data); /* f.venue, f.side, f.price, f.shares, f.tradeId */ });A stream lasts about a minute and then reconnects by itself; fills from the gap are replayed, so dedupe on tradeId (Hyperliquid) or txHash (Polymarket).
6. Webhooks
POST https://api.slay.money/api/predict/api-keys/webhooks with { "url": "https://…" } and your API key. Keep the secret it returns. Slay then POSTs order.filled and position.settled for your account, one event per request, oldest first. Check each one:
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(raw: string, header: string, secret: string) {
const t = /t=(\d+)/.exec(header)?.[1];
const v1 = /v1=([0-9a-f]+)/.exec(header)?.[1];
if (!t || !v1 || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const want = createHmac("sha256", secret).update(`${t}.${raw}`).digest("hex");
return v1.length === want.length && timingSafeEqual(Buffer.from(v1), Buffer.from(want));
}
// header: req.headers["slay-signature"]; answer 2xx within 10 s, and dedupe on the event idSafety rules
- Price guard. Every order needs a two-sided book with a spread of 10c or less, and a price within 5c of its middle (a buy at most mid + 5c, a sell at least mid − 5c). Thin or one-sided markets are refused. This stops anyone holding your key from draining your account through an empty market.
- Your limits apply to every order and every UTC day.
- Your key, your account. Anyone with your API key can trade your account within those limits. If it leaks, revoke it at slay.money/api/keys: it stops at once. Turning API trading off stops every key.
- Never a withdrawal. Nothing in this API moves money out. Deposits, withdrawals and claiming Polymarket winnings happen in the app (wins are claimed automatically when you open it).
- 60 order requests a minute per key. Polymarket isn't available in every country.
- To change an order, cancel it and place a new one.