depthsignal
v1.0.0
Published
Official TypeScript SDK for the DepthSignal API — institutional-grade orderbook microstructure intelligence
Downloads
100
Maintainers
Readme
DepthSignal TypeScript SDK
v1.0.0 — Stable release
Official TypeScript/JavaScript client for the DepthSignal API — institutional-grade orderbook microstructure intelligence for crypto markets.
Target API: DepthSignal REST API v1
Requirements
- Node.js 18+ (uses native
fetch) - Zero production dependencies
Installation
npm install depthsignalQuick Start
import { DepthSignal } from "depthsignal";
const ds = new DepthSignal({ apiKey: "your-api-key" });
// Orderbook features (Basic+ tier)
const features = await ds.getOrderbookFeatures("BTCUSDT");
console.log(features.features["binance"]?.["vpin"]);
// Composite signals (Pro+ tier)
const composites = await ds.getCompositeSignals("BTCUSDT");
if (composites.directional_pressure > 0.7) {
console.log("Strong bullish pressure");
}
// Support/resistance zones (Pro+ tier)
const sr = await ds.getSupportResistance("BTCUSDT");
for (const zone of sr.zones) {
console.log(`${zone.type}: $${zone.price} (strength: ${zone.strength})`);
}Configuration
const ds = new DepthSignal({
apiKey: "your-api-key",
baseUrl: "https://api.depthsignal.io", // default
timeout: 10_000, // ms, default 10000
maxRetries: 2, // retries on 429/503/network, default 2
});The client enforces HTTPS in production. HTTP is only allowed for localhost and 127.0.0.1 during development.
Endpoints
Orderbook (Basic+ tier)
const features = await ds.getOrderbookFeatures("BTCUSDT");
const composites = await ds.getCompositeSignals("BTCUSDT"); // Pro+
const sr = await ds.getSupportResistance("BTCUSDT"); // Pro+Flow Intelligence
const overview = await ds.getFlowOverview(); // Enterprise
const asset = await ds.getFlowAsset("BTCUSDT"); // Enterprise
const liqs = await ds.getLiquidations("BTCUSDT"); // Pro+
const whales = await ds.getLargeTrades("BTCUSDT"); // Pro+
const cvd = await ds.getCVD("BTCUSDT"); // Pro+
const sentiment = await ds.getSentiment("BTCUSDT"); // Pro+
const sf = await ds.getSpotFutures("BTCUSDT"); // Enterprise
const derivs = await ds.getDerivatives("BTCUSDT"); // Enterprise
const pos = await ds.getPositioning("BTCUSDT"); // EnterpriseAggregated Timeframes (Pro+)
const aggFeatures = await ds.getAggregatedFeatures("BTCUSDT", {
timeframe: "4h",
exchange: "binance",
});
const aggComposites = await ds.getAggregatedComposites("BTCUSDT", {
timeframe: "1h",
});Venue Analytics
const venue = await ds.getVenueSelection("BTCUSDT"); // Pro+
const depth = await ds.getDepthResilience("BTCUSDT"); // Starter+
const events = await ds.getSpreadEvents("BTCUSDT", { // Starter+
threshold: 3,
});
const cost = await ds.getExecutionCost("BTCUSDT", { // Enterprise
tradeSizeUsd: 50000,
});
const corr = await ds.getCorrelation("BTCUSDT", "ETHUSDT"); // Pro+
const whale = await ds.getWhaleFlow("BTCUSDT"); // EnterpriseHistorical (Pro+ tier)
const hist = await ds.getHistoricalFeatures("BTCUSDT", {
exchange: "binance",
hours: 24,
limit: 500,
});
const histComp = await ds.getHistoricalComposites("BTCUSDT", { hours: 12 });Discovery & Health (Public)
const symbols = await ds.getSymbols();
const tiers = await ds.getTiers();
const health = await ds.getHealth();Real-Time Streaming (Enterprise)
const sub = ds.stream("BTCUSDT", {
onData: (event) => console.log("Received:", event),
onError: (err) => console.error("Stream error:", err),
onClose: () => console.log("Stream closed"),
reconnect: true, // default
maxReconnectDelay: 30_000, // default 30s
});
// Close after 60 seconds
setTimeout(() => sub.close(), 60_000);Error Handling
import {
DepthSignalError,
AuthenticationError,
TierAccessError,
RateLimitError,
NotFoundError,
ServerError,
ConnectionError,
} from "depthsignal";
try {
const features = await ds.getOrderbookFeatures("BTCUSDT");
} catch (err) {
if (err instanceof AuthenticationError) {
console.error("Invalid API key");
} else if (err instanceof TierAccessError) {
console.error("Upgrade your tier for this endpoint");
} else if (err instanceof RateLimitError) {
console.error(`Rate limited — retry after ${err.retryAfter}s`);
} else if (err instanceof NotFoundError) {
console.error("Symbol not found");
} else if (err instanceof ConnectionError) {
console.error("Could not reach the API");
} else if (err instanceof DepthSignalError) {
console.error(`API error ${err.statusCode}: ${err.detail}`);
}
}Version Sync
Both the TypeScript and Python SDKs follow the same semantic versioning and target the same DepthSignal API version (v1). Breaking API changes are released as major version bumps in both SDKs simultaneously.
License
MIT — Ravenna OÜ
