Integration Guides
Copy-paste examples for common use cases. All examples use the DepthSignal REST API to build monitoring views, review summaries, and broader market context.
1. Context Monitoring Integration
Use DepthSignal composite reads to organize pressure, large-order activity, and liquidity conditions. This example polls the API every 30 seconds and turns the latest reads into an internal context summary for monitoring or review workflows.
Python
import requests
import time
API_URL = "https://api.depthsignal.io"
API_KEY = "your-api-key-here" # Replace with your key
HEADERS = {"X-API-Key": API_KEY}
SYMBOL = "BTCUSDT"
def get_context_read(symbol):
"""Fetch composite reads and summarize market context."""
url = API_URL + "/v1/orderbook/composite/" + symbol
resp = requests.get(url, headers=HEADERS, timeout=10)
resp.raise_for_status()
data = resp.json()
composites = data.get("composites", {})
direction = composites.get("directional_pressure", 0)
whale = composites.get("whale_conviction", 0)
liquidity_risk = composites.get("liquidity_risk", 0)
if liquidity_risk > 0.7:
return {"context": "elevated liquidity stress", "reason": "Liquidity conditions are thinner than normal and deserve extra review"}
if direction > 0.3 and whale > 0.2:
return {"context": "buy-side pressure skew", "reason": "Directional pressure and larger-size activity are aligned to the same side"}
if direction < -0.3 and whale < -0.2:
return {"context": "sell-side pressure skew", "reason": "Directional pressure and larger-size activity are aligned to the same side"}
return {"context": "mixed context", "reason": "Pressure is mixed and no clean summary stands out"}
# Main loop
while True:
try:
read = get_context_read(SYMBOL)
print("[" + SYMBOL + "] " + read["context"] + ": " + read["reason"])
# Route the context into your dashboard or review workflow here
except Exception as e:
print("Error: " + str(e))
time.sleep(30)Key Concepts
- directional_pressure: -1 to +1, a synthesized read of which side has more weight in the current book and flow
- whale_conviction: -1 to +1, large-order placement patterns indicating stronger or weaker larger-size participation
- liquidity_risk: 0 to 1, higher values indicate thinner orderbook conditions and a less stable context snapshot
2. Real-time Monitoring Dashboard
Poll multiple symbols in parallel and display a live terminal-based dashboard.
Node.js
const API_URL = "https://api.depthsignal.io";
const API_KEY = "your-api-key-here";
const SYMBOLS = ["BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT", "XRPUSDT"];
async function fetchFeatures(symbol) {
const url = API_URL + "/v1/orderbook/features/" + symbol;
const res = await fetch(url, {
headers: { "X-API-Key": API_KEY }
});
if (!res.ok) throw new Error(symbol + ": " + res.status);
return res.json();
}
async function poll() {
const results = await Promise.allSettled(
SYMBOLS.map(s => fetchFeatures(s))
);
console.clear();
console.log("Symbol | Spread | SMS | OFI | Age(s)");
console.log("------------|----------|--------|----------|-------");
results.forEach(function(r, i) {
if (r.status === "fulfilled") {
// features is keyed per-exchange; pick binance (or first available)
var feats = r.value.features || {};
var d = feats.binance || Object.values(feats)[0] || {};
var fresh = r.value.data_freshness || {};
var fr = fresh.binance || Object.values(fresh)[0] || {};
var age = (fr.age_seconds != null) ? fr.age_seconds : "?";
console.log(
SYMBOLS[i].padEnd(12) + "| " +
(d.bid_ask_spread || 0).toFixed(5).padStart(8) + "| " +
(d.smart_money_score || 0).toFixed(3).padStart(6) + "| " +
(d.order_flow_imbalance || 0).toFixed(3).padStart(8) + "| " +
String(age).padStart(5)
);
}
});
}
// Poll every 10 seconds
setInterval(poll, 10000);
poll();Tips
- Use
Promise.allSettledso one failing symbol does not block others - Check
data_freshness(per-exchange age_seconds). If above 60s, data may be stale - Professional tier: 300 req/min. 5 symbols every 10s = 30 req/min (well within limits)
Rate Limit Considerations
All examples above respect rate limits:
| Tier | Rate | Budget |
|---|---|---|
| Starter access | 10/min | free, BTCUSDT |
| Trader | 60/min | ~1 symbol/sec |
| Professional | 300/min | ~5 symbols/sec |
| Expert | 1,500/min | ~25 symbols/sec |
| Enterprise | 1,000/min | ~16 symbols/sec/key |
Check X-RateLimit-Remaining response header to monitor usage. See the full documentation for details.