🔌API Reference

REST API & WebSocket Documentation

This document provides complete API reference for integrating with the Robot Fighting Championship platform.


🌐 Base URLs

Production:

REST API: https://api.robotfight.io/v1
WebSocket: wss://ws.robotfight.io

Authentication: Most endpoints require an API key or wallet signature.


🔐 Authentication

Admin Endpoints

Admin endpoints require Bearer token authentication:

Authorization: Bearer <ADMIN_TOKEN>

User Endpoints

User endpoints require wallet signature verification:

// Generate signature
const message = `robotfight:${timestamp}:${walletAddress}`;
const signature = await wallet.signMessage(message);

// Send in header
Authorization: Signature ${walletAddress}:${timestamp}:${signature}

📡 REST API Endpoints

Fights

GET /fights

Get all fights (past and upcoming).

Query Parameters:

  • status (optional): open, live, closed

  • limit (optional): Number of results (default: 50)

  • offset (optional): Pagination offset

Response:

GET /fights/:fight_id

Get specific fight details.

Response:

POST /admin/fight/create

[Admin Only] Create a new fight.

Request Body:

Response:

POST /admin/fight/:fight_id/close

[Admin Only] Close a fight and declare winner.

Request Body:

Response:


Bets

GET /bets

Get bet history for authenticated user.

Query Parameters:

  • status (optional): pending, won, lost

  • limit (optional): Number of results (default: 50)

Response:

POST /bet/create

Place a new bet.

Request Body:

Response:

GET /bet/:bet_id

Get specific bet details.

Response:

POST /bet/:bet_id/claim

Claim payout for winning bet.

Response:


Fighters

GET /fighters

Get all fighter profiles.

Response:

GET /fighters/:fighter_name

Get specific fighter details.

Response:


Statistics

GET /stats/platform

Get platform-wide statistics.

Response:

GET /stats/fighter/:fighter_name

Get detailed fighter statistics.

Response:


🔌 WebSocket API

Connection

Authentication


Events

Client → Server

Subscribe to Fight

Unsubscribe from Fight

Server → Client

Fight Started

Fight State Update (60Hz during live fights)

Hit Event

Fight Ended

Bet Placed (real-time betting updates)

Odds Update


🛠️ SDK & Libraries

JavaScript SDK

Python SDK


🔍 Rate Limits

  • Public endpoints: 100 requests/minute per IP

  • Authenticated endpoints: 1000 requests/minute per user

  • WebSocket: 1000 messages/minute per connection

  • Betting: 10 bets/minute per wallet


⚠️ Error Codes

Code
Message
Description

400

Bad Request

Invalid request parameters

401

Unauthorized

Missing or invalid authentication

403

Forbidden

Insufficient permissions

404

Not Found

Resource not found

429

Too Many Requests

Rate limit exceeded

500

Internal Server Error

Server error

503

Service Unavailable

Maintenance mode

Error Response Format:


📚 Examples

Complete Betting Flow


Last updated