AWBW Battleground trading API

A read feed and an order mailbox for the prediction market on twitch.tv/awbwbattleground, so a bot can trade without typing in chat. Your bot trades as you: same balance, same positions, same leaderboard as your chat bets, and the same rules.

Getting a key

  1. Follow the channel (the key arrives by whisper, and Twitch only delivers whispers from accounts you follow).
  2. Type !key in the channel's chat. The bot whispers you a key that starts with awbwbg_.
  3. Didn't get it? Check your whisper settings, then !key again. Every !key replaces the previous key, so a lost or leaked key is one command away from dead.

Send it on every request that needs it: Authorization: Bearer awbwbg_…

Read feed (no key)

RouteWhat
GET /v1/stateThe current market with outcome ids and prices, the last 50 trades, the live game stats the house model reads, which game is on stream, and whether AWBW is up. Pushed by the box whenever it changes; cached 2 s. market is null between games.
GET /v1/healthbox_alive (the box heartbeats every minute), state_updated_at, open_orders.

Poll /v1/state every second or two if you like; the odds move per AWBW turn, so faster buys nothing.

Your account (key)

GET /v1/me: your balance and positions as of your last fill or the last settlement, plus when the key was made and last used.

Orders (key)

POST /v1/orders with a JSON body. The box picks orders up within a couple of seconds, runs them, and writes the result back; poll GET /v1/orders/{id} for it.

{ "side": "buy",  "outcome_id": 2, "amount": 100 }        // spend 100 gold on outcome 2 (like !buy)
{ "side": "buy",  "outcome_id": 2, "all": true }           // all in (like !buymax)
{ "side": "sell", "outcome_id": 2, "shares": 10 }          // sell 10 shares (like !sell)
{ "side": "sell", "outcome_id": 2, "all": true }           // sell everything on that outcome (like !sellall)

Optional fields: market_id (the order is rejected if that isn't the market on stream when it runs) and id (your own id, 1–64 chars of A-Za-z0-9_-; resending the same id returns the same order instead of placing a second one. Use it: it makes retries safe).

Outcome ids come from /v1/state; they change with every market.

statusMeaning
pendingWaiting for the box.
executingThe box has it.
filledDone. result has the trade (cost, shares, price), your new balance and position, and the prices after the trade.
rejectedNot done; error says why (market closed, not enough gold, unknown outcome, wrong market…).
unknownThe box restarted mid-order. Check /v1/me before retrying.

GET /v1/orders?limit=20 lists your recent orders, newest first.

Limits

Example

KEY=awbwbg_…
curl -s https://api.awbwbg.otw.gg/v1/state | jq '.market.outcomes'
curl -s -X POST https://api.awbwbg.otw.gg/v1/orders \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"id":"my-bot-1","side":"buy","outcome_id":2,"amount":100}'
curl -s https://api.awbwbg.otw.gg/v1/orders/my-bot-1 -H "Authorization: Bearer $KEY"

Everything here is play money on a Twitch stream. Trades placed this way are tagged, and show as "(via api)" next to your name in the game-over results.