Integration Guides
Copy-paste examples for common use cases. All examples use the DepthSignal REST API.
1. Bot Signal Integration
Use DepthSignal composite signals to generate BUY/SELL/HOLD decisions. This example polls the API every 30 seconds and combines directional pressure, whale conviction, and liquidity risk into a decision signal.
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_signal(symbol):
"""Fetch composite signals and generate a decision."""
url = API_URL + "/v1/orderbook/composite/" + symbol
resp = requests.get(url, headers=HEADERS, timeout=10)
resp.raise_for_status()
data = resp.json()
signals = data.get("composites", {})
direction = signals.get("directional_pressure", 0)
whale = signals.get("whale_conviction", 0)
liquidity_risk = signals.get("liquidity_risk", 0)
if liquidity_risk > 0.7:
return {"action": "HOLD", "reason": "High liquidity risk"}
if direction > 0.3 and whale > 0.2:
return {"action": "BUY", "reason": "Bullish pressure detected"}
if direction < -0.3 and whale < -0.2:
return {"action": "SELL", "reason": "Bearish pressure detected"}
return {"action": "HOLD", "reason": "No clear signal"}
# Main loop
while True:
try:
signal = get_signal(SYMBOL)
print("[" + SYMBOL + "] " + signal["action"] + ": " + signal["reason"])
# Connect to your exchange API here to act on the signal
except Exception as e:
print("Error: " + str(e))
time.sleep(30)Key Concepts
- directional_pressure: -1 (bearish) to +1 (bullish), synthesized from OFI, trade flow, and order imbalance
- whale_conviction: -1 to +1, large order placement patterns indicating institutional positioning
- liquidity_risk: 0 to 1, higher values indicate thin orderbook, potential slippage
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 |
|---|---|---|
| Observer | 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.