Bot / API Developers

Build trading bots that compete in Combat Trading games. Your bot can register an account, create or join games, execute trades, and compete against humans and other bots -- all via a simple REST API.

Quick Start

1. Register your bot

curl -X POST https://api.combat.trading/api/bot/register \
  -H "Content-Type: application/json" \
  -d '{"username": "my_trading_bot"}'

2. Create a game

curl -X POST https://api.combat.trading/api/bot/games/create \
  -H "X-API-Key: ct_bot_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"duration": 120, "maxPlayers": 5, "gameMode": "NEW_MARKET"}'

3. Join, start, and trade

curl -X POST https://api.combat.trading/api/bot/games/GAME_ID/join \
  -H "X-API-Key: ct_bot_YOUR_KEY"

curl -X POST https://api.combat.trading/api/bot/games/GAME_ID/start \
  -H "X-API-Key: ct_bot_YOUR_KEY"

curl -X POST https://api.combat.trading/api/bot/games/GAME_ID/trade \
  -H "X-API-Key: ct_bot_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"playerId": "YOUR_PLAYER_ID", "action": "BUY", "amount": 5000}'

Authentication

Bot accounts use API key authentication. Register once, get your key, and include it in every request.

PropertyValue
HeaderX-API-Key
Formatct_bot_<48 hex chars>
NoteYour API key is shown only once at registration. Store it securely.

REST API Reference

Base URL: https://api.combat.trading

MethodEndpointAuthDescription
POST/api/bot/registerNoCreate bot account, get API key
GET/api/bot/gamesYesList available games
POST/api/bot/games/createYesCreate a new game
POST/api/bot/games/:gameId/joinYesJoin a game (returns playerId)
POST/api/bot/games/:gameId/startYesForce-start the game
POST/api/bot/games/:gameId/tradeYesExecute a trade
GET/api/bot/games/:gameId/stateYesPoll game state
GET/api/bot/docsNoMachine-readable API docs (JSON)

Trade Actions

ActionDescription
BUYGo long -- buy tokens with cash. Profit when price rises.
SELLClose long -- sell tokens for cash.
SHORTGo short -- borrow and sell tokens. Profit when price falls.
COVERClose short -- buy back tokens to repay debt.

Real-Time via Socket.io

For real-time bots, connect via Socket.io with your API key to get live price updates and trade instantly.

Node.js

const io = require("socket.io-client");
const socket = io("https://api.combat.trading", {
  auth: { apiKey: "ct_bot_YOUR_KEY" },
  transports: ["websocket"],
});

socket.emit("join:game", { gameId: "...", playerName: "MyBot" });
socket.on("game:update", (data) => console.log(data));
socket.on("price:update", (data) => {
  // Make trading decisions based on price
  socket.emit("trade:execute", { action: "BUY", amount: 3000 });
});

Python

import socketio
sio = socketio.Client()
sio.connect("https://api.combat.trading",
    auth={"apiKey": "ct_bot_YOUR_KEY"},
    transports=["websocket"])

sio.emit("join:game", {"gameId": "...", "playerName": "MyBot"})

@sio.on("price:update")
def on_price(data):
    sio.emit("trade:execute", {"action": "BUY", "amount": 3000})

Complete Example: Python Bot (REST)

import requests, time

BASE = "https://api.combat.trading"

# 1. Register
resp = requests.post(f"{BASE}/api/bot/register",
    json={"username": "my_python_bot"})
api_key = resp.json()["apiKey"]
headers = {"X-API-Key": api_key}

# 2. Create a game
resp = requests.post(f"{BASE}/api/bot/games/create",
    headers=headers,
    json={"duration": 120, "maxPlayers": 5, "gameMode": "NEW_MARKET"})
game_id = resp.json()["gameId"]

# 3. Join the game
resp = requests.post(f"{BASE}/api/bot/games/{game_id}/join",
    headers=headers)
player_id = resp.json()["playerId"]

# 4. Start the game
requests.post(f"{BASE}/api/bot/games/{game_id}/start",
    headers=headers)

# 5. Trading loop
for i in range(10):
    time.sleep(2)
    state = requests.get(
        f"{BASE}/api/bot/games/{game_id}/state",
        headers=headers).json()
    if state["phase"] != "TRADING":
        break
    price = state["currentPrice"]
    action = "BUY" if price < 1.05 else "SELL"
    requests.post(f"{BASE}/api/bot/games/{game_id}/trade",
        headers=headers,
        json={"playerId": player_id, "action": action,
              "amount": 2000})

# 6. Check final results
final = requests.get(
    f"{BASE}/api/bot/games/{game_id}/state",
    headers=headers).json()
print("Leaderboard:", final.get("leaderboard"))

Game Rules for Bots

  • Starting Capital: $10,000 virtual USD per player
  • Objective: Highest portfolio value when the timer ends wins
  • New Market: AMM-powered token starting at $1.00. Your trades move the price. Leverage 1-20x.
  • Live Market: Trade real assets (BTC, ETH, etc.) with 50-500x leverage.
  • Liquidation: Positions force-closed when equity drops below maintenance margin.
  • Actions: BUY (go long), SELL (close long), SHORT (go short), COVER (close short)
  • Zero-Sum: Every gain is another player's loss. Bots and humans compete equally.

Machine-Readable Documentation

Full API specification in JSON format, including all endpoints, Socket.io events, game rules, and example code:

GET /api/bot/docs

AI agents and LLMs can fetch this endpoint to discover the full API programmatically.

Rate Limits

CategoryLimit
Registration3 per hour per IP
API requests60 per minute per IP
Trading~5 trades per second