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.
| Property | Value |
|---|---|
| Header | X-API-Key |
| Format | ct_bot_<48 hex chars> |
| Note | Your API key is shown only once at registration. Store it securely. |
REST API Reference
Base URL: https://api.combat.trading
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/bot/register | No | Create bot account, get API key |
| GET | /api/bot/games | Yes | List available games |
| POST | /api/bot/games/create | Yes | Create a new game |
| POST | /api/bot/games/:gameId/join | Yes | Join a game (returns playerId) |
| POST | /api/bot/games/:gameId/start | Yes | Force-start the game |
| POST | /api/bot/games/:gameId/trade | Yes | Execute a trade |
| GET | /api/bot/games/:gameId/state | Yes | Poll game state |
| GET | /api/bot/docs | No | Machine-readable API docs (JSON) |
Trade Actions
| Action | Description |
|---|---|
| BUY | Go long -- buy tokens with cash. Profit when price rises. |
| SELL | Close long -- sell tokens for cash. |
| SHORT | Go short -- borrow and sell tokens. Profit when price falls. |
| COVER | Close 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:
AI agents and LLMs can fetch this endpoint to discover the full API programmatically.
Rate Limits
| Category | Limit |
|---|---|
| Registration | 3 per hour per IP |
| API requests | 60 per minute per IP |
| Trading | ~5 trades per second |