Agents
Agent skill
A skill file that teaches a coding agent — Codex, Claude Code, or anything that reads SKILL.md — to use the ITMatrixHQ SDKs the way they are meant to be used.
Build market-data workflows on the ITMatrixHQ API, including GEX analysis, calendar bars, options flow, off-exchange views, public streams and response metadata. Prefers the itmatrix Python or @itmatrixhq/core TypeScript SDK when installed and calls documented public operations over HTTPS otherwise. Not for publishing packages or operating the backend.
Install the skill
Put SKILL.md in your agent's skills directory as itmatrix-api/SKILL.md. Installing the SDK package does not install agent instructions.
# Codex
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills/itmatrix-api"
curl -sSo "${CODEX_HOME:-$HOME/.codex}/skills/itmatrix-api/SKILL.md" \
https://docs.itmatrixhq.com/agents/itmatrix-api/SKILL.md
# Claude Code (per project)
mkdir -p .claude/skills/itmatrix-api
curl -sSo .claude/skills/itmatrix-api/SKILL.md https://docs.itmatrixhq.com/agents/itmatrix-api/SKILL.mdllms.txt
The API serves a machine-readable index for language models at https://api.itmatrixhq.com/llms.txt. Point an agent there when it needs to discover
endpoints; point it at this skill when it is writing code.
The skill
itmatrix-api/SKILL.md raw
ITMatrixHQ API
Choose how to call it
- SDK first when it is installed. Python:
itmatrix(itmatrix.ITMClientsync,itmatrix.AsyncITMClientasync). TypeScript:ITMClientfrom@itmatrixhq/core. The SDKs handle auth, the envelope, bounded retries, protobuf decoding and typed models. Check the installed version's README or types for signatures; this skill may outlive a package release. - Direct HTTPS is fine too. Use it when no SDK is installed, the language has none, or a named method does not cover what you need. Use
curl,httpx,fetchor the SDK'srequest("/v2/...")escape hatch. The servedGET /v2/openapi.jsonlists every operation with its parameters and schemas./v2/rest-protocol.protoand/v2/ws-protocol.protoare the protobuf schemas. - Stay on the documented public surface. Call only the
/v2operations that the OpenAPI document marksx-exposure: public. Fetching the document itself and the two.protofiles is always fine. App-only operations refuse API keys with 403, and neither an SDK method nor a hand-built request gets around that. Never call internal, undocumented or guessed routes, and skip the pre-/v2aliases.
Take credentials from the application's configured environment and keep them out of logs and generated output.
Direct HTTPS rules
- Base URL: the one the application configures. The default is the
DEFAULT_BASE_URLconstant that both SDKs export. - Auth: send
Authorization: Bearer itm_…on every request. - Media types:
Accept: application/jsonby default. Sendapplication/x-protobufonly on operations whose OpenAPI response lists it, and decode with the served.proto. Request no other media type. - Envelope: success is
{data, meta}. An error is{error: {code, message, details}}, and thex-request-idresponse header identifies the request. - Retries: retry only GETs that return 429, 502, 503 or 504. Honour
Retry-Afterand cap the attempts. Never retry a mutation blindly. - Caching: send
If-None-Matchwith a stored ETag. A 304 has no body, so reuse data only if you actually kept it. - Streams:
POST /v2/stream/ticket, then the WebSocket at/v2/wsframed by the public WebSocket schema (GexStrikeBookandGexStrikeBookUpdateonly). Prefer the SDK stream, which already handles tickets, reconnects and backpressure. Do not hand-build a keyed GEX stream. It needs the SDK protocol (see Streams).
Choose the smallest useful method
- Direct reads:
get_gex/getGex,get_option_chain/getOptionChain,get_bars/getBars. - For a New York calendar period, use
get_bars_for_period(symbol, "today")orgetBarsForPeriod(symbol, "today"). The other periods areweek_to_date,month_to_date,year_to_date, andcalendar_monthwith aYYYY-MMmonth. Today defaults to 1-minute bars and longer periods to daily bars. These return one page, not a complete observed month. - For GEX levels,
get_gex_analysis/getGexAnalysisfetches and analyzes in one call, andanalyze_gex/analyzeGexworks on a grid you already have. Servernet_gexand the nullableflip_pointgive net exposure and zero gamma. The positive and negative level rankings cover only the returned strike rows, sotopor tier limits can hide stronger levels. Do not call them full-chain walls, and do not infer market direction from the sign of exposure. flowgives bounded public options-flow views.offexchangegives the synthetic activity, concentration, profile and composition views. Live large trades need a symbol or a premium floor. EOD flow needs a session plus one of those. Server attestation and entitlements still apply.
Keep what the response says
- Keep
datatogether with its metadata, HTTP status, request ID and ETag whenever the caller needs provenance or cache behaviour. - Before presenting a result as current or complete, check freshness, coverage, session or capture, caps, and any
partialordelayedsignal. - Keep nulls as nulls. An unavailable zero gamma or a missing price is not zero.
- Units:
- GEX values are dollars of dealer hedging per $1 move. Each has a served
*_sharessibling in shares of the underlying; use it rather than dividing by a price yourself. - Timestamps ending in
_msare epoch milliseconds. - Strikes and strike filters are integer thousandths of dollars where the schema says so.
- On entitlement errors, surface the code and the request ID.
- For lists or bars, follow only the cursor the response provides (
meta.cursor). Bound the page and row counts, and stop on a missing or repeated cursor. Do not quietly turn a first page into a monthly aggregate or a full-history study.
Streams
Python streams prefer AsyncITMClient. TypeScript streams use client.stream. Keep one shared connection and a bounded set of subscriptions, and close them through their lifecycle methods. A ticket authorizes one connection handshake: mint a new ticket for a real reconnect, not because a healthy connection's ticket expired. Treat a backpressure error as data loss that needs an explicit recovery decision.
Live GEX book for API keys
SDK 1.2.0 adds a live GEX book for itm_ keys. API Explorer and API Pro keys can use it. If key streaming is switched off for the account, the key gets not_entitled_tier with the reason stream_preview. Do not retry that error. Check the installed SDK version before using the stream. 1.2.0 or later is required for this API.
- Python:
spy = client.stream.gex("SPY", nearest=20), thenspy.on("update", handler), and keep the program alive withawait client.run(). TypeScript:const spy = client.stream.gex("SPY", { nearest: 20 }),spy.on("update", handler),await client.run(). The call returns at once. Do not wrap it in your own loop. - Events:
update(aBook),status(connecting,live,reconnecting,closed),error(a handler failure or aStreamError). Readspy.latestfor the newest book at any time.await spy.ready()for the first,await spy.changed()for the next. Never busy-polllatest. - A
Bookiterates rows withstrike,call,put,total(call plus put, computed by the SDK). Header:spot,net_gex(netGex),flip(nullable),time,age.meta.changedlists the strikes that moved. Python hasdf(). Keep a nullflipas null.net_gexis the whole-chain total, not the sum of the listed strikes. The book has no open interest. Read the REST GEX grid when you need it. - The book holds the 120 strikes with the largest gross GEX (
|call| + |put|). Filters pick among those 120 and run in the SDK:nearest,within(a fraction, 0.02 is 2%),between(inclusive),topwithby=gross,net,callorput. Change them live withspy.update(...).nearest=20can have gaps when a near-spot strike is not in the top 120. - Conflation: handlers and iterators always get the newest book, never a backlog. A slow async handler skips intermediate books.
- A key receives GEX books and nothing else: call and put GEX for the 120 largest strikes, net GEX, the flip point and the underlying spot from the ITMatrixHQ price engine, about every 5 seconds. No trades, quotes, bars or chain data. Every other topic is refused for keys, and so are index symbols.
- One SDK client is one connection. Subscribe once per symbol and keep it open. Limits are per account: Explorer 5 connections and 25 subscriptions, Pro 100 and 1,000, and 50 subscriptions per connection. The server refuses over a limit and never evicts.
- Let the SDK reconnect. Do not add your own retry loop around it.
stream_preview,client_outdated,client_required,protobuf_requiredandproto_requiredare terminal.connection_limitneeds at least 30 seconds of backoff. - The stream requires the SDK protocol: protobuf, the
itmatrixhq.v1subprotocol and a client name. The server cannot verify the SDK was used. Do not present this as a security control. Details:docs/streaming.md.
Minimal examples
import os
import itmatrix as itm
client = itm.ITMClient(api_key=os.environ["ITM_API_KEY"]) # close() is optional
result = client.get_gex_analysis("SPY", levels=3)
print(result.data.net_gex, result.data.zero_gamma, result.data.levels_scope)
month = client.get_bars_for_period("SPY", "calendar_month", month="2026-09")
print(month.meta.get("cursor")) # continue if complete history is requiredimport { ITMClient } from "@itmatrixhq/core";
const client = new ITMClient({ apiKey: process.env.ITM_API_KEY }); // REST needs no close()
const analysis = await client.getGexAnalysis("SPY", { levels: 3 });
console.log(analysis.data.netGex, analysis.data.zeroGamma);curl -fsS -H "Authorization: Bearer $ITM_API_KEY" \
"$BASE_URL/v2/gex/SPY/grid?top=10" # BASE_URL is your configured base URL