@0xinsider/sdk
Official TypeScript SDK for the 0xinsider API: analytics for Polymarket sports and esports markets. Wallet grades, large trades, combos, profitable-wallet flows, market intel and OHLC candles, a live SSE feed, and signed webhooks.
The types are generated from the published OpenAPI document. The release check compares generated types and the operation table against the committed OpenAPI snapshot.
Requirements
- Node.js 22+ (uses native
fetch, ReadableStream, and node:crypto). Zero runtime dependencies.
- Every API call has a 15 s SDK deadline (
DEFAULT_TIMEOUT_MS). Set timeoutMs on the client or per call; null disables it. Only the SDK's deadline rejects with RequestTimeoutError (no status, body, or request id). An API call cancelled by the caller's signal rejects with its exact abort reason, including a caller-owned TimeoutError. streamFeed has no deadline; signed object downloads use their separate downloadTimeoutMs option.
- API call cancellation stays active while the response body is read and during retry backoff. The first signal to abort determines the rejection; no further attempt starts after cancellation. On runtimes without
AbortSignal.any, request-owned listeners are removed when the call finishes, including failures; one cancellation signal can be reused across pages without accumulating listeners.
baseUrl is the server URL, https://api.0xinsider.com by default or https://0xinsider.com/sandbox; a path on it is kept and the /api/v1/... operation paths are appended after it. It must be https:; http: is accepted only for a loopback host (localhost, 127.0.0.1, [::1]). The constructor throws otherwise, so the API key is never sent to an untrusted origin.
- An API key. Your key looks like
oxi_sk_live_.... Create one at 0xinsider.com/developers. The sandbox needs none.
Install
npm install @0xinsider/sdk
For local SDK development, build this repository and install it from the folder:
git clone https://github.com/0xinsider/0xinsider-node
(cd 0xinsider-node && npm ci && npm run build)
npm install ./0xinsider-node # from your project, with the path to the clone
The package is ESM-only (import, not require) and ships its own type declarations.
Development checks use npm run check-types and npm run lint. The SDK checks collection indexing and optional fields strictly: callers guard missing array entries, and request options omit absent fields. These checks preserve API payloads and caller-owned abort reasons.
The lint contract exceptions record the named compatibility aliases, exact abort reasons and stream cleanup behavior preserved by the configuration.
Try it with no key against the sandbox:
git clone https://github.com/0xinsider/0xinsider-node && cd 0xinsider-node
npm ci && npm run build && node examples/sandbox.mjs
Types
SDK 0.28.0 requires Node.js 22 or newer: engines.node is >=22, and the
package type-checks against Node 22's types. Node 18 reached end of life on
2025-04-30 and Node 20 on 2026-04-30. Request deadlines and caller signals now
combine through AbortSignal.any, which every supported Node version has.
Method names, request options and response types are unchanged; two scheduled
Pick of the Day doc comments are refreshed.
SDK 0.27.1 refreshes Pick of the Day field guidance and synchronizes the current
canonical response declarations. getMarketHolders.total is required in the
returned type, matching the existing API response; consumers constructing mock
values must include it. Existing webhook payload names remain available and use
the generated contract declarations. Request behavior and the Node.js 18+
requirement are unchanged.
API response types come from the published OpenAPI document
(https://0xinsider.com/api/v1/openapi.json), generated by
scripts/generate.mjs into src/schema.ts. All component schemas
are exported by name, and five per-operation maps (OperationPath,
OperationQuery, OperationBody, OperationData, OperationResponse) type
every convenience method, call, list and paginate by the operation they
name: the path parameters it takes, the query keys and values it documents,
the body it requires, and the envelope it answers with its own data and
meta (BatchResponseMeta on a batch, EventReplayMeta on the replay).
Nothing takes a type argument any more; the method knows its shape.
const trader = await client.getTrader("swisstony", { query: { expand: ["strategy"] } });
if (trader.object === "trader") {
trader.data?.grade; // Grade | null
trader.meta.request_id; // ResponseMeta, always present
}
const explore = await client.exploreMarkets({ sort: "trending", limit: 10 });
explore.data[0]; // ExploreEntry, and explore.facets is typed too
explore.data[0].title; // compile error: an ExploreEntry has no title
const batch = await client.batchGetTraders(["swisstony", "0xabc..."], { expand: ["trust"] });
if (batch.object === "trader_batch") batch.meta.request_cost; // BatchResponseMeta
client.listSuspiciousTrades({ min_grade: "S" }); // compile error: the route takes min_suspicion and severity
Every method forwards the same transport options, so a conditional read,
a deadline or a cancellation looks the same everywhere:
client.listLargeTradesConditional({ min_grade: "S", since }, { signal, timeoutMs: 5_000, maxRetries: 0, headers: { "If-None-Match": etag } }).
A list method such as listLargeTrades() throws on a 304; send
If-None-Match through a ...Conditional method or call(), which return the
typed not_modified result instead.
call, list, paginate, paginatePages and collect are typed the same
way when the operation id is a literal. Given an id chosen at runtime, or an
explicit type argument, they fall back to the loose form (path, query and
body as plain records, the generic { object, data, meta? } envelope back)
for the caller that asserts the shape itself.
npm run check regenerates from the committed snapshot and compares on every
push, so a contract change that nobody regenerated fails CI rather than
shipping as a stale type.
SDK 0.25.0 adds PnlCorrection: pnl.correction on a Trader, and pnl_correction on a LeaderboardEntry and a TrendingWallet. It is present only when 0xinsider corrects Polymarket's P&L for neg-risk conversions Polymarket misbooks, in either direction: cost charged to inactive placeholder outcomes and never booked as a loss, or shares a conversion minted that Polymarket's records leave out. markets_measured says how many of the wallet's converted markets the amount sums; markets_excluded, when present, counts markets left at Polymarket's figure because shares moved in or out by direct transfer. A correction is published only once every converted market of the wallet is checked; until then pnl.correction_pending is true on a Trader. The body's own P&L fields keep Polymarket's figures; correction.net_total is the total the 0xinsider profile shows and correction.realized is what the grade uses.
const trader = await client.getTrader("swisstony");
const total = trader.data.pnl.correction?.net_total ?? trader.data.pnl.net_total;
SDK 0.27.0 types 23 response fields as always present, because the API sends them on every response and earlier releases typed them field?: T. Among them: freshness and score_components on an ExploreMarket, pick_rank on a PickOfTheDayArchiveEntry, stake_usd and series on a PickOfTheDayHitRate, and large_trade_count in market flows. Code that checks them for undefined keeps compiling, and the checks can go. The same release removes monthly_quota.unavailable_reason from the usage type, which the API has never sent: code that reads it no longer compiles.
SDK 0.29.0 adds monthly_quota.unavailable_reason back to the usage type, now that GET /api/v1/usage sends it on every response: "usage_price_reconciliation_required" while the account's usage subscription carries a price billing has not reconciled to its plan (pay as you go stays off), otherwise null.
SDK 0.30.0 follows the API to sports and esports markets only. A market or event outside them throws MarketOutOfScopeError, the 404 market_out_of_scope: stop asking for it, because a retry cannot succeed. A category outside sports and esports is a 400 bad_request with error.param category. New types: pnl.in_scope (TraderPnlInScope) on a trader, report.market_scope on reports, product_scope on trader exports, Edge Hunter's opt-in admission: "most_held_48h", a departures list (EdgeHunterObservationDeparture) for cards that leave before kickoff, and category_avg_price on MarketHolder and PickHolder. Parameter descriptions and examples use sports and esports values only.
SDK 0.31.0 types the deprecated supersedes_pick_id on PickOfTheDayNoEntitledPicks as string | null, the same as every other Pick of the Day shape. Earlier releases typed it null. The API still always sends null. Code that assigns the field to a variable typed null no longer compiles: type it string | null, or stop reading it and identify picks by pick_id.
SDK 0.32.0 removes the old names from the September 2026 renames. Each removed name was an alias of the name that replaces it, so the replacement takes the same arguments and returns the same data. Code that uses an old name stops compiling; switch to the new name. The API paths behind the old methods still answer until their sunset on 2027-02-01, and call() and paginate() accept only the new operation ids.
| Removed |
Use |
listWhaleTrades(), WhaleTradeListParams |
listLargeTrades(), LargeTradeListParams |
listWhaleTradeHistory(), WhaleTradeHistoryParams |
listLargeTradeHistory(), LargeTradeHistoryParams |
getWhaleTrade() |
getLargeTrade() |
WhaleTrade, WhaleTradeDetail, WhaleTradeHistoryMeta |
LargeTrade, LargeTradeDetail, LargeTradeHistoryMeta |
listInsiderRadar(), InsiderRadarListParams |
listSuspiciousTrades(), SuspiciousTradesListParams |
getInsiderRadarFlag(), RadarFlag |
getSuspiciousTrade(), SuspiciousTrade |
getMarketIntel(), MarketIntel |
getMarketFlow(), MarketFlow |
batchGetMarketIntel(), BatchMarketIntelItem |
batchGetMarketFlow(), BatchMarketFlowItem |
listSmartMoneyFlows() |
listSharpMoneyFlows() |
getPlatforms() |
getCoverage() |
WhaleTradesInsertedEvent, WhaleTradesInsertedData |
LargeTradesInsertedEvent, LargeTradesInsertedData |
WhaleTraderSyncedEvent, WhaleTraderSyncedData |
TraderSyncedEvent, TraderSyncedData |
InsiderRadarFlagRaisedEvent, InsiderRadarFlagRaisedData |
SuspiciousTradeFlaggedEvent, SuspiciousTradeFlaggedData |
SmartMoneyFlowDetectedEvent, SmartMoneyFlowDetectedData |
SharpMoneyFlowDetectedEvent, SharpMoneyFlowDetectedData |
Two differences remain on the wire. The new methods call the new paths, so a response has the new object: large_trade instead of whale_trade, suspicious_trade instead of radar_flag, and market_flow and market_flow_batch instead of market_intel and market_intel_batch. The old webhook event names are still delivered, so a subscription made under an old name keeps the old type literal. WebhookEvent still includes those literals: narrow on event.type rather than on a removed event type.
SDK 0.40.0 types three blocks on game markets. Every listGameMarkets row and every getMarketSnapshot market carries settlement: how Polymarket's oracle settled or is settling the market (status observed, not_posed or unavailable, then oracle_status, payouts, result, winning_outcome_index, resolved_at and the rest; a null is unknown). getGame winner markets carry it too, and listGames with expand: ["settlement"] (#32706, #32896). On listGameMarkets, expand: ["quotes"] adds each outcome's quote, the cached price with its price_basis, best bid and best ask (#32893), and expand: ["trading_terms"] adds each row's trading_terms from the market's Gamma record: the fee schedule, reward settings, seconds_delay, tick_size and min_order_size_shares, the smallest order the CLOB accepts, in shares, not USDC (#32688, #32938). Each of the two adds 1 to the request cost. A quote or trading_terms whose status is unavailable has every figure null: read again after a few seconds.
const page = await client.listGameMarkets("nba-bos-orl-2026-11-01", { expand: ["quotes", "trading_terms"] });
for (const row of page.data) {
row.trading_terms?.min_order_size_shares; // number | null, in shares
row.outcomes[0]?.quote?.price; // number | null, 0 to 1
row.settlement.status; // "observed" | "not_posed" | "unavailable"
}
SDK 0.105.0 types protocol_version: "v1" for a market that trades on Polymarket's CTF exchanges, "v2" for one on Protocol V2, where an outcome's token_id is its V2 position id. It is on every listGameMarkets and listProps row, getFairPrice, the large-trade and position rows, the market snapshot, candles, close and trades reads, and position timelines. listGameMarkets and listProps take a protocol_version filter, and on listGameMarkets trading_terms.trading names where an order on the market is signed:
const v2 = await client.listGameMarkets("polyv2-nba-gsw-mem-2026-11-19", { protocol_version: "v2", expand: ["trading_terms"] });
for (const row of v2.data) {
row.protocol_version; // "v1" | "v2"
row.trading_terms?.trading?.exchange; // "ctf_exchange_v2" | "neg_risk_ctf_exchange_v2" | "exchange_v3"
row.trading_terms?.trading?.eip712_domain_version; // "2" | "3"
row.trading_terms?.trading?.verifying_contract; // the exchange's Polygon address
row.trading_terms?.trading?.balance_asset_type; // "CONDITIONAL" | "CONDITIONAL-V2"
}
SDK 0.106.0 types category_numbers (#36089): whether a wallet's category figures take its latest settlements. It is on every getSportLeaderboard row, every getCategoryLeaderboard and listCategoryLeaders row, and on getTrader with expand: ["categories"]. state is current, behind (an update for the wallet has waited over an hour; as_of is when the oldest waiting one was queued, and the figures stay served) or unknown (the server's check has no recent result: treat the figures as unverified, not current). New type: CategoryNumbers.
const board = await client.getSportLeaderboard("tennis");
for (const row of board.data.rows) {
if (row.category_numbers.state === "behind") row.category_numbers.as_of; // string, UTC
}