API Documentation

SSE Streaming Endpoint

Subscribe to real-time normalized trade data via Server-Sent Events.

GET /stream/{exchange}/{pair}/{event}

Path Parameters

  • exchange : binance or bitstamp
  • pair : e.g., btcusdt, ethusd (See Full List)
  • event : trade

Query Parameters

  • throttle : Optional duration (e.g. 100ms, 1s). Limits the update rate.

Event Data Structure

{
  "event": "trade",
  "exchange": "binance",
  "payload": {
    "id": "5650440593",
    "exchange": "binance",
    "market": "btcusdt",
    "price": "90033.29000000",
    "amount": "0.00008000",
    "side": "sell",
    "timestamp": "2025-12-12T18:53:34.336+01:00"
  }
}

Common Errors

  • 400 Bad Request : { "error": "invalid throttle duration" }
  • 404 Not Found : { "error": "requested pair not found" }
  • 404 Not Found : { "error": "requested exchange not found" }
  • 404 Not Found : { "error": "requested event not found" }

LLM Integration Prompt

Copy this prompt to give an LLM context about this API:

You have access to a real-time crypto trade stream via SSE (Server-Sent Events) at:
GET https://metra.sh/stream/{exchange}/{pair}/{event}?throttle={duration}

Parameters:
- exchange: "binance" or "bitstamp"
- pair: e.g. "btcusdt" (binance) or "btcusd" (bitstamp)
- event: "trade"
- throttle (optional): e.g. "100ms", "1s"

The stream returns JSON data lines:
data: {"event":"trade", "exchange":"...", "payload": { "id":"...", "price":"...", "amount":"...", "side":"buy/sell", "timestamp":"..." }}

Write a script to consume this stream and [YOUR GOAL HERE].

Example Usage

cURL
curl -N "https://metra.sh/stream/binance/btcusdt/trade?throttle=500ms"
JavaScript (Browser)
const es = new EventSource("https://metra.sh/stream/binance/btcusdt/trade");
es.onmessage = (e) => console.log(JSON.parse(e.data));
Go
resp, _ := http.Get("https://metra.sh/stream/binance/btcusdt/trade")
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
    line := scanner.Text()
    if strings.HasPrefix(line, "data: ") {
        fmt.Println(line[6:]) // JSON payload
    }
}
Python
import requests

url = "https://metra.sh/stream/binance/btcusdt/trade"
with requests.get(url, stream=True) as r:
    for line in r.iter_lines():
        if line and line.startswith(b"data: "):
            print(line.decode('utf-8')[6:])