dino-markets 0.1.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.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/index.cjs +312 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.js +278 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the dino.markets /v2 REST API. Mirrors the server's serialization
|
|
3
|
+
* in v2shape.to_market: type-stable (kalshi/polymarket prices are always
|
|
4
|
+
* number|null, never a fabricated 0), with several fields present only on
|
|
5
|
+
* certain market shapes (documented per-field below).
|
|
6
|
+
*/
|
|
7
|
+
/** Kalshi book for one outcome. Present only with include=depth. */
|
|
8
|
+
interface KalshiBook {
|
|
9
|
+
ask: number | null;
|
|
10
|
+
bid: number | null;
|
|
11
|
+
depth: number | null;
|
|
12
|
+
ticker?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Polymarket book for one outcome. Present only with include=depth. */
|
|
15
|
+
interface PolymarketBook {
|
|
16
|
+
ask: number | null;
|
|
17
|
+
bid: number | null;
|
|
18
|
+
depth: number | null;
|
|
19
|
+
token_id?: string | null;
|
|
20
|
+
}
|
|
21
|
+
interface Outcome {
|
|
22
|
+
key: string;
|
|
23
|
+
name: string;
|
|
24
|
+
/** Kalshi best ask, 0-1 probability. Null when Kalshi has no price for this outcome. */
|
|
25
|
+
kalshi: number | null;
|
|
26
|
+
/** Polymarket best ask, 0-1 probability. Null when Polymarket has no price for this outcome. */
|
|
27
|
+
polymarket: number | null;
|
|
28
|
+
/** Which venue is cheaper right now, or null if either price is missing. */
|
|
29
|
+
cheaper: "kalshi" | "polymarket" | null;
|
|
30
|
+
/** Present only when the outcome has a captured team/option logo. */
|
|
31
|
+
logo?: string;
|
|
32
|
+
/** Sibling depth book, present only with include=depth. Never replaces `kalshi`/`polymarket`. */
|
|
33
|
+
kalshi_book?: KalshiBook | null;
|
|
34
|
+
polymarket_book?: PolymarketBook | null;
|
|
35
|
+
/** Ladder markets only (e.g. weather_high): whether this bucket is an exact Kalshi match or a span. */
|
|
36
|
+
relation?: "EXACT" | "OVERLAPS";
|
|
37
|
+
/** Ladder markets only, present when relation is "OVERLAPS". */
|
|
38
|
+
kalshi_span?: string[];
|
|
39
|
+
}
|
|
40
|
+
interface MarketResult {
|
|
41
|
+
venues_agree: boolean;
|
|
42
|
+
void: boolean;
|
|
43
|
+
settled_at: string | null;
|
|
44
|
+
}
|
|
45
|
+
interface MarketLinks {
|
|
46
|
+
kalshi: string | null;
|
|
47
|
+
polymarket: string | null;
|
|
48
|
+
}
|
|
49
|
+
/** One bucket of a ladder market's full Kalshi axis (e.g. weather_high). */
|
|
50
|
+
interface KalshiLadderBucket {
|
|
51
|
+
label: string;
|
|
52
|
+
kalshi: number | null;
|
|
53
|
+
}
|
|
54
|
+
/** Native venue identifiers. Present only with include=ids. */
|
|
55
|
+
interface VenueIds {
|
|
56
|
+
kalshi?: Record<string, unknown> | null;
|
|
57
|
+
polymarket?: Record<string, unknown> | null;
|
|
58
|
+
}
|
|
59
|
+
/** Match confidence scores. Present only with include=ids. */
|
|
60
|
+
interface Confidence {
|
|
61
|
+
entity?: number | null;
|
|
62
|
+
resolution?: number | null;
|
|
63
|
+
}
|
|
64
|
+
/** Settlement disclosure. Present only with include=settlement. */
|
|
65
|
+
interface Settlement {
|
|
66
|
+
parity?: boolean;
|
|
67
|
+
risks?: Record<string, unknown>[];
|
|
68
|
+
kalshi_text?: string | null;
|
|
69
|
+
poly_text?: string | null;
|
|
70
|
+
verdict?: string | null;
|
|
71
|
+
}
|
|
72
|
+
type MarketStatus = "open" | "resolving" | "closed" | "settled";
|
|
73
|
+
type MarketSignal = "arb" | "spread";
|
|
74
|
+
/**
|
|
75
|
+
* The canonical v2 market object, as returned by /v2/markets, /v2/pairs/{id},
|
|
76
|
+
* and streamed on the markets:* WebSocket channels ("market" frames).
|
|
77
|
+
*/
|
|
78
|
+
interface Market {
|
|
79
|
+
/** "dino_" + uuid. */
|
|
80
|
+
id: string;
|
|
81
|
+
slug: string | null;
|
|
82
|
+
sport: string | null;
|
|
83
|
+
league: string | null;
|
|
84
|
+
title: string | null;
|
|
85
|
+
/** Deferred server-side; always null today. */
|
|
86
|
+
home: string | null;
|
|
87
|
+
/** Deferred server-side; always null today. */
|
|
88
|
+
away: string | null;
|
|
89
|
+
start_time: string | null;
|
|
90
|
+
status: MarketStatus;
|
|
91
|
+
/** Match confidence tier. Currently always "high_confidence". */
|
|
92
|
+
match: string;
|
|
93
|
+
signal: MarketSignal;
|
|
94
|
+
/** Max cross-venue gap in percentage points, or null if any price is missing. */
|
|
95
|
+
spread_pts: number | null;
|
|
96
|
+
/** Gross ask-to-ask arbitrage percent, only set when signal is "arb". */
|
|
97
|
+
potential_arb_pct: number | null;
|
|
98
|
+
coverage: {
|
|
99
|
+
kalshi: boolean;
|
|
100
|
+
polymarket: boolean;
|
|
101
|
+
};
|
|
102
|
+
outcomes: Outcome[];
|
|
103
|
+
/** Verdict-only settlement result, present only once status is "settled". */
|
|
104
|
+
result: MarketResult | null;
|
|
105
|
+
expires_at: string | null;
|
|
106
|
+
updated_at: string | null;
|
|
107
|
+
priced_at: string | null;
|
|
108
|
+
links: MarketLinks;
|
|
109
|
+
/** Native venue identifiers, present only with include=ids. */
|
|
110
|
+
venues?: VenueIds;
|
|
111
|
+
/** Match confidence scores, present only with include=ids. */
|
|
112
|
+
confidence?: Confidence;
|
|
113
|
+
/** Settlement disclosure, present only with include=settlement. */
|
|
114
|
+
settlement?: Settlement;
|
|
115
|
+
/** Present only on total/spread/team_total/advance/weather_high rows (never on moneyline/outright). */
|
|
116
|
+
market_type?: string;
|
|
117
|
+
/** Present only on total/spread/team_total/advance rows. */
|
|
118
|
+
line?: number | null;
|
|
119
|
+
/** Present on total/spread/team_total/advance and weather_high (ladder) rows. */
|
|
120
|
+
basis?: string | null;
|
|
121
|
+
/** Present only on total/spread/team_total/advance rows: the anchor market's id for this game. */
|
|
122
|
+
game_id?: string | null;
|
|
123
|
+
/** Present only on ladder rows (e.g. weather_high): the full Kalshi bucket axis. */
|
|
124
|
+
kalshi_ladder?: KalshiLadderBucket[];
|
|
125
|
+
}
|
|
126
|
+
interface MarketsResponse {
|
|
127
|
+
count: number;
|
|
128
|
+
sport: string | null;
|
|
129
|
+
has_more: boolean;
|
|
130
|
+
markets: Market[];
|
|
131
|
+
}
|
|
132
|
+
interface HistoryPoint {
|
|
133
|
+
/** Epoch milliseconds. */
|
|
134
|
+
t: number;
|
|
135
|
+
k: number | null;
|
|
136
|
+
p: number | null;
|
|
137
|
+
}
|
|
138
|
+
interface HistorySeries {
|
|
139
|
+
outcome: string;
|
|
140
|
+
points: HistoryPoint[];
|
|
141
|
+
}
|
|
142
|
+
interface HistoryResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
series: HistorySeries[];
|
|
145
|
+
}
|
|
146
|
+
interface LeagueSummary {
|
|
147
|
+
sport: string;
|
|
148
|
+
leagues: string[];
|
|
149
|
+
count: number;
|
|
150
|
+
open: number;
|
|
151
|
+
live: number;
|
|
152
|
+
settled: number;
|
|
153
|
+
}
|
|
154
|
+
interface LeaguesResponse {
|
|
155
|
+
sports: LeagueSummary[];
|
|
156
|
+
}
|
|
157
|
+
interface StreamTokenResponse {
|
|
158
|
+
ticket: string;
|
|
159
|
+
ws_url: string;
|
|
160
|
+
expires_in: number;
|
|
161
|
+
allowed: {
|
|
162
|
+
channels: string[];
|
|
163
|
+
max_conns: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Body for reportBadArb. At least one field is required. */
|
|
167
|
+
interface ReportBadArbBody {
|
|
168
|
+
opp_id?: string;
|
|
169
|
+
reason?: string;
|
|
170
|
+
sport?: string;
|
|
171
|
+
market?: string;
|
|
172
|
+
detail?: string;
|
|
173
|
+
}
|
|
174
|
+
interface ReportBadArbResponse {
|
|
175
|
+
status: string;
|
|
176
|
+
}
|
|
177
|
+
/** Query options for Dino#markets(). */
|
|
178
|
+
interface MarketsOptions {
|
|
179
|
+
sport?: string;
|
|
180
|
+
league?: string;
|
|
181
|
+
/** Comma-separated: open,live,resolving,closed,settled. Server default: open,live. */
|
|
182
|
+
status?: string;
|
|
183
|
+
signal?: "spread" | "arb" | "candidates";
|
|
184
|
+
/** "start_time" (default) | "-spread_pts". */
|
|
185
|
+
sort?: string;
|
|
186
|
+
/** Comma-separated opt-in blocks: ids,depth,settlement. */
|
|
187
|
+
include?: string;
|
|
188
|
+
/** Comma-separated: moneyline,outright,total,spread,team_total,advance,weather_high,all. */
|
|
189
|
+
market_type?: string;
|
|
190
|
+
game_id?: string;
|
|
191
|
+
/** 1-1000, server default 500. */
|
|
192
|
+
limit?: number;
|
|
193
|
+
}
|
|
194
|
+
/** Query options for Dino#findArbitrage(). Same as MarketsOptions minus signal (fixed to "arb"). */
|
|
195
|
+
type FindArbitrageOptions = Omit<MarketsOptions, "signal">;
|
|
196
|
+
|
|
197
|
+
type FetchLike = typeof fetch;
|
|
198
|
+
interface DinoOptions {
|
|
199
|
+
/** API key. Falls back to process.env.DINO_API_KEY when process is available. */
|
|
200
|
+
apiKey?: string;
|
|
201
|
+
baseUrl?: string;
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
maxRetries?: number;
|
|
204
|
+
/** Injectable fetch implementation, mainly for tests. Defaults to the global fetch. */
|
|
205
|
+
fetchImpl?: FetchLike;
|
|
206
|
+
}
|
|
207
|
+
declare class Dino {
|
|
208
|
+
private readonly apiKey;
|
|
209
|
+
private readonly baseUrl;
|
|
210
|
+
private readonly timeoutMs;
|
|
211
|
+
private readonly maxRetries;
|
|
212
|
+
private readonly fetchImpl;
|
|
213
|
+
constructor(opts?: DinoOptions);
|
|
214
|
+
/** Matched cross-venue catalog. See MarketsOptions for filters. */
|
|
215
|
+
markets(opts?: MarketsOptions): Promise<MarketsResponse>;
|
|
216
|
+
/** One canonical market object. Accepts a "dino_<uuid>" id or a bare uuid. */
|
|
217
|
+
market(marketId: string): Promise<Market>;
|
|
218
|
+
/** Per-outcome Kalshi/Polymarket price history for one market. */
|
|
219
|
+
history(marketId: string): Promise<HistoryResponse>;
|
|
220
|
+
/** Sports and leagues currently in season, with lifecycle counts. */
|
|
221
|
+
leagues(): Promise<LeaguesResponse>;
|
|
222
|
+
/** Sugar for markets({ ...opts, signal: "arb" }). */
|
|
223
|
+
findArbitrage(opts?: FindArbitrageOptions): Promise<MarketsResponse>;
|
|
224
|
+
/** Flag a bad or incorrect arbitrage signal. At least one field of body is required. */
|
|
225
|
+
reportBadArb(body: ReportBadArbBody): Promise<ReportBadArbResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* Mint a short-lived WebSocket connect ticket (Basic/Pro only; 402 on Free).
|
|
228
|
+
* See stream.ts's `watch()` helper to consume it directly.
|
|
229
|
+
*/
|
|
230
|
+
streamToken(): Promise<StreamTokenResponse>;
|
|
231
|
+
private request;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* A market/price frame published on the markets:* channels. Frames are flat
|
|
236
|
+
* and self-describing (type discriminator, no wrapper) - see the WebSocket
|
|
237
|
+
* docs at https://dino.markets/docs/websocket. This SDK does not parse the
|
|
238
|
+
* frame further; it is passed through as-is.
|
|
239
|
+
*/
|
|
240
|
+
type StreamFrame = Record<string, unknown>;
|
|
241
|
+
interface WatchOptions {
|
|
242
|
+
/** Called for every publication received on the subscribed channels. */
|
|
243
|
+
onFrame: (frame: StreamFrame, channel: string) => void;
|
|
244
|
+
/** Called on a connection error. Optional. */
|
|
245
|
+
onError?: (error: unknown) => void;
|
|
246
|
+
}
|
|
247
|
+
interface WatchHandle {
|
|
248
|
+
/** Disconnect the stream. */
|
|
249
|
+
close: () => void;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Connect to the dino.markets real-time stream and forward publications to
|
|
253
|
+
* onFrame. Requires a Basic or Pro plan; a Free key's streamToken() call
|
|
254
|
+
* throws a PlanError (402).
|
|
255
|
+
*
|
|
256
|
+
* Requires the optional "centrifuge" peer dependency: `npm install centrifuge`.
|
|
257
|
+
*/
|
|
258
|
+
declare function watch(client: Dino, opts: WatchOptions): Promise<WatchHandle>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Error types raised by the dino-markets client.
|
|
262
|
+
*
|
|
263
|
+
* Every non-2xx HTTP response from the API is mapped to one of these via
|
|
264
|
+
* `mapError`. `body` is the parsed JSON response body when available (the
|
|
265
|
+
* API returns `{ error: string, ... }` on failures), or `null` if the body
|
|
266
|
+
* could not be parsed as JSON.
|
|
267
|
+
*/
|
|
268
|
+
declare class DinoError extends Error {
|
|
269
|
+
/** HTTP status code of the failed response. */
|
|
270
|
+
status: number;
|
|
271
|
+
/** Parsed JSON response body, or null if unavailable/unparseable. */
|
|
272
|
+
body: unknown;
|
|
273
|
+
constructor(message: string, status: number, body?: unknown);
|
|
274
|
+
}
|
|
275
|
+
/** 401 - missing, malformed, or revoked API key. */
|
|
276
|
+
declare class AuthenticationError extends DinoError {
|
|
277
|
+
constructor(message: string, status: number, body?: unknown);
|
|
278
|
+
}
|
|
279
|
+
/** 402 - subscription inactive, or the endpoint needs a paid plan (e.g. streaming on Free). */
|
|
280
|
+
declare class PlanError extends DinoError {
|
|
281
|
+
constructor(message: string, status: number, body?: unknown);
|
|
282
|
+
}
|
|
283
|
+
/** 429 - rate limit exceeded. `retryAfter` is in seconds when the server reports one. */
|
|
284
|
+
declare class RateLimitError extends DinoError {
|
|
285
|
+
retryAfter?: number;
|
|
286
|
+
constructor(message: string, status: number, body?: unknown, retryAfter?: number);
|
|
287
|
+
}
|
|
288
|
+
/** 5xx - server-side failure. */
|
|
289
|
+
declare class ServerError extends DinoError {
|
|
290
|
+
constructor(message: string, status: number, body?: unknown);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Map an HTTP response's status/body to a DinoError subclass. status must be
|
|
294
|
+
* a non-2xx code; headers is optional and only used to read Retry-After.
|
|
295
|
+
*/
|
|
296
|
+
declare function mapError(status: number, body: unknown, headers?: Headers): DinoError;
|
|
297
|
+
|
|
298
|
+
export { AuthenticationError, type Confidence, Dino, DinoError, type DinoOptions, type FetchLike, type FindArbitrageOptions, type HistoryPoint, type HistoryResponse, type HistorySeries, type KalshiBook, type KalshiLadderBucket, type LeagueSummary, type LeaguesResponse, type Market, type MarketLinks, type MarketResult, type MarketSignal, type MarketStatus, type MarketsOptions, type MarketsResponse, type Outcome, PlanError, type PolymarketBook, RateLimitError, type ReportBadArbBody, type ReportBadArbResponse, ServerError, type Settlement, type StreamFrame, type StreamTokenResponse, type VenueIds, type WatchHandle, type WatchOptions, mapError, watch };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the dino.markets /v2 REST API. Mirrors the server's serialization
|
|
3
|
+
* in v2shape.to_market: type-stable (kalshi/polymarket prices are always
|
|
4
|
+
* number|null, never a fabricated 0), with several fields present only on
|
|
5
|
+
* certain market shapes (documented per-field below).
|
|
6
|
+
*/
|
|
7
|
+
/** Kalshi book for one outcome. Present only with include=depth. */
|
|
8
|
+
interface KalshiBook {
|
|
9
|
+
ask: number | null;
|
|
10
|
+
bid: number | null;
|
|
11
|
+
depth: number | null;
|
|
12
|
+
ticker?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Polymarket book for one outcome. Present only with include=depth. */
|
|
15
|
+
interface PolymarketBook {
|
|
16
|
+
ask: number | null;
|
|
17
|
+
bid: number | null;
|
|
18
|
+
depth: number | null;
|
|
19
|
+
token_id?: string | null;
|
|
20
|
+
}
|
|
21
|
+
interface Outcome {
|
|
22
|
+
key: string;
|
|
23
|
+
name: string;
|
|
24
|
+
/** Kalshi best ask, 0-1 probability. Null when Kalshi has no price for this outcome. */
|
|
25
|
+
kalshi: number | null;
|
|
26
|
+
/** Polymarket best ask, 0-1 probability. Null when Polymarket has no price for this outcome. */
|
|
27
|
+
polymarket: number | null;
|
|
28
|
+
/** Which venue is cheaper right now, or null if either price is missing. */
|
|
29
|
+
cheaper: "kalshi" | "polymarket" | null;
|
|
30
|
+
/** Present only when the outcome has a captured team/option logo. */
|
|
31
|
+
logo?: string;
|
|
32
|
+
/** Sibling depth book, present only with include=depth. Never replaces `kalshi`/`polymarket`. */
|
|
33
|
+
kalshi_book?: KalshiBook | null;
|
|
34
|
+
polymarket_book?: PolymarketBook | null;
|
|
35
|
+
/** Ladder markets only (e.g. weather_high): whether this bucket is an exact Kalshi match or a span. */
|
|
36
|
+
relation?: "EXACT" | "OVERLAPS";
|
|
37
|
+
/** Ladder markets only, present when relation is "OVERLAPS". */
|
|
38
|
+
kalshi_span?: string[];
|
|
39
|
+
}
|
|
40
|
+
interface MarketResult {
|
|
41
|
+
venues_agree: boolean;
|
|
42
|
+
void: boolean;
|
|
43
|
+
settled_at: string | null;
|
|
44
|
+
}
|
|
45
|
+
interface MarketLinks {
|
|
46
|
+
kalshi: string | null;
|
|
47
|
+
polymarket: string | null;
|
|
48
|
+
}
|
|
49
|
+
/** One bucket of a ladder market's full Kalshi axis (e.g. weather_high). */
|
|
50
|
+
interface KalshiLadderBucket {
|
|
51
|
+
label: string;
|
|
52
|
+
kalshi: number | null;
|
|
53
|
+
}
|
|
54
|
+
/** Native venue identifiers. Present only with include=ids. */
|
|
55
|
+
interface VenueIds {
|
|
56
|
+
kalshi?: Record<string, unknown> | null;
|
|
57
|
+
polymarket?: Record<string, unknown> | null;
|
|
58
|
+
}
|
|
59
|
+
/** Match confidence scores. Present only with include=ids. */
|
|
60
|
+
interface Confidence {
|
|
61
|
+
entity?: number | null;
|
|
62
|
+
resolution?: number | null;
|
|
63
|
+
}
|
|
64
|
+
/** Settlement disclosure. Present only with include=settlement. */
|
|
65
|
+
interface Settlement {
|
|
66
|
+
parity?: boolean;
|
|
67
|
+
risks?: Record<string, unknown>[];
|
|
68
|
+
kalshi_text?: string | null;
|
|
69
|
+
poly_text?: string | null;
|
|
70
|
+
verdict?: string | null;
|
|
71
|
+
}
|
|
72
|
+
type MarketStatus = "open" | "resolving" | "closed" | "settled";
|
|
73
|
+
type MarketSignal = "arb" | "spread";
|
|
74
|
+
/**
|
|
75
|
+
* The canonical v2 market object, as returned by /v2/markets, /v2/pairs/{id},
|
|
76
|
+
* and streamed on the markets:* WebSocket channels ("market" frames).
|
|
77
|
+
*/
|
|
78
|
+
interface Market {
|
|
79
|
+
/** "dino_" + uuid. */
|
|
80
|
+
id: string;
|
|
81
|
+
slug: string | null;
|
|
82
|
+
sport: string | null;
|
|
83
|
+
league: string | null;
|
|
84
|
+
title: string | null;
|
|
85
|
+
/** Deferred server-side; always null today. */
|
|
86
|
+
home: string | null;
|
|
87
|
+
/** Deferred server-side; always null today. */
|
|
88
|
+
away: string | null;
|
|
89
|
+
start_time: string | null;
|
|
90
|
+
status: MarketStatus;
|
|
91
|
+
/** Match confidence tier. Currently always "high_confidence". */
|
|
92
|
+
match: string;
|
|
93
|
+
signal: MarketSignal;
|
|
94
|
+
/** Max cross-venue gap in percentage points, or null if any price is missing. */
|
|
95
|
+
spread_pts: number | null;
|
|
96
|
+
/** Gross ask-to-ask arbitrage percent, only set when signal is "arb". */
|
|
97
|
+
potential_arb_pct: number | null;
|
|
98
|
+
coverage: {
|
|
99
|
+
kalshi: boolean;
|
|
100
|
+
polymarket: boolean;
|
|
101
|
+
};
|
|
102
|
+
outcomes: Outcome[];
|
|
103
|
+
/** Verdict-only settlement result, present only once status is "settled". */
|
|
104
|
+
result: MarketResult | null;
|
|
105
|
+
expires_at: string | null;
|
|
106
|
+
updated_at: string | null;
|
|
107
|
+
priced_at: string | null;
|
|
108
|
+
links: MarketLinks;
|
|
109
|
+
/** Native venue identifiers, present only with include=ids. */
|
|
110
|
+
venues?: VenueIds;
|
|
111
|
+
/** Match confidence scores, present only with include=ids. */
|
|
112
|
+
confidence?: Confidence;
|
|
113
|
+
/** Settlement disclosure, present only with include=settlement. */
|
|
114
|
+
settlement?: Settlement;
|
|
115
|
+
/** Present only on total/spread/team_total/advance/weather_high rows (never on moneyline/outright). */
|
|
116
|
+
market_type?: string;
|
|
117
|
+
/** Present only on total/spread/team_total/advance rows. */
|
|
118
|
+
line?: number | null;
|
|
119
|
+
/** Present on total/spread/team_total/advance and weather_high (ladder) rows. */
|
|
120
|
+
basis?: string | null;
|
|
121
|
+
/** Present only on total/spread/team_total/advance rows: the anchor market's id for this game. */
|
|
122
|
+
game_id?: string | null;
|
|
123
|
+
/** Present only on ladder rows (e.g. weather_high): the full Kalshi bucket axis. */
|
|
124
|
+
kalshi_ladder?: KalshiLadderBucket[];
|
|
125
|
+
}
|
|
126
|
+
interface MarketsResponse {
|
|
127
|
+
count: number;
|
|
128
|
+
sport: string | null;
|
|
129
|
+
has_more: boolean;
|
|
130
|
+
markets: Market[];
|
|
131
|
+
}
|
|
132
|
+
interface HistoryPoint {
|
|
133
|
+
/** Epoch milliseconds. */
|
|
134
|
+
t: number;
|
|
135
|
+
k: number | null;
|
|
136
|
+
p: number | null;
|
|
137
|
+
}
|
|
138
|
+
interface HistorySeries {
|
|
139
|
+
outcome: string;
|
|
140
|
+
points: HistoryPoint[];
|
|
141
|
+
}
|
|
142
|
+
interface HistoryResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
series: HistorySeries[];
|
|
145
|
+
}
|
|
146
|
+
interface LeagueSummary {
|
|
147
|
+
sport: string;
|
|
148
|
+
leagues: string[];
|
|
149
|
+
count: number;
|
|
150
|
+
open: number;
|
|
151
|
+
live: number;
|
|
152
|
+
settled: number;
|
|
153
|
+
}
|
|
154
|
+
interface LeaguesResponse {
|
|
155
|
+
sports: LeagueSummary[];
|
|
156
|
+
}
|
|
157
|
+
interface StreamTokenResponse {
|
|
158
|
+
ticket: string;
|
|
159
|
+
ws_url: string;
|
|
160
|
+
expires_in: number;
|
|
161
|
+
allowed: {
|
|
162
|
+
channels: string[];
|
|
163
|
+
max_conns: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Body for reportBadArb. At least one field is required. */
|
|
167
|
+
interface ReportBadArbBody {
|
|
168
|
+
opp_id?: string;
|
|
169
|
+
reason?: string;
|
|
170
|
+
sport?: string;
|
|
171
|
+
market?: string;
|
|
172
|
+
detail?: string;
|
|
173
|
+
}
|
|
174
|
+
interface ReportBadArbResponse {
|
|
175
|
+
status: string;
|
|
176
|
+
}
|
|
177
|
+
/** Query options for Dino#markets(). */
|
|
178
|
+
interface MarketsOptions {
|
|
179
|
+
sport?: string;
|
|
180
|
+
league?: string;
|
|
181
|
+
/** Comma-separated: open,live,resolving,closed,settled. Server default: open,live. */
|
|
182
|
+
status?: string;
|
|
183
|
+
signal?: "spread" | "arb" | "candidates";
|
|
184
|
+
/** "start_time" (default) | "-spread_pts". */
|
|
185
|
+
sort?: string;
|
|
186
|
+
/** Comma-separated opt-in blocks: ids,depth,settlement. */
|
|
187
|
+
include?: string;
|
|
188
|
+
/** Comma-separated: moneyline,outright,total,spread,team_total,advance,weather_high,all. */
|
|
189
|
+
market_type?: string;
|
|
190
|
+
game_id?: string;
|
|
191
|
+
/** 1-1000, server default 500. */
|
|
192
|
+
limit?: number;
|
|
193
|
+
}
|
|
194
|
+
/** Query options for Dino#findArbitrage(). Same as MarketsOptions minus signal (fixed to "arb"). */
|
|
195
|
+
type FindArbitrageOptions = Omit<MarketsOptions, "signal">;
|
|
196
|
+
|
|
197
|
+
type FetchLike = typeof fetch;
|
|
198
|
+
interface DinoOptions {
|
|
199
|
+
/** API key. Falls back to process.env.DINO_API_KEY when process is available. */
|
|
200
|
+
apiKey?: string;
|
|
201
|
+
baseUrl?: string;
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
maxRetries?: number;
|
|
204
|
+
/** Injectable fetch implementation, mainly for tests. Defaults to the global fetch. */
|
|
205
|
+
fetchImpl?: FetchLike;
|
|
206
|
+
}
|
|
207
|
+
declare class Dino {
|
|
208
|
+
private readonly apiKey;
|
|
209
|
+
private readonly baseUrl;
|
|
210
|
+
private readonly timeoutMs;
|
|
211
|
+
private readonly maxRetries;
|
|
212
|
+
private readonly fetchImpl;
|
|
213
|
+
constructor(opts?: DinoOptions);
|
|
214
|
+
/** Matched cross-venue catalog. See MarketsOptions for filters. */
|
|
215
|
+
markets(opts?: MarketsOptions): Promise<MarketsResponse>;
|
|
216
|
+
/** One canonical market object. Accepts a "dino_<uuid>" id or a bare uuid. */
|
|
217
|
+
market(marketId: string): Promise<Market>;
|
|
218
|
+
/** Per-outcome Kalshi/Polymarket price history for one market. */
|
|
219
|
+
history(marketId: string): Promise<HistoryResponse>;
|
|
220
|
+
/** Sports and leagues currently in season, with lifecycle counts. */
|
|
221
|
+
leagues(): Promise<LeaguesResponse>;
|
|
222
|
+
/** Sugar for markets({ ...opts, signal: "arb" }). */
|
|
223
|
+
findArbitrage(opts?: FindArbitrageOptions): Promise<MarketsResponse>;
|
|
224
|
+
/** Flag a bad or incorrect arbitrage signal. At least one field of body is required. */
|
|
225
|
+
reportBadArb(body: ReportBadArbBody): Promise<ReportBadArbResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* Mint a short-lived WebSocket connect ticket (Basic/Pro only; 402 on Free).
|
|
228
|
+
* See stream.ts's `watch()` helper to consume it directly.
|
|
229
|
+
*/
|
|
230
|
+
streamToken(): Promise<StreamTokenResponse>;
|
|
231
|
+
private request;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* A market/price frame published on the markets:* channels. Frames are flat
|
|
236
|
+
* and self-describing (type discriminator, no wrapper) - see the WebSocket
|
|
237
|
+
* docs at https://dino.markets/docs/websocket. This SDK does not parse the
|
|
238
|
+
* frame further; it is passed through as-is.
|
|
239
|
+
*/
|
|
240
|
+
type StreamFrame = Record<string, unknown>;
|
|
241
|
+
interface WatchOptions {
|
|
242
|
+
/** Called for every publication received on the subscribed channels. */
|
|
243
|
+
onFrame: (frame: StreamFrame, channel: string) => void;
|
|
244
|
+
/** Called on a connection error. Optional. */
|
|
245
|
+
onError?: (error: unknown) => void;
|
|
246
|
+
}
|
|
247
|
+
interface WatchHandle {
|
|
248
|
+
/** Disconnect the stream. */
|
|
249
|
+
close: () => void;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Connect to the dino.markets real-time stream and forward publications to
|
|
253
|
+
* onFrame. Requires a Basic or Pro plan; a Free key's streamToken() call
|
|
254
|
+
* throws a PlanError (402).
|
|
255
|
+
*
|
|
256
|
+
* Requires the optional "centrifuge" peer dependency: `npm install centrifuge`.
|
|
257
|
+
*/
|
|
258
|
+
declare function watch(client: Dino, opts: WatchOptions): Promise<WatchHandle>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Error types raised by the dino-markets client.
|
|
262
|
+
*
|
|
263
|
+
* Every non-2xx HTTP response from the API is mapped to one of these via
|
|
264
|
+
* `mapError`. `body` is the parsed JSON response body when available (the
|
|
265
|
+
* API returns `{ error: string, ... }` on failures), or `null` if the body
|
|
266
|
+
* could not be parsed as JSON.
|
|
267
|
+
*/
|
|
268
|
+
declare class DinoError extends Error {
|
|
269
|
+
/** HTTP status code of the failed response. */
|
|
270
|
+
status: number;
|
|
271
|
+
/** Parsed JSON response body, or null if unavailable/unparseable. */
|
|
272
|
+
body: unknown;
|
|
273
|
+
constructor(message: string, status: number, body?: unknown);
|
|
274
|
+
}
|
|
275
|
+
/** 401 - missing, malformed, or revoked API key. */
|
|
276
|
+
declare class AuthenticationError extends DinoError {
|
|
277
|
+
constructor(message: string, status: number, body?: unknown);
|
|
278
|
+
}
|
|
279
|
+
/** 402 - subscription inactive, or the endpoint needs a paid plan (e.g. streaming on Free). */
|
|
280
|
+
declare class PlanError extends DinoError {
|
|
281
|
+
constructor(message: string, status: number, body?: unknown);
|
|
282
|
+
}
|
|
283
|
+
/** 429 - rate limit exceeded. `retryAfter` is in seconds when the server reports one. */
|
|
284
|
+
declare class RateLimitError extends DinoError {
|
|
285
|
+
retryAfter?: number;
|
|
286
|
+
constructor(message: string, status: number, body?: unknown, retryAfter?: number);
|
|
287
|
+
}
|
|
288
|
+
/** 5xx - server-side failure. */
|
|
289
|
+
declare class ServerError extends DinoError {
|
|
290
|
+
constructor(message: string, status: number, body?: unknown);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Map an HTTP response's status/body to a DinoError subclass. status must be
|
|
294
|
+
* a non-2xx code; headers is optional and only used to read Retry-After.
|
|
295
|
+
*/
|
|
296
|
+
declare function mapError(status: number, body: unknown, headers?: Headers): DinoError;
|
|
297
|
+
|
|
298
|
+
export { AuthenticationError, type Confidence, Dino, DinoError, type DinoOptions, type FetchLike, type FindArbitrageOptions, type HistoryPoint, type HistoryResponse, type HistorySeries, type KalshiBook, type KalshiLadderBucket, type LeagueSummary, type LeaguesResponse, type Market, type MarketLinks, type MarketResult, type MarketSignal, type MarketStatus, type MarketsOptions, type MarketsResponse, type Outcome, PlanError, type PolymarketBook, RateLimitError, type ReportBadArbBody, type ReportBadArbResponse, ServerError, type Settlement, type StreamFrame, type StreamTokenResponse, type VenueIds, type WatchHandle, type WatchOptions, mapError, watch };
|