SDKs
TypeScript SDK
@itmatrixhq/core for Node 22+ and modern browsers — typed models, protobuf on request, streams, and grouped resources for the whole public API.
Source on GitHub · Python on PyPI · TypeScript on npm.
Install
npm install @itmatrixhq/coreNode 22+ and modern browsers. Keep API keys on your server.
Quickstart
import { ITMClient } from "@itmatrixhq/core";
const client = new ITMClient({ apiKey: process.env.ITM_API_KEY });
const { data: grid, meta } = await client.getGex("SPY", { top: 10 });
console.log(grid.net_gex, grid.strikes[0]?.gex, meta.plane);Results keep data, meta, status, etag and requestId. Prices are dollars, timestamps epoch milliseconds, dates ISO calendar dates, and strikes and strike filters are integer thousandths (600_000 is $600).
The main methods
| Method | Returns |
|---|---|
getGex(symbol, { top, at, expiries, byExpiry }) | GexGrid |
getGexHistory(symbol, { date, from, to, top }) | Every capture of one session |
getGexReference(symbol, { date, basis }) | The exact persisted reference book |
getOptionChain(symbol, { expiry, strikeGte, strikeLte }) | Chain |
listExpirations(symbol) | ISO expiry dates |
listSymbols(symbolClass?), getSymbol(symbol), lookupSymbol(query) | Registry and identity models |
getBars(symbol, { from, to, timeframe, cursor }) | Bars; the next page's cursor is in meta.cursor |
getGexAnalysis(symbol, { levels }) | Net GEX, zero gamma and ranked visible levels (local) |
getBarsForPeriod(symbol, "today") | One page of New York calendar-period bars (local) |
const expiries = await client.listExpirations("SPY");
const chain = await client.getOptionChain("SPY", {
expiry: expiries.data[0], strikeGte: 590_000, strikeLte: 610_000,
});
for (const row of chain.data.rows) {
console.log(row.contract.expiry, row.contract.right, row.contract.strike / 1000, row.gamma);
}Grouped resources cover the rest of the public API: client.flow, client.offexchange, client.vol, client.market, client.reference, client.screener, client.economy, client.fundamentals, client.journal, client.watchlists, client.account, client.protocols, client.info. request<T>("/v2/…", options) is the escape hatch.
Protobuf
const client = new ITMClient({ apiKey: process.env.ITM_API_KEY, transport: "protobuf" });The get… methods return the same models under either transport. Domain conversion rejects a protobuf integer beyond JavaScript's safe range instead of rounding it. See Protobuf.
Streams
for await (const frame of client.stream.gex("SPY")) {
console.log(frame.symbol, frame.gexSnap?.netGex ?? frame.gexDelta);
}client.stream keeps one protobuf WebSocket with ticket renewal and reconnects; stocks, spot, gex and chain return subscriptions you iterate and close. See Streaming.
Errors and timeouts
Requests time out after 30 seconds per attempt (timeoutMs changes it). GET retries default to two on 429/502/503/504, each delay capped at 30 seconds; writes are never retried. ITMError carries the HTTP status, the server code, the message, the request id and any retry hint.
import { ITMClient, ITMError } from "@itmatrixhq/core";
try {
await client.getGex("SPX");
} catch (error) {
if (error instanceof ITMError) console.log(error.code, error.status, error.requestId);
}