4rho API Overview

The 4rho API provides programmatic access to the 4rho prediction market platform. It provides programmatic order placement, market-making endpoints, and real-time data feeds.

Base URL

https://api.4rho.com/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:

  1. JWT Bearer Token — For browser-based applications using OAuth login
  2. 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://api.4rho.com/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}"
    hmac_key = hashlib.sha256(SECRET.encode()).hexdigest()
    signature = hmac.new(
        hmac_key.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:

ParameterTypeDescription
limitintMax results (default 50)
offsetintSkip N results
sincestringISO 8601 timestamp filter

Next Steps