@keystrokehq/polymarket 0.0.15 → 0.0.16-integration-id-canonicalization.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/README.md +5 -0
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +3 -0
- package/dist/{schemas-C_SM7qmm.mjs → data-g8Gt5cqR.mjs} +74 -165
- package/dist/index.d.mts +4 -372
- package/dist/index.mjs +4 -9
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/polymarket.credential-set-jU6p-ps3.d.mts +14 -0
- package/dist/polymarket.credential-set-wbGYLp9q.mjs +19 -0
- package/dist/pricing-x-VWqR0L.d.mts +309 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +3 -0
- package/dist/search-polymarket.operation-BW-S0mae.d.mts +700 -0
- package/dist/search-polymarket.operation-DPkjnHty.mjs +624 -0
- package/package.json +14 -30
- package/dist/_official/index.d.mts +0 -2
- package/dist/_official/index.mjs +0 -3
- package/dist/data.d.mts +0 -95
- package/dist/data.mjs +0 -114
- package/dist/discovery.d.mts +0 -64
- package/dist/discovery.mjs +0 -126
- package/dist/events.d.mts +0 -202
- package/dist/events.mjs +0 -69
- package/dist/integration-BwWHe7Rh.d.mts +0 -19
- package/dist/integration-DX7CGwFx.mjs +0 -28
- package/dist/markets.d.mts +0 -143
- package/dist/markets.mjs +0 -69
- package/dist/orderbook.d.mts +0 -58
- package/dist/orderbook.mjs +0 -58
- package/dist/pricing.d.mts +0 -52
- package/dist/pricing.mjs +0 -105
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @keystrokehq/polymarket
|
|
2
|
+
|
|
3
|
+
Keystroke official integration for [Polymarket](https://polymarket.com) — decentralized prediction market data across the Gamma, CLOB, and Data APIs.
|
|
4
|
+
|
|
5
|
+
Credential sets live under [`./credential-sets`](./src/credential-sets/index.ts). Operations live under [`./operations`](./src/operations/index.ts).
|
|
@@ -1,82 +1,81 @@
|
|
|
1
|
-
import { t as polymarket } from "./integration-DX7CGwFx.mjs";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import { createOfficialOperationFactory } from "@keystrokehq/integration-authoring/official";
|
|
4
2
|
|
|
5
|
-
//#region src/
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const headers = { Accept: "application/json" };
|
|
28
|
-
if (credentials.POLYMARKET_API_KEY) headers.Authorization = `Bearer ${credentials.POLYMARKET_API_KEY}`;
|
|
29
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
30
|
-
const response = await fetch(url, {
|
|
31
|
-
method,
|
|
32
|
-
headers,
|
|
33
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
34
|
-
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
const errorBody = await response.text().catch(() => "");
|
|
37
|
-
throw new Error(`Polymarket API error (${host}): ${response.status} ${response.statusText}${errorBody ? ` — ${errorBody}` : ""}`);
|
|
38
|
-
}
|
|
39
|
-
const data = await response.json();
|
|
40
|
-
if (data === null || data === void 0) throw new Error(`Polymarket API returned empty response for ${method} ${url} (status ${response.status})`);
|
|
41
|
-
return data;
|
|
42
|
-
};
|
|
43
|
-
return { request };
|
|
44
|
-
}
|
|
3
|
+
//#region src/schemas/orderbook.ts
|
|
4
|
+
const orderBookEntrySchema = z.object({
|
|
5
|
+
price: z.string(),
|
|
6
|
+
size: z.string()
|
|
7
|
+
});
|
|
8
|
+
const orderBookSummarySchema = z.object({
|
|
9
|
+
market: z.string().optional(),
|
|
10
|
+
asset_id: z.string(),
|
|
11
|
+
timestamp: z.string().optional(),
|
|
12
|
+
hash: z.string().optional(),
|
|
13
|
+
bids: z.array(orderBookEntrySchema),
|
|
14
|
+
asks: z.array(orderBookEntrySchema),
|
|
15
|
+
min_order_size: z.string().optional(),
|
|
16
|
+
tick_size: z.string().optional(),
|
|
17
|
+
neg_risk: z.boolean().optional()
|
|
18
|
+
}).passthrough();
|
|
19
|
+
const spreadSchema = z.object({
|
|
20
|
+
asset_id: z.string(),
|
|
21
|
+
spread: z.string(),
|
|
22
|
+
bid: z.string().optional(),
|
|
23
|
+
ask: z.string().optional()
|
|
24
|
+
}).passthrough();
|
|
45
25
|
|
|
46
26
|
//#endregion
|
|
47
|
-
//#region src/
|
|
48
|
-
const
|
|
27
|
+
//#region src/schemas/pricing.ts
|
|
28
|
+
const clobPriceSchema = z.object({ price: z.string() });
|
|
29
|
+
const clobMidpointSchema = z.object({ mid: z.string() });
|
|
30
|
+
const clobPricesMapSchema = z.record(z.string(), z.object({
|
|
31
|
+
BUY: z.string(),
|
|
32
|
+
SELL: z.string()
|
|
33
|
+
}));
|
|
34
|
+
const priceHistoryPointSchema = z.object({
|
|
35
|
+
t: z.number(),
|
|
36
|
+
p: z.number()
|
|
37
|
+
});
|
|
38
|
+
const priceHistoryResponseSchema = z.object({ history: z.array(priceHistoryPointSchema) });
|
|
49
39
|
|
|
50
40
|
//#endregion
|
|
51
|
-
//#region src/schemas.ts
|
|
52
|
-
/**
|
|
53
|
-
* polymarket/schemas.ts
|
|
54
|
-
*
|
|
55
|
-
* All Zod schemas for Polymarket API objects.
|
|
56
|
-
*
|
|
57
|
-
* Three APIs with different conventions:
|
|
58
|
-
* - Gamma API: Standard JSON types, camelCase fields
|
|
59
|
-
* - CLOB API: String-typed numbers (e.g., { price: "0.54" })
|
|
60
|
-
* - Data API: Polymarket-specific field names (proxyWallet, conditionId, etc.)
|
|
61
|
-
*
|
|
62
|
-
* Types are inferred from schemas — never defined separately.
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* Pagination params used by all list endpoints (offset-based).
|
|
66
|
-
*/
|
|
67
|
-
const paginationParamsSchema = z.object({
|
|
68
|
-
limit: z.number().optional(),
|
|
69
|
-
offset: z.number().optional()
|
|
70
|
-
});
|
|
41
|
+
//#region src/schemas/discovery.ts
|
|
71
42
|
const tagSchema = z.object({
|
|
72
43
|
id: z.string(),
|
|
73
44
|
label: z.string(),
|
|
74
45
|
slug: z.string().optional()
|
|
75
46
|
}).passthrough();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
const seriesSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
title: z.string(),
|
|
50
|
+
slug: z.string().optional(),
|
|
51
|
+
description: z.string().optional()
|
|
52
|
+
}).passthrough();
|
|
53
|
+
const searchResultSchema = z.object({
|
|
54
|
+
events: z.array(z.unknown()).optional(),
|
|
55
|
+
tags: z.array(z.unknown()).optional(),
|
|
56
|
+
profiles: z.array(z.unknown()).optional(),
|
|
57
|
+
pagination: z.object({
|
|
58
|
+
hasMore: z.boolean().optional(),
|
|
59
|
+
totalResults: z.number().optional()
|
|
60
|
+
}).optional()
|
|
61
|
+
});
|
|
62
|
+
const profileSchema = z.object({
|
|
63
|
+
address: z.string(),
|
|
64
|
+
pseudonym: z.string().optional(),
|
|
65
|
+
bio: z.string().optional(),
|
|
66
|
+
profileImage: z.string().optional(),
|
|
67
|
+
displayUsernamePublic: z.boolean().optional()
|
|
68
|
+
}).passthrough();
|
|
69
|
+
const sportsMetadataSchema = z.unknown();
|
|
70
|
+
const sportsMarketTypeSchema = z.unknown();
|
|
71
|
+
const sportsTeamSchema = z.unknown();
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/schemas/markets.ts
|
|
75
|
+
const paginationParamsSchema = z.object({
|
|
76
|
+
limit: z.number().optional(),
|
|
77
|
+
offset: z.number().optional()
|
|
78
|
+
});
|
|
80
79
|
const marketSchema = z.object({
|
|
81
80
|
id: z.string(),
|
|
82
81
|
question: z.string(),
|
|
@@ -107,11 +106,6 @@ const marketSchema = z.object({
|
|
|
107
106
|
createdAt: z.string().optional(),
|
|
108
107
|
updatedAt: z.string().optional()
|
|
109
108
|
}).passthrough();
|
|
110
|
-
/**
|
|
111
|
-
* Valid order fields for Gamma API /markets endpoint.
|
|
112
|
-
* Must match Market object property names (camelCase).
|
|
113
|
-
* See: https://docs.polymarket.com/api-reference/markets/list-markets
|
|
114
|
-
*/
|
|
115
109
|
const listMarketsOrderSchema = z.enum([
|
|
116
110
|
"volume24hr",
|
|
117
111
|
"volumeNum",
|
|
@@ -121,9 +115,6 @@ const listMarketsOrderSchema = z.enum([
|
|
|
121
115
|
"competitive",
|
|
122
116
|
"closedTime"
|
|
123
117
|
]).optional();
|
|
124
|
-
/**
|
|
125
|
-
* List markets query params.
|
|
126
|
-
*/
|
|
127
118
|
const listMarketsParamsSchema = z.object({
|
|
128
119
|
limit: z.number().optional(),
|
|
129
120
|
offset: z.number().optional(),
|
|
@@ -145,10 +136,9 @@ const listMarketsParamsSchema = z.object({
|
|
|
145
136
|
closed: z.boolean().optional(),
|
|
146
137
|
active: z.boolean().optional()
|
|
147
138
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
*/
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/schemas/events.ts
|
|
152
142
|
const eventSchema = z.object({
|
|
153
143
|
id: z.string(),
|
|
154
144
|
title: z.string(),
|
|
@@ -168,9 +158,6 @@ const eventSchema = z.object({
|
|
|
168
158
|
tags: z.array(tagSchema).optional(),
|
|
169
159
|
categories: z.array(z.unknown()).optional()
|
|
170
160
|
}).passthrough();
|
|
171
|
-
/**
|
|
172
|
-
* List events query params.
|
|
173
|
-
*/
|
|
174
161
|
const listEventsParamsSchema = z.object({
|
|
175
162
|
limit: z.number().optional(),
|
|
176
163
|
offset: z.number().optional(),
|
|
@@ -193,87 +180,9 @@ const listEventsParamsSchema = z.object({
|
|
|
193
180
|
end_date_min: z.string().optional(),
|
|
194
181
|
end_date_max: z.string().optional()
|
|
195
182
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
slug: z.string().optional(),
|
|
200
|
-
description: z.string().optional()
|
|
201
|
-
}).passthrough();
|
|
202
|
-
const searchResultSchema = z.object({
|
|
203
|
-
events: z.array(z.unknown()).optional(),
|
|
204
|
-
tags: z.array(z.unknown()).optional(),
|
|
205
|
-
profiles: z.array(z.unknown()).optional(),
|
|
206
|
-
pagination: z.object({
|
|
207
|
-
hasMore: z.boolean().optional(),
|
|
208
|
-
totalResults: z.number().optional()
|
|
209
|
-
}).optional()
|
|
210
|
-
});
|
|
211
|
-
const profileSchema = z.object({
|
|
212
|
-
address: z.string(),
|
|
213
|
-
pseudonym: z.string().optional(),
|
|
214
|
-
bio: z.string().optional(),
|
|
215
|
-
profileImage: z.string().optional(),
|
|
216
|
-
displayUsernamePublic: z.boolean().optional()
|
|
217
|
-
}).passthrough();
|
|
218
|
-
const sportsMetadataSchema = z.unknown();
|
|
219
|
-
const sportsMarketTypeSchema = z.unknown();
|
|
220
|
-
const sportsTeamSchema = z.unknown();
|
|
221
|
-
/**
|
|
222
|
-
* CLOB price response — prices are strings, not numbers.
|
|
223
|
-
*/
|
|
224
|
-
const clobPriceSchema = z.object({ price: z.string() });
|
|
225
|
-
/**
|
|
226
|
-
* CLOB midpoint response.
|
|
227
|
-
*/
|
|
228
|
-
const clobMidpointSchema = z.object({ mid: z.string() });
|
|
229
|
-
/**
|
|
230
|
-
* CLOB /prices response — Record<token_id, { BUY: string, SELL: string }>
|
|
231
|
-
*/
|
|
232
|
-
const clobPricesMapSchema = z.record(z.string(), z.object({
|
|
233
|
-
BUY: z.string(),
|
|
234
|
-
SELL: z.string()
|
|
235
|
-
}));
|
|
236
|
-
/**
|
|
237
|
-
* CLOB price history point.
|
|
238
|
-
*/
|
|
239
|
-
const priceHistoryPointSchema = z.object({
|
|
240
|
-
t: z.number(),
|
|
241
|
-
p: z.number()
|
|
242
|
-
});
|
|
243
|
-
/**
|
|
244
|
-
* CLOB /prices-history response.
|
|
245
|
-
*/
|
|
246
|
-
const priceHistoryResponseSchema = z.object({ history: z.array(priceHistoryPointSchema) });
|
|
247
|
-
/**
|
|
248
|
-
* Order book entry (bid or ask) — prices and sizes are strings.
|
|
249
|
-
*/
|
|
250
|
-
const orderBookEntrySchema = z.object({
|
|
251
|
-
price: z.string(),
|
|
252
|
-
size: z.string()
|
|
253
|
-
});
|
|
254
|
-
/**
|
|
255
|
-
* Order book summary for a token.
|
|
256
|
-
*/
|
|
257
|
-
const orderBookSummarySchema = z.object({
|
|
258
|
-
market: z.string().optional(),
|
|
259
|
-
asset_id: z.string(),
|
|
260
|
-
timestamp: z.string().optional(),
|
|
261
|
-
hash: z.string().optional(),
|
|
262
|
-
bids: z.array(orderBookEntrySchema),
|
|
263
|
-
asks: z.array(orderBookEntrySchema),
|
|
264
|
-
min_order_size: z.string().optional(),
|
|
265
|
-
tick_size: z.string().optional(),
|
|
266
|
-
neg_risk: z.boolean().optional()
|
|
267
|
-
}).passthrough();
|
|
268
|
-
/**
|
|
269
|
-
* Spread for a token.
|
|
270
|
-
*/
|
|
271
|
-
const spreadSchema = z.object({
|
|
272
|
-
asset_id: z.string(),
|
|
273
|
-
spread: z.string(),
|
|
274
|
-
bid: z.string().optional(),
|
|
275
|
-
ask: z.string().optional()
|
|
276
|
-
}).passthrough();
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/schemas/data.ts
|
|
277
186
|
const tradeSchema = z.object({
|
|
278
187
|
id: z.string().optional(),
|
|
279
188
|
taker_order_id: z.string().optional(),
|
|
@@ -334,4 +243,4 @@ const liveVolumeSchema = z.object({
|
|
|
334
243
|
}).passthrough();
|
|
335
244
|
|
|
336
245
|
//#endregion
|
|
337
|
-
export {
|
|
246
|
+
export { orderBookEntrySchema as C, priceHistoryResponseSchema as S, spreadSchema as T, tagSchema as _, tradeSchema as a, clobPricesMapSchema as b, listMarketsParamsSchema as c, profileSchema as d, searchResultSchema as f, sportsTeamSchema as g, sportsMetadataSchema as h, positionSchema as i, marketSchema as l, sportsMarketTypeSchema as m, liveVolumeSchema as n, eventSchema as o, seriesSchema as p, openInterestSchema as r, listEventsParamsSchema as s, holderSchema as t, paginationParamsSchema as u, clobMidpointSchema as v, orderBookSummarySchema as w, priceHistoryPointSchema as x, clobPriceSchema as y };
|