Docs

SDKs

TypeScript SDK

@itmatrixhq/core for Node 22+ and modern browsers — typed models, protobuf on request, response metadata, and grouped resources for the whole public API.

Source on GitHub · Python on PyPI · TypeScript on npm.

Install

sh
npm install @itmatrixhq/core

Node 22+ and modern browsers. Keep API keys on your server.

Quickstart

ts
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

MethodReturns
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)
ts
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

ts
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

API Explorer and API Pro keys can stream live GEX with SDK 1.2.0 or later. Install it with npm i @itmatrixhq/core@latest. Node 22 or later is required.

const client = new ITMClient({ apiKey: process.env.ITM_API_KEY });
const spy = client.stream.gex("SPY", { nearest: 20 });
spy.on("update", (book) => console.log(book.spot, book.netGex, book.flip));
spy.on("error", (error) => console.error(error));
await client.run();

client.stream.gex(symbol, options) returns a live book at once and connects in the background. Register handlers with on("update" | "status" | "error", fn). It returns a function that removes the handler. A handler can return a promise, and its next call waits for it. latest is the newest book at any moment, await ready() waits for the first one and await changed() for the next. Change the filter with update({ nearest: 40 }), update({ within: 0.02 }), update({ between: [590, 610] }) or update({ top: 10, by: "net" }). close() ends one book, and closing the client ends them all.

A Book iterates rows with strike, call, put and total, and has spot, netGex, flip, time, age, get(strike), rows, columns (typed arrays) and meta. Handlers and for await always get the newest book, never a backlog. stream.gex needs an itm_ key. See Streaming for events, recipes, limits and refusal reasons.

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.

ts
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);
}