@0xinsider/mcp 1.3.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +91 -0
  2. package/dist/cli-lib.d.ts.map +1 -1
  3. package/dist/cli-lib.js +9 -5
  4. package/dist/cli-lib.js.map +1 -1
  5. package/dist/cli.js +6 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/product-cli/errors.d.ts +7 -0
  10. package/dist/product-cli/errors.d.ts.map +1 -0
  11. package/dist/product-cli/errors.js +13 -0
  12. package/dist/product-cli/errors.js.map +1 -0
  13. package/dist/product-cli/index.d.ts +4 -0
  14. package/dist/product-cli/index.d.ts.map +1 -0
  15. package/dist/product-cli/index.js +372 -0
  16. package/dist/product-cli/index.js.map +1 -0
  17. package/dist/product-cli/oauth.d.ts +10 -0
  18. package/dist/product-cli/oauth.d.ts.map +1 -0
  19. package/dist/product-cli/oauth.js +245 -0
  20. package/dist/product-cli/oauth.js.map +1 -0
  21. package/dist/product-cli/storage.d.ts +20 -0
  22. package/dist/product-cli/storage.d.ts.map +1 -0
  23. package/dist/product-cli/storage.js +149 -0
  24. package/dist/product-cli/storage.js.map +1 -0
  25. package/dist/sdk/client.d.ts +765 -0
  26. package/dist/sdk/client.d.ts.map +1 -0
  27. package/dist/sdk/client.js +974 -0
  28. package/dist/sdk/client.js.map +1 -0
  29. package/dist/sdk/errors.d.ts +313 -0
  30. package/dist/sdk/errors.d.ts.map +1 -0
  31. package/dist/sdk/errors.js +521 -0
  32. package/dist/sdk/errors.js.map +1 -0
  33. package/dist/sdk/index.d.ts +26 -0
  34. package/dist/sdk/index.d.ts.map +1 -0
  35. package/dist/sdk/index.js +25 -0
  36. package/dist/sdk/index.js.map +1 -0
  37. package/dist/sdk/pagination.d.ts +76 -0
  38. package/dist/sdk/pagination.d.ts.map +1 -0
  39. package/dist/sdk/pagination.js +106 -0
  40. package/dist/sdk/pagination.js.map +1 -0
  41. package/dist/sdk/schema.d.ts +2372 -0
  42. package/dist/sdk/schema.d.ts.map +1 -0
  43. package/dist/sdk/schema.js +7 -0
  44. package/dist/sdk/schema.js.map +1 -0
  45. package/dist/sdk/stream.d.ts +182 -0
  46. package/dist/sdk/stream.d.ts.map +1 -0
  47. package/dist/sdk/stream.js +391 -0
  48. package/dist/sdk/stream.js.map +1 -0
  49. package/dist/sdk/webhooks.d.ts +163 -0
  50. package/dist/sdk/webhooks.d.ts.map +1 -0
  51. package/dist/sdk/webhooks.js +122 -0
  52. package/dist/sdk/webhooks.js.map +1 -0
  53. package/package.json +6 -3
@@ -0,0 +1,765 @@
1
+ /**
2
+ * Standalone 0xinsider API V1 client.
3
+ *
4
+ * Ported from the app's original repo-owned client (`web/src/lib/api-client`,
5
+ * removed in #9060; this package is now the sole client implementation). The
6
+ * `API_CLIENT_OPERATIONS` table below IS the contract surface:
7
+ * `scripts/check-sdk-openapi-drift.mjs` asserts it equals the set of operations
8
+ * with a `200` response in `web/public/api/v1/openapi.json`, so this package
9
+ * cannot silently diverge from the spec. That enforcement used to be a vitest
10
+ * suite, which the repository does not run -- the table shipped three
11
+ * operations short before #9687 replaced it with the runnable script, and
12
+ * #11894 deleted the suite.
13
+ *
14
+ * Differences from the retired app client (intentional):
15
+ * - No `@/lib/api-contracts` import; the operation table is inlined so the
16
+ * package has zero workspace coupling.
17
+ * - Errors throw the typed subclass hierarchy in `errors.ts` (the app client
18
+ * threw a single `OxinsiderApiError`).
19
+ * - Extra typed convenience methods for list/candle/webhook-event/stream
20
+ * surfaces and a typed `Grade` enum.
21
+ */
22
+ import type { OperationData, PickOfTheDay, PickOfTheDayArchive, ResponseMeta, SportsEdgeFunnelReport, SportsEdgeObservation, SportsEdgeSignal } from "./schema.js";
23
+ /**
24
+ * The envelope `meta` as THIS client hands it to a caller: everything the
25
+ * contract declares (`ResponseMeta`), plus `etag`.
26
+ *
27
+ * `etag` is a client-side addition, not a contract field. The server sends it
28
+ * as an `ETag` response HEADER and never in the body, so the OpenAPI document
29
+ * is right not to declare it; this client lifts it into `meta` so a caller can
30
+ * echo it on a conditional re-request without reaching for the raw headers
31
+ * (#14278 -- the hand-written `ResponseMeta` carried `etag` inline, which read
32
+ * as though the server sent it).
33
+ */
34
+ export type ClientResponseMeta = ResponseMeta & {
35
+ /** Lifted from the `ETag` response header by this client. */
36
+ etag?: string;
37
+ };
38
+ export type ApiClientMethod = "GET" | "POST" | "PATCH" | "DELETE";
39
+ /** Whether an operation requires the `oxi_sk_*` Bearer key. */
40
+ export type AuthMode = "none" | "bearer";
41
+ export interface ApiClientOperation {
42
+ readonly method: ApiClientMethod;
43
+ readonly path: string;
44
+ readonly operationId: string;
45
+ readonly auth: AuthMode;
46
+ }
47
+ /**
48
+ * The full V1 operation table. One row per OpenAPI operation that returns a
49
+ * `200`. Kept in lockstep with `web/public/api/v1/openapi.json` by
50
+ * `scripts/check-sdk-openapi-drift.mjs`. Do not add a row without a matching
51
+ * spec operation, and do not remove a spec operation without removing its row.
52
+ */
53
+ export declare const API_CLIENT_OPERATIONS: readonly [{
54
+ readonly method: "GET";
55
+ readonly path: "/api/v1/me";
56
+ readonly operationId: "getAccountIdentity";
57
+ readonly auth: "bearer";
58
+ }, {
59
+ readonly method: "GET";
60
+ readonly path: "/api/v1";
61
+ readonly operationId: "getApiDiscovery";
62
+ readonly auth: "none";
63
+ }, {
64
+ readonly method: "GET";
65
+ readonly path: "/api/v1/trader/{address}";
66
+ readonly operationId: "getTrader";
67
+ readonly auth: "bearer";
68
+ }, {
69
+ readonly method: "POST";
70
+ readonly path: "/api/v1/traders/batch";
71
+ readonly operationId: "batchGetTraders";
72
+ readonly auth: "bearer";
73
+ }, {
74
+ readonly method: "GET";
75
+ readonly path: "/api/v1/trader/{address}/position-timeline";
76
+ readonly operationId: "getPositionTimeline";
77
+ readonly auth: "bearer";
78
+ }, {
79
+ readonly method: "GET";
80
+ readonly path: "/api/v1/traders/{trader}/position-timeline";
81
+ readonly operationId: "getPositionTimelineById";
82
+ readonly auth: "bearer";
83
+ }, {
84
+ readonly method: "GET";
85
+ readonly path: "/api/v1/positions";
86
+ readonly operationId: "listPositions";
87
+ readonly auth: "bearer";
88
+ }, {
89
+ readonly method: "GET";
90
+ readonly path: "/api/v1/large-positions";
91
+ readonly operationId: "listLargePositions";
92
+ readonly auth: "bearer";
93
+ }, {
94
+ readonly method: "GET";
95
+ readonly path: "/api/v1/trader/{address}/pnl";
96
+ readonly operationId: "getTraderPnl";
97
+ readonly auth: "bearer";
98
+ }, {
99
+ readonly method: "GET";
100
+ readonly path: "/api/v1/trader/{address}/context";
101
+ readonly operationId: "getTraderContext";
102
+ readonly auth: "bearer";
103
+ }, {
104
+ readonly method: "GET";
105
+ readonly path: "/api/v1/trader/{address}/context.md";
106
+ readonly operationId: "getTraderContextMarkdown";
107
+ readonly auth: "bearer";
108
+ }, {
109
+ readonly method: "POST";
110
+ readonly path: "/api/v1/trader/{address}/export";
111
+ readonly operationId: "submitTraderExport";
112
+ readonly auth: "bearer";
113
+ }, {
114
+ readonly method: "GET";
115
+ readonly path: "/api/v1/trader/{address}/export/status";
116
+ readonly operationId: "getTraderExportStatus";
117
+ readonly auth: "bearer";
118
+ }, {
119
+ readonly method: "GET";
120
+ readonly path: "/api/v1/leaderboard/trending";
121
+ readonly operationId: "listTrendingWallets";
122
+ readonly auth: "bearer";
123
+ }, {
124
+ readonly method: "GET";
125
+ readonly path: "/api/v1/sports-edge-signals";
126
+ readonly operationId: "listSportsEdgeSignals";
127
+ readonly auth: "bearer";
128
+ }, {
129
+ readonly method: "GET";
130
+ readonly path: "/api/v1/sports-edge-observations";
131
+ readonly operationId: "listSportsEdgeObservations";
132
+ readonly auth: "bearer";
133
+ }, {
134
+ readonly method: "GET";
135
+ readonly path: "/api/v1/whale-trades";
136
+ readonly operationId: "listWhaleTrades";
137
+ readonly auth: "bearer";
138
+ }, {
139
+ readonly method: "GET";
140
+ readonly path: "/api/v1/whale-trades/history";
141
+ readonly operationId: "listWhaleTradeHistory";
142
+ readonly auth: "bearer";
143
+ }, {
144
+ readonly method: "GET";
145
+ readonly path: "/api/v1/whale-trades/{id}/counterparties/executions";
146
+ readonly operationId: "listWhaleTradeCounterpartyExecutions";
147
+ readonly auth: "bearer";
148
+ }, {
149
+ readonly method: "GET";
150
+ readonly path: "/api/v1/whale-trades/{id}/counterparties/executions/{execution_id}/makers";
151
+ readonly operationId: "listWhaleTradeCounterpartyMakers";
152
+ readonly auth: "bearer";
153
+ }, {
154
+ readonly method: "GET";
155
+ readonly path: "/api/v1/content/search";
156
+ readonly operationId: "searchContent";
157
+ readonly auth: "bearer";
158
+ }, {
159
+ readonly method: "GET";
160
+ readonly path: "/api/v1/whale-trades/{id}";
161
+ readonly operationId: "getWhaleTrade";
162
+ readonly auth: "bearer";
163
+ }, {
164
+ readonly method: "GET";
165
+ readonly path: "/api/v1/leaderboard";
166
+ readonly operationId: "listLeaderboard";
167
+ readonly auth: "bearer";
168
+ }, {
169
+ readonly method: "GET";
170
+ readonly path: "/api/v1/markets/search";
171
+ readonly operationId: "searchMarkets";
172
+ readonly auth: "bearer";
173
+ }, {
174
+ readonly method: "GET";
175
+ readonly path: "/api/v1/markets/explore";
176
+ readonly operationId: "exploreMarkets";
177
+ readonly auth: "bearer";
178
+ }, {
179
+ readonly method: "GET";
180
+ readonly path: "/api/v1/markets/smart-money-flows";
181
+ readonly operationId: "listSmartMoneyFlows";
182
+ readonly auth: "bearer";
183
+ }, {
184
+ readonly method: "GET";
185
+ readonly path: "/api/v1/markets/sharp-money-flows";
186
+ readonly operationId: "listSharpMoneyFlows";
187
+ readonly auth: "bearer";
188
+ }, {
189
+ readonly method: "GET";
190
+ readonly path: "/api/v1/platforms";
191
+ readonly operationId: "getPlatforms";
192
+ readonly auth: "none";
193
+ }, {
194
+ readonly method: "GET";
195
+ readonly path: "/api/v1/market/{condition_id}/intel";
196
+ readonly operationId: "getMarketIntel";
197
+ readonly auth: "bearer";
198
+ }, {
199
+ readonly method: "POST";
200
+ readonly path: "/api/v1/markets/intel/batch";
201
+ readonly operationId: "batchGetMarketIntel";
202
+ readonly auth: "bearer";
203
+ }, {
204
+ readonly method: "GET";
205
+ readonly path: "/api/v1/market/{condition_id}/snapshot";
206
+ readonly operationId: "getMarketSnapshot";
207
+ readonly auth: "bearer";
208
+ }, {
209
+ readonly method: "GET";
210
+ readonly path: "/api/v1/market/{condition_id}/context.md";
211
+ readonly operationId: "getMarketContextMarkdown";
212
+ readonly auth: "bearer";
213
+ }, {
214
+ readonly method: "GET";
215
+ readonly path: "/api/v1/market/{condition_id}/candles";
216
+ readonly operationId: "getMarketCandles";
217
+ readonly auth: "bearer";
218
+ }, {
219
+ readonly method: "GET";
220
+ readonly path: "/api/v1/insider-radar";
221
+ readonly operationId: "listInsiderRadar";
222
+ readonly auth: "bearer";
223
+ }, {
224
+ readonly method: "GET";
225
+ readonly path: "/api/v1/insider-radar/{id}";
226
+ readonly operationId: "getInsiderRadarFlag";
227
+ readonly auth: "bearer";
228
+ }, {
229
+ readonly method: "GET";
230
+ readonly path: "/api/v1/events/feed/since";
231
+ readonly operationId: "getEventReplaySince";
232
+ readonly auth: "bearer";
233
+ }, {
234
+ readonly method: "GET";
235
+ readonly path: "/api/v1/stream";
236
+ readonly operationId: "getStream";
237
+ readonly auth: "bearer";
238
+ }, {
239
+ readonly method: "GET";
240
+ readonly path: "/api/v1/webhooks";
241
+ readonly operationId: "listWebhooks";
242
+ readonly auth: "bearer";
243
+ }, {
244
+ readonly method: "POST";
245
+ readonly path: "/api/v1/webhooks";
246
+ readonly operationId: "createWebhook";
247
+ readonly auth: "bearer";
248
+ }, {
249
+ readonly method: "GET";
250
+ readonly path: "/api/v1/webhooks/{id}";
251
+ readonly operationId: "getWebhook";
252
+ readonly auth: "bearer";
253
+ }, {
254
+ readonly method: "PATCH";
255
+ readonly path: "/api/v1/webhooks/{id}";
256
+ readonly operationId: "updateWebhook";
257
+ readonly auth: "bearer";
258
+ }, {
259
+ readonly method: "DELETE";
260
+ readonly path: "/api/v1/webhooks/{id}";
261
+ readonly operationId: "deleteWebhook";
262
+ readonly auth: "bearer";
263
+ }, {
264
+ readonly method: "POST";
265
+ readonly path: "/api/v1/webhooks/{id}/verify";
266
+ readonly operationId: "verifyWebhook";
267
+ readonly auth: "bearer";
268
+ }, {
269
+ readonly method: "POST";
270
+ readonly path: "/api/v1/webhooks/{id}/rotate-secret";
271
+ readonly operationId: "rotateWebhookSecret";
272
+ readonly auth: "bearer";
273
+ }, {
274
+ readonly method: "GET";
275
+ readonly path: "/api/v1/webhooks/events";
276
+ readonly operationId: "listWebhookEvents";
277
+ readonly auth: "bearer";
278
+ }, {
279
+ readonly method: "GET";
280
+ readonly path: "/api/v1/webhooks/{id}/deliveries";
281
+ readonly operationId: "listWebhookDeliveries";
282
+ readonly auth: "bearer";
283
+ }, {
284
+ readonly method: "POST";
285
+ readonly path: "/api/v1/webhooks/{id}/deliveries/{delivery_id}/redeliver";
286
+ readonly operationId: "redeliverWebhookDelivery";
287
+ readonly auth: "bearer";
288
+ }, {
289
+ readonly method: "GET";
290
+ readonly path: "/api/v1/health";
291
+ readonly operationId: "getHealth";
292
+ readonly auth: "none";
293
+ }, {
294
+ readonly method: "POST";
295
+ readonly path: "/api/v1/mcp";
296
+ readonly operationId: "createMcpJsonRpcResponse";
297
+ readonly auth: "bearer";
298
+ }, {
299
+ readonly method: "GET";
300
+ readonly path: "/api/v1/mcp";
301
+ readonly operationId: "openMcpEventStream";
302
+ readonly auth: "bearer";
303
+ }, {
304
+ readonly method: "GET";
305
+ readonly path: "/api/v1/reports";
306
+ readonly operationId: "getReports";
307
+ readonly auth: "bearer";
308
+ }, {
309
+ readonly method: "GET";
310
+ readonly path: "/api/v1/reports/daily";
311
+ readonly operationId: "getDailyReportSnapshot";
312
+ readonly auth: "bearer";
313
+ }, {
314
+ readonly method: "GET";
315
+ readonly path: "/api/v1/reports/weekly";
316
+ readonly operationId: "getWeeklyReportSnapshot";
317
+ readonly auth: "bearer";
318
+ }, {
319
+ readonly method: "GET";
320
+ readonly path: "/api/v1/reports/monthly";
321
+ readonly operationId: "getMonthlyReportSnapshot";
322
+ readonly auth: "bearer";
323
+ }, {
324
+ readonly method: "GET";
325
+ readonly path: "/api/v1/trader/{address}/export";
326
+ readonly operationId: "getTraderExportSnapshot";
327
+ readonly auth: "bearer";
328
+ }, {
329
+ readonly method: "GET";
330
+ readonly path: "/api/v1/usage";
331
+ readonly operationId: "getUsage";
332
+ readonly auth: "bearer";
333
+ }, {
334
+ readonly method: "GET";
335
+ readonly path: "/api/v1/pick-of-the-day";
336
+ readonly operationId: "getPickOfTheDay";
337
+ readonly auth: "bearer";
338
+ }, {
339
+ readonly method: "GET";
340
+ readonly path: "/api/v1/pick-of-the-day/archive";
341
+ readonly operationId: "getPickOfTheDayArchive";
342
+ readonly auth: "bearer";
343
+ }];
344
+ export type ApiOperationId = (typeof API_CLIENT_OPERATIONS)[number]["operationId"];
345
+ /**
346
+ * Trader skill grade. Source of truth:
347
+ * `components.schemas.Trader.properties.grade.enum` (S highest, F lowest).
348
+ */
349
+ export declare const GRADES: readonly ["S", "A", "B", "C", "D", "F"];
350
+ export type Grade = (typeof GRADES)[number];
351
+ export type ApiQueryValue = string | number | boolean | null | undefined | readonly (string | number | boolean)[];
352
+ export interface ApiRequestOptions {
353
+ path?: Record<string, string | number>;
354
+ query?: Record<string, ApiQueryValue>;
355
+ body?: unknown;
356
+ headers?: Record<string, string>;
357
+ /** Cooperative cancellation; composed with the request deadline. */
358
+ signal?: AbortSignal;
359
+ /**
360
+ * Per-call deadline in ms, overriding the client default; `null` disables
361
+ * it for this call. The SSE stream (`streamFeed`) never has one. Retries
362
+ * share this one deadline: no retry is started that cannot finish inside it.
363
+ */
364
+ timeoutMs?: number | null;
365
+ /**
366
+ * Retries for this call, overriding the client's `maxRetries` (#14281).
367
+ * `0` sends exactly one request, which is the SDK's behaviour before retries.
368
+ */
369
+ maxRetries?: number;
370
+ /**
371
+ * Sent as the `Idempotency-Key` header. The API honours it on `createWebhook`,
372
+ * `updateWebhook`, `deleteWebhook`, `rotateWebhookSecret` and
373
+ * `redeliverWebhookDelivery`: a replay with the same key and body returns the
374
+ * first result instead of repeating the write.
375
+ * A write carrying a key is also the only non-GET request the SDK retries.
376
+ * On `IdempotencyInProgressError`, retry with the SAME key and body.
377
+ */
378
+ idempotencyKey?: string;
379
+ }
380
+ export interface ApiClientOptions {
381
+ /**
382
+ * API base, e.g. `https://api.0xinsider.com`. Trailing slashes are trimmed.
383
+ */
384
+ baseUrl?: string;
385
+ /** The `oxi_sk_live_*` secret API key. */
386
+ apiKey?: string;
387
+ /** Override the global `fetch` (e.g. for testing or a proxy agent). */
388
+ fetch?: typeof fetch;
389
+ /**
390
+ * Deadline for every request, connect to body, in ms. Default
391
+ * `DEFAULT_TIMEOUT_MS` (15 000); `null` disables it. A request that misses
392
+ * it rejects with `RequestTimeoutError`. Long-lived reads (`streamFeed`)
393
+ * are not subject to it (#11115).
394
+ */
395
+ timeoutMs?: number | null;
396
+ /**
397
+ * How many times a failed idempotent request is retried (#14281). Default
398
+ * `DEFAULT_MAX_RETRIES` (2); `0` disables retries.
399
+ *
400
+ * Retried: a GET, or a write carrying an `Idempotency-Key`, that failed with
401
+ * 429, 502, 503, 504, or a network error before any response. The wait is the
402
+ * response's `Retry-After` plus up to 250 ms of jitter when present, otherwise
403
+ * a jittered exponential backoff from 500 ms capped at 8 s. A `Retry-After`
404
+ * longer than 60 s is not waited out; the error is thrown so the caller can
405
+ * schedule it. Never retried: 400, 401, 402, 403, 404, 409, 500, a write
406
+ * without a key, a timeout, or a caller abort. A retry never starts unless it
407
+ * can finish inside `timeoutMs`, and a caller `AbortSignal` ends a backoff at
408
+ * once.
409
+ */
410
+ maxRetries?: number;
411
+ }
412
+ /** Default production API base used when `baseUrl` is omitted. */
413
+ export declare const DEFAULT_BASE_URL = "https://api.0xinsider.com";
414
+ /** Default per-request deadline; see `ApiClientOptions.timeoutMs`. */
415
+ export declare const DEFAULT_TIMEOUT_MS = 15000;
416
+ /** Default retry budget; see `ApiClientOptions.maxRetries`. */
417
+ export declare const DEFAULT_MAX_RETRIES = 2;
418
+ /**
419
+ * The API key travels as a bearer header on every request, so the base URL
420
+ * decides who receives it. Only `https:` is accepted, with `http:` allowed for
421
+ * a loopback host (a local backend on `localhost` or `127.0.0.1`). Anything
422
+ * else throws from the constructor, before any request is sent (#11115).
423
+ */
424
+ export declare function assertTrustedBaseUrl(baseUrl: string): URL;
425
+ /**
426
+ * One signal that aborts on the deadline OR when the caller's signal aborts.
427
+ * Uses native composition where available. The manual fallback removes both
428
+ * source listeners when either source aborts.
429
+ */
430
+ export declare function composeSignals(timeoutMs: number | null, caller?: AbortSignal): AbortSignal | undefined;
431
+ /** Standard single-resource envelope: `{ object, data, meta }`. */
432
+ export interface ApiEnvelope<T> {
433
+ object: string;
434
+ data: T;
435
+ meta?: ClientResponseMeta;
436
+ }
437
+ /** Stripe-style list envelope: `{ object: "list", data, has_more, next_cursor, total?, meta }`. */
438
+ export interface ApiListEnvelope<T> {
439
+ object: "list";
440
+ data: T[];
441
+ has_more: boolean;
442
+ next_cursor?: string | null;
443
+ total?: number | null;
444
+ meta?: ClientResponseMeta;
445
+ /**
446
+ * When this body was computed, on endpoints that publish a freshness envelope
447
+ * (`markets/explore` today). Absent elsewhere.
448
+ *
449
+ * Pair it with `fresh_for_seconds` to bound how long you reuse the body:
450
+ * `fresh_for_seconds - age(computed_at)`. The remainder is deliberately not
451
+ * pre-subtracted, because a cached body cannot carry a number that changes
452
+ * while it sits in a cache. Both are excluded from the `ETag` validator, so a
453
+ * body recomputed with identical data keeps its validator.
454
+ */
455
+ computed_at?: string;
456
+ /** How long the body computed at `computed_at` is good for, in seconds. */
457
+ fresh_for_seconds?: number;
458
+ }
459
+ export type CategorySkillStatus = "live" | "insufficient" | "stale" | "unknown" | "degraded";
460
+ export interface CategorySkillStatusCounts {
461
+ live: number;
462
+ insufficient: number;
463
+ stale: number;
464
+ unknown: number;
465
+ degraded: number;
466
+ }
467
+ export interface SportsEdgeSignalsParams extends ListParams {
468
+ category?: string;
469
+ horizon_hours?: number;
470
+ min_grade?: "S" | "A" | "B";
471
+ }
472
+ /** Observation cohorts exposed by `listSportsEdgeObservations`. */
473
+ export type SportsEdgeObservationCohort = "wider_holder" | "in_play" | "emerging_pile";
474
+ /** Source of the provider holder snapshot used to build an observation. */
475
+ export type SportsEdgeObservationProviderSource = "cached" | "live";
476
+ /** Why a sport's upcoming-board source is (un)available in the funnel report. */
477
+ export type SportsEdgeObservationBoardUpcomingStatus = "unknown" | "not_configured" | "available" | "capacity_limited" | "source_unavailable" | "cold_unavailable" | "deadline_unavailable";
478
+ /** Scope attribution for an unavailable upcoming-board union. */
479
+ export type SportsEdgeObservationBoardUnavailableScope = "category" | "nfl" | "cfb" | "nba" | "wnba" | "nhl" | "mls" | "valorant" | "league-of-legends" | "counter-strike-2" | "dota-2" | "registry" | "union" | "wave";
480
+ /** Truthful state of the cross-market directional read. */
481
+ export type SportsEdgeObservationDirectionalStatus = "available" | "unknown_ungrouped" | "unknown_stale" | "unavailable";
482
+ /**
483
+ * Provider binary-column selector for observation markets: 0 selects
484
+ * outcome_yes/token_id_yes; 1 selects outcome_no/token_id_no. Use piled_side,
485
+ * not this index, for participant identity.
486
+ */
487
+ export type SportsEdgeObservationOutcomeIndex = 0 | 1;
488
+ /** Closed grade vocabulary for the best holder grade on an observation. */
489
+ export type SportsEdgeObservationTopGrade = "S" | "A" | "B";
490
+ /** Canonical sports emitted by observation responses. */
491
+ export type SportsEdgeObservationSport = "Basketball" | "Football" | "Baseball" | "Hockey" | "MMA" | "Boxing" | "Soccer" | "Cricket" | "Golf" | "Tennis" | "Esports" | "Racing" | "Table Tennis" | "Pickleball";
492
+ /** Full list response, including the observation snapshot and accountable funnel. */
493
+ export interface SportsEdgeObservationsResponse extends ApiListEnvelope<SportsEdgeObservation> {
494
+ next_cursor: string | null;
495
+ snapshot_as_of: string;
496
+ /**
497
+ * Snapshot-wide operational/unknown-completeness verdict. True means treat
498
+ * the evidence as partial; fully accounted `capacity_limited` rows alone do
499
+ * not set it.
500
+ */
501
+ degraded: boolean;
502
+ funnel: SportsEdgeFunnelReport;
503
+ meta: ClientResponseMeta;
504
+ }
505
+ export interface SportsEdgeObservationsParams extends ListParams {
506
+ cohort: SportsEdgeObservationCohort;
507
+ category?: string;
508
+ }
509
+ /**
510
+ * One qualifying category expert on a Pick of the Day's backed side.
511
+ *
512
+ * Every threshold below holds BY CONSTRUCTION -- the selector only ever freezes a wallet that
513
+ * cleared all of them -- so a consumer can render the numbers without re-checking them.
514
+ */
515
+ export interface PickQualifyingExpert {
516
+ /** Policy 6 admission exception; absent on earlier frozen policies. */
517
+ lane?: "standard" | "longshot_specialist";
518
+ /** Answered, index-scoped provider probability, present only on specialist lanes. */
519
+ lane_probability?: number;
520
+ lane_probability_source?: "p";
521
+ address: string;
522
+ name?: string | null;
523
+ /** Public V1 exposes `S` or `A`; internal policy v2 also admits B. */
524
+ grade?: string | null;
525
+ /**
526
+ * The canonical sport BUCKET the rate below was measured over (for example `Basketball`).
527
+ *
528
+ * Label `win_rate` with THIS field, never with the pick's `display_category`: that names an
529
+ * exact league (NBA/WNBA/NFL/NHL/MLB/UFC) which folds into a broader bucket, so rendering
530
+ * "68% of their NBA markets" for a Basketball-wide rate publishes a false quantified claim.
531
+ */
532
+ canonical_category: string;
533
+ /**
534
+ * Share of this wallet's resolved markets in `canonical_category` whose realized P&L came out
535
+ * positive, as a 0..1 fraction. Above 0.60. Scale x100 at the display edge. `null` for an
536
+ * expert who qualified on the category-skill v2 definition only (`source` = `v2`).
537
+ */
538
+ win_rate: number | null;
539
+ /** Resolved markets in `canonical_category` behind `win_rate`. At least 10. `null` with it. */
540
+ n_resolved: number | null;
541
+ /**
542
+ * Which definition qualified the wallet: `v1` (the profitability rate above) or `v2` (the
543
+ * forward-only category-skill calibration edge below). Absent on picks frozen before the v2
544
+ * definition existed; read absence as `v1`. A Tennis pick frozen under gate policy v4 or later
545
+ * carries `v2` only: a v1 rate stopped qualifying a tennis expert at v4. A Tennis pick frozen
546
+ * under an earlier policy can still carry `v1` with a win rate.
547
+ */
548
+ source?: "v1" | "v2";
549
+ /**
550
+ * 95% lower bound of the wallet's mean calibration edge over the market price in
551
+ * `canonical_category`, in probability units (0.08 = 8 points). Positive by construction for
552
+ * a `v2` expert; present on a `v1` expert only when the wallet also has a live v2 row.
553
+ */
554
+ edge_lower_95?: number | null;
555
+ /** Point estimate behind `edge_lower_95`. */
556
+ edge_mean?: number | null;
557
+ /**
558
+ * Independent canonical events behind the edge. Clears the v2 sample floor for a `v2`
559
+ * expert; the floor is the selector's and is not published.
560
+ */
561
+ independent_event_count?: number | null;
562
+ /**
563
+ * Polymarket's own `currentValue` for this wallet on the backed outcome, in USD, as of
564
+ * selection. Clears the lane's net-position floor at selection; the floor is the selector's,
565
+ * has changed between gate policies, and is not published.
566
+ */
567
+ position_usd: number;
568
+ /**
569
+ * The same wallet's `currentValue` on the OTHER outcome of this market, in USD, as of
570
+ * selection. From gate policy v5 the floor is read on the net: `position_usd` minus this
571
+ * value clears the lane's floor, so a wallet long both sides does not qualify. Absent on picks
572
+ * frozen before v5, which never read the leg; 0 is a measured one-way position.
573
+ */
574
+ opposite_position_usd?: number | null;
575
+ /**
576
+ * When the skill read model behind the evidence was last rebuilt: `trader_category_stats`
577
+ * for a `source: v1` expert, `category_skill_v2_current.as_of` for a `source: v2` expert.
578
+ */
579
+ stats_computed_at: string;
580
+ }
581
+ /**
582
+ * Tennis tour a competitor belongs to. Only `atp` and `wta` name a gender: the
583
+ * ITF World Tennis Tour runs men's and women's events and the provider does not
584
+ * say which, so `itf` means tennis with gender unknown.
585
+ */
586
+ export type TennisTour = "atp" | "wta" | "itf";
587
+ /**
588
+ * The daily editorial Pick of the Day. Single-object envelope for
589
+ * `getPickOfTheDay` (`GET /api/v1/pick-of-the-day`). Field names mirror the
590
+ * JSON wire shape (snake_case); the backend omits null/absent optional fields.
591
+ * The outer object retains the historical first-pick fields and `picks` carries
592
+ * the ordered daily picks, normally three to six items and never more than six.
593
+ * A published pick whose holder proof is not readable yet is listed in
594
+ * `proof_pending_picks` instead of `picks` (#10698).
595
+ */
596
+ /** Typed 304 result returned for a matching `If-None-Match` conditional GET. */
597
+ export interface ApiNotModifiedResponse {
598
+ object: "not_modified";
599
+ data: null;
600
+ meta: {
601
+ status: 304;
602
+ etag?: string;
603
+ request_id?: string;
604
+ [key: string]: unknown;
605
+ };
606
+ }
607
+ export type ApiClientResponse<T> = ApiEnvelope<T> | ApiNotModifiedResponse;
608
+ /** Shared paging params accepted by Stripe-style list endpoints. */
609
+ export interface ListParams {
610
+ limit?: number;
611
+ cursor?: string;
612
+ [key: string]: ApiQueryValue;
613
+ }
614
+ /** `GET /api/v1/leaderboard` -> parameters -> strategy (`web/public/api/v1/openapi.json`). */
615
+ export declare const LEADERBOARD_STRATEGIES: readonly ["accumulator", "algo_trader", "arbitrageur", "directional", "event_driven", "market_maker", "momentum", "scalper", "speculator", "swing_trader"];
616
+ export type LeaderboardStrategy = (typeof LEADERBOARD_STRATEGIES)[number];
617
+ /**
618
+ * Query parameters for `GET /api/v1/leaderboard`. The board has no `min_grade`:
619
+ * it only holds S, A, and B traders, and the backend drops an unknown query key
620
+ * instead of rejecting it (#10642).
621
+ */
622
+ export interface LeaderboardListParams extends ListParams {
623
+ category?: string;
624
+ strategy?: LeaderboardStrategy;
625
+ }
626
+ /** Query parameters for `GET /api/v1/leaderboard/trending`. */
627
+ export interface TrendingWalletsParams extends ListParams {
628
+ window?: "7d" | "30d";
629
+ }
630
+ /** Query parameters shared by the V1 whale-trade list and history reads. */
631
+ export interface WhaleTradeListParams extends ListParams {
632
+ min_size?: number;
633
+ category?: string;
634
+ min_grade?: Grade;
635
+ /** Keep only rows with persisted suspicion_score >= 60. */
636
+ suspicious_only?: boolean;
637
+ }
638
+ /** Query parameters for the V1 historical whale-trade replay. */
639
+ export interface WhaleTradeHistoryParams extends WhaleTradeListParams {
640
+ condition_id?: string;
641
+ trader?: string;
642
+ from?: string;
643
+ to?: string;
644
+ platform?: "polymarket" | "all";
645
+ }
646
+ export declare class OxinsiderApiClient {
647
+ private readonly baseUrl;
648
+ private readonly apiKey?;
649
+ private readonly fetchImpl;
650
+ private readonly timeoutMs;
651
+ private readonly maxRetries;
652
+ constructor(options?: ApiClientOptions);
653
+ /**
654
+ * Execute any operation by id. Throws the matching `OxinsiderApiError`
655
+ * subclass on a non-2xx response, returns a typed `not_modified` result for a
656
+ * 304, and otherwise returns the parsed `{ object, data, meta }` envelope.
657
+ */
658
+ call<T>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
659
+ /**
660
+ * Execute a Stripe-style list operation and return the list envelope.
661
+ * Use `paginate()` (in `pagination.ts`) to auto-follow `next_cursor`.
662
+ */
663
+ list<T>(operationId: ApiOperationId, options?: ApiRequestOptions): Promise<ApiListEnvelope<T>>;
664
+ getTrader<T = OperationData["getTrader"]>(address: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
665
+ getTraderPnl<T = OperationData["getTraderPnl"]>(address: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
666
+ batchGetTraders<T = OperationData["batchGetTraders"]>(identifiers: readonly string[], options?: Omit<ApiRequestOptions, "body">): Promise<ApiClientResponse<T>>;
667
+ listLeaderboard<T = OperationData["listLeaderboard"][number]>(params?: LeaderboardListParams): Promise<ApiListEnvelope<T>>;
668
+ listTrendingWallets<T = OperationData["listTrendingWallets"][number]>(params?: TrendingWalletsParams): Promise<ApiListEnvelope<T>>;
669
+ listWhaleTrades<T = OperationData["listWhaleTrades"][number]>(params?: WhaleTradeListParams): Promise<ApiListEnvelope<T>>;
670
+ listWhaleTradeHistory<T = OperationData["listWhaleTradeHistory"][number]>(params?: WhaleTradeHistoryParams): Promise<ApiListEnvelope<T>>;
671
+ listPositions<T = OperationData["listPositions"][number]>(params?: ListParams & {
672
+ min_grade?: Grade;
673
+ }): Promise<ApiListEnvelope<T>>;
674
+ listLargePositions<T = OperationData["listLargePositions"][number]>(params?: ListParams & {
675
+ min_grade?: Grade;
676
+ }): Promise<ApiListEnvelope<T>>;
677
+ listSmartMoneyFlows<T = OperationData["listSmartMoneyFlows"][number]>(params?: ListParams & {
678
+ min_grade?: Grade;
679
+ }): Promise<ApiListEnvelope<T>>;
680
+ /** Canonical alias of {@link listSmartMoneyFlows} (epic #6912). */
681
+ listSharpMoneyFlows<T = OperationData["listSharpMoneyFlows"][number]>(params?: ListParams & {
682
+ min_grade?: Grade;
683
+ }): Promise<ApiListEnvelope<T>>;
684
+ /**
685
+ * List the funded-primary sports signals with additive, shadow-only category
686
+ * evidence. `category_skill` never changes membership, ordering, or sizing.
687
+ */
688
+ listSportsEdgeSignals(params?: SportsEdgeSignalsParams): Promise<ApiListEnvelope<SportsEdgeSignal>>;
689
+ /**
690
+ * Read an explicitly observation-only sports cohort and its accountable
691
+ * per-sport funnel. This surface is isolated from the funded signals route.
692
+ * Healthy wider-holder and emerging-pile snapshots may be served for about
693
+ * 180 seconds; in-play cached snapshots are capped at about 30 seconds and
694
+ * stale provider live-board evidence fails closed. emerging-pile is an
695
+ * additive wider-holder projection, not an arrival-history or independent
696
+ * denominator view.
697
+ */
698
+ listSportsEdgeObservations(params: SportsEdgeObservationsParams, options?: Omit<ApiRequestOptions, "query">): Promise<SportsEdgeObservationsResponse>;
699
+ /**
700
+ * Typed conditional-read variant of {@link listSportsEdgeObservations}.
701
+ * Returns the full observation response on 200 or a typed `not_modified`
702
+ * envelope on 304 instead of routing the latter through generic `call()`.
703
+ * The endpoint emits a weak semantic ETag over the stable response payload;
704
+ * request-specific `meta` is excluded. For emerging-pile, the opaque
705
+ * projection cutoff inside `next_cursor` is excluded while its stable page
706
+ * position remains covered.
707
+ */
708
+ listSportsEdgeObservationsConditional(params: SportsEdgeObservationsParams, options?: Omit<ApiRequestOptions, "query">): Promise<SportsEdgeObservationsResponse | ApiNotModifiedResponse>;
709
+ searchMarkets<T = OperationData["searchMarkets"]>(q: string, options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
710
+ exploreMarkets<T = OperationData["getMarketIntel"]>(params?: ListParams): Promise<ApiListEnvelope<T>>;
711
+ getMarketIntel<T = OperationData["getMarketIntel"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
712
+ getMarketSnapshot<T = OperationData["getMarketSnapshot"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
713
+ /**
714
+ * Fetch bucketed OHLC candles for a market's outcome tokens.
715
+ * Resolution defaults to the server default; pass `query.resolution` as
716
+ * `"1d"` or `"1w"` to override.
717
+ */
718
+ getMarketCandles<T = OperationData["getMarketCandles"]>(conditionId: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
719
+ getInsiderRadarFlag<T = OperationData["getInsiderRadarFlag"]>(id: string, options?: Omit<ApiRequestOptions, "path">): Promise<ApiClientResponse<T>>;
720
+ listInsiderRadar<T = OperationData["listWebhooks"]>(params?: ListParams & {
721
+ min_grade?: Grade;
722
+ }): Promise<ApiListEnvelope<T>>;
723
+ listWebhooks<T = OperationData["listWebhooks"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
724
+ /**
725
+ * Fetch the self-describing webhook event catalog (each entry's `id`,
726
+ * description, payload shape, and active/dormant status).
727
+ */
728
+ listWebhookEvents<T = OperationData["listWebhookEvents"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
729
+ /** List delivery attempts for one webhook endpoint (Stripe-style list). */
730
+ listWebhookDeliveries<T = OperationData["redeliverWebhookDelivery"]>(webhookId: string | number, params?: ListParams): Promise<ApiListEnvelope<T>>;
731
+ /**
732
+ * Requeue one `dead_letter` delivery with a fresh attempt budget and return
733
+ * the delivery row. Re-enabling a disabled endpoint resends nothing, so this
734
+ * is how its dead-lettered deliveries are recovered. The API answers 409 when
735
+ * the delivery is already delivered or still queued, or when the endpoint is
736
+ * disabled, unverified, or no longer subscribed to the delivery's event type;
737
+ * the error message names the fix. Pass `idempotencyKey` to make a retry safe.
738
+ */
739
+ redeliverWebhookDelivery<T = OperationData["redeliverWebhookDelivery"]>(webhookId: string | number, deliveryId: string | number, options?: Omit<ApiRequestOptions, "path" | "body">): Promise<ApiClientResponse<T>>;
740
+ getHealth<T = OperationData["getHealth"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
741
+ getApiDiscovery<T = OperationData["getApiDiscovery"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
742
+ getAccountIdentity(options?: ApiRequestOptions): Promise<ApiClientResponse<{
743
+ user_id: number;
744
+ credential_id: number;
745
+ credential_kind: "api_key" | "oauth_grant";
746
+ scopes: string[] | null;
747
+ }>>;
748
+ getUsage<T = OperationData["getUsage"]>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
749
+ /** Fetch today's editorial Pick of the Day (single-object envelope). */
750
+ getPickOfTheDay<T = PickOfTheDay>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
751
+ /** Fetch the Pick of the Day archive with hit-rate (single-object envelope). */
752
+ getPickOfTheDayArchive<T = PickOfTheDayArchive>(options?: ApiRequestOptions): Promise<ApiClientResponse<T>>;
753
+ /** Resolve the base URL (used by the SSE stream consumer). */
754
+ getBaseUrl(): string;
755
+ /** The configured API key, if any (used by the SSE stream consumer). */
756
+ getApiKey(): string | undefined;
757
+ /** The resolved fetch implementation (used by the SSE stream consumer). */
758
+ getFetch(): typeof fetch;
759
+ buildUrl(operation: ApiClientOperation, options: ApiRequestOptions): string;
760
+ private buildHeaders;
761
+ }
762
+ export declare function isApiNotModifiedResponse(response: ApiClientResponse<unknown>): response is ApiNotModifiedResponse;
763
+ export declare function interpolatePath(path: string, params: Partial<Record<string, string | number>>): string;
764
+ export declare function isListEnvelope<T>(body: unknown): body is ApiListEnvelope<T>;
765
+ //# sourceMappingURL=client.d.ts.map