Developers
Open app
Get started

Trade from a script

Bet from a script in one line. Slay finds the market, picks the venue that pays more (Hyperliquid or Polymarket), moves your money there if it needs to, and places the order.

Quick start

  1. At [slay.money/api/keys](/api/keys): create an API key (shown once: keep it like a password) and add money to your API wallet. Only the money in the API wallet can be traded by a key; Withdraw sends it back to Slay Cash.
  2. Click Download starter bot under your new key. You get slay_bot.py: one file, your key already in it, set to practice money. Run it: python slay_bot.py (needs Python and pip install requests). Edit the bottom of the file to make it yours.

The API wallet is a wallet Slay holds for you, like a copy's own wallet: money leaves it only into your bets, or back to your Slay Cash when you withdraw.

Prefer your own files? Download the helper, slay.py or slay.js, into your script's folder and import slay (don't name your own script slay.py):

import slay
slay.key = "spk_..."                 # or set SLAY_API_KEY

slay.buy("btc 5m", "up", 10)         # $10 on Up in the current Bitcoin 5-minute market
slay.buy("lakers", "Lakers", 20)     # $20 on the Lakers
slay.sell("btc 5m", "up")            # sell all of it
print(slay.balance())                # cash and open positions
print(slay.say(slay.buy("btc 5m", "up", 10)))   # say(): one readable line, e.g.
# Bought 19.6 Up on Polymarket for $10.00 at 51.0c, wins $19.60 - filled
const slay = require("./slay");
slay.key = "spk_...";
await slay.buy("btc 5m", "up", 10);

Where your bet goes: every answer names the venue: "venue": "polymarket" or "hyperliquid", with offers showing what each venue gave for the same bet. To see it before betting, slay.quote("btc 5m", "up", 10) does everything but place the order ("status": "preview"). To choose the venue yourself, add venue="hyperliquid" ({ venue: "hyperliquid" } in JS).

{ "status": "filled", "market": "Bitcoin Up or Down - 4:25AM-4:30AM ET", "outcome": "Up", "venue": "polymarket",
  "shares": 19.6, "usd": 10, "avgPrice": 0.51, "toWin": 19.6,
  "offers": { "polymarket": { "shares": 19.6, "avgPrice": 0.51, "cost": 10, "toWin": 19.6 } } }

It runs on its own when your script does. An API key doesn't trade by itself: your script decides when to bet, and Slay places each bet it sends. Run the script in a loop (or on a schedule, or on a server so it keeps going when your computer is off):

import time, slay
slay.key = "spk_..."
while True:
    q = slay.quote("btc 5m", "up", 10)
    if q["avgPrice"] < 0.45:          # your rule
        print(slay.buy("btc 5m", "up", 10))
    time.sleep(60)

Practice first: slay.paper = True trades $1,000 of fake money against the live prices. Nothing real moves.

The market is a few words from its title ("btc 5m", "eth 15m", "lakers"), its id, or its slay.money link. Repeating markets (5m, 15m, 1h, 4h, daily) pick the window that's open now. When the words fit more than one market, the order is refused with the list (matches): add a word or use the id. slay.find("lakers") shows what fits.

The outcome is one of the market's options: "up", "yes", "Lakers". "no Lakers" bets against an option.

What comes back: status (filled, partial, unfilled, failed), shares, usd, avgPrice, venue, market, outcome and the order id. A refused order raises SlayError with a code: insufficient_balance, over_order_limit, over_daily_limit, min_order_size, no_liquidity, ambiguous_market, market_not_found, insufficient_position, no_wallet, paused, venue_error (the venue's own reason in the message). A failed order still has an id (in e.data).

Prices: a buy pays at most 3c over the book's price for its size, a sell takes at least 3c under; set your own with max_price=0.55 / min_price=0.40 (maxPrice / minPrice in JS).

Limits: $100 an order and $500 a day unless you set your own on the page. Hyperliquid's smallest order is $10 (smaller buys go to Polymarket); Polymarket's is $1.

Retries are safe: every order carries its own id (id= to set it), and the same id never places a second order.

Plain HTTP

The helpers call these; any language can:

curl -s -X POST https://www.slay.money/api/trade/buy -H "authorization: Bearer $SLAY_API_KEY"   -H "content-type: application/json" -d '{"market":"btc 5m","outcome":"up","usd":10,"externalId":"my-0001"}'
curl -s -X POST https://www.slay.money/api/trade/sell -H "authorization: Bearer $SLAY_API_KEY"   -H "content-type: application/json" -d '{"market":"btc 5m","outcome":"up"}'
curl -s https://www.slay.money/api/trade/balance -H "authorization: Bearer $SLAY_API_KEY"
curl -s https://www.slay.money/api/trade/order/my-0001 -H "authorization: Bearer $SLAY_API_KEY"

"paper": true on /buy and /sell (?paper=1 on /balance) for practice. An order that takes longer than 20 seconds (in-play markets hold orders) answers 202 with status: "pending": read it again with /order/<id>.

Need limit orders, cancels, live order books or webhooks? See Trade your main account (advanced).