Skip to main content
GET
/
api
/
v1
/
market
/
orderbook
/
:exchange
/
:symbol
Order Book
curl --request GET \
  --url https://api.example.com/api/v1/market/orderbook/:exchange/:symbol
{
  "error": "Exchange and symbol are required"
}

Overview

Retrieve the current order book for a trading pair, including bids and asks with price levels and quantities. This endpoint provides real-time market depth data essential for analyzing liquidity and market microstructure.

Endpoint

GET /api/v1/market/orderbook/:exchange/:symbol

Path Parameters

exchange
string
required
The exchange identifier (e.g., binance, coinbase, kraken)
symbol
string
required
The trading pair symbol in exchange format (e.g., BTC/USDT, ETH/USD)

Query Parameters

limit
integer
default:"20"
Number of price levels to return for both bids and asks. Valid range: 1-100. Default is 20.

Response Schema

exchange
string
required
The exchange name from the request
symbol
string
required
The trading pair symbol from the request
bids
array
required
Array of bid price levels, where each entry is [price, amount]
asks
array
required
Array of ask price levels, where each entry is [price, amount]
timestamp
timestamp
required
The timestamp when this order book snapshot was captured
cached
boolean
required
Indicates whether the data was served from Redis cache

Code Examples

curl -X GET "https://api.neuratrade.io/api/v1/market/orderbook/binance/BTC/USDT?limit=10" \
  -H "Content-Type: application/json"

Response Example

{
  "exchange": "binance",
  "symbol": "BTC/USDT",
  "bids": [
    [49999.50, 1.2345],
    [49999.00, 0.5678],
    [49998.50, 2.1234]
  ],
  "asks": [
    [50000.50, 0.9876],
    [50001.00, 1.5432],
    [50001.50, 0.7654]
  ],
  "timestamp": "2026-03-03T10:30:45Z",
  "cached": false
}

Caching Behavior

  • Cache TTL: 5 seconds (shorter than tickers due to rapid order book changes)
  • Cache Key Format: orderbook:{exchange}:{symbol}:{limit}
  • Cache Analytics: Cache hits/misses are tracked in the order_books category

Order Book Metrics

For advanced order book analysis including imbalance, liquidity scores, and depth metrics, use the metrics endpoint:
GET /api/v1/market/orderbook/:exchange/:symbol/metrics
This endpoint calculates:
  • Bid-ask spread and mid-price
  • Order book imbalance at 1% and 2% depth
  • Liquidity scores
  • Best bid/ask prices

Error Responses

{
  "error": "Exchange and symbol are required"
}

Implementation Details

  • Data Source: Live CCXT service only (no database fallback)
  • Service Health Check: Returns 503 if CCXT service is unhealthy
  • Limit Validation: Values outside 1-100 range default to 20
  • Source Code: services/backend-api/internal/api/handlers/market.go:518

Use Cases

  • Market Making: Monitor bid/ask spreads for trading opportunities
  • Liquidity Analysis: Assess market depth before placing large orders
  • Arbitrage Detection: Compare order books across exchanges
  • Price Discovery: Identify support and resistance levels from order clustering

Build docs developers (and LLMs) love