4rho API Overview
The 4rho API provides programmatic access to the 4rho prediction market platform. It supports high-frequency trading, market making, and real-time data feeds.
Base URL
https://4rho.com/api/v1
Features
- CLOB Trading: Place and manage limit orders on any prediction market
- Batch Operations: Place or cancel up to 50 orders in a single request
- Advanced Order Types: GTC, GTD, FOK, FAK, post-only, self-trade prevention
- Cancel-Replace: Atomically replace an existing order
- Real-Time WebSocket: Market data and user fills via WebSocket
- Market Data: Order book snapshots, BBO, spreads, and trade history
Authentication
The API supports two authentication methods:
- JWT Bearer Token — For browser-based applications using OAuth login
- HMAC API Key — For programmatic access (market makers, bots)
API keys are issued by 4rho administrators. See Authentication for details.
Quick Start
import hashlib
import hmac
import time
import requests
API_KEY = "4rho_..."
SECRET = "your_secret"
PASSPHRASE = "your_passphrase"
BASE_URL = "https://4rho.com/api/v1"
def sign_request(method, path, body=""):
timestamp = str(int(time.time()))
body_hash = hashlib.sha256(body.encode()).hexdigest()
message = f"{timestamp}\n{method}\n{path}\n{body_hash}"
secret_hash = hashlib.sha256(SECRET.encode()).hexdigest()
signature = hmac.new(
secret_hash.encode(), message.encode(), hashlib.sha256
).hexdigest()
return {
"X-4RHO-API-KEY": API_KEY,
"X-4RHO-SIGNATURE": signature,
"X-4RHO-TIMESTAMP": timestamp,
"X-4RHO-PASSPHRASE": PASSPHRASE,
}
# Get server time
resp = requests.get(f"{BASE_URL}/time")
print(resp.json())
# Get order book
headers = sign_request("GET", "/v1/orders/book/YOUR_MARKET_ID")
resp = requests.get(
f"{BASE_URL}/orders/book/YOUR_MARKET_ID",
headers=headers
)
print(resp.json())
Response Format
All responses are JSON. Successful responses return the data directly:
{
"order_id": "550e8400-e29b-41d4-a716-446655440000",
"order_hash": "0xabc...",
"status": "open",
"matches": 0
}
Error responses include an error field:
{
"error": "order not found"
}
Pagination
List endpoints support cursor-based pagination:
| Parameter | Type | Description |
|---|---|---|
limit | int | Max results (default 50) |
offset | int | Skip N results |
since | string | ISO 8601 timestamp filter |
Next Steps
- Authentication — Set up your API key
- Orders — Place your first order
- WebSocket — Subscribe to real-time feeds