@wahoopredict/trading-sdk 0.4.0 → 0.4.1

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 (2) hide show
  1. package/README.md +96 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -30,6 +30,28 @@ if (error) {
30
30
  }
31
31
  ```
32
32
 
33
+ ## Configuration
34
+
35
+ ### Custom Base URL
36
+
37
+ ```typescript
38
+ const client = createWahooClient({
39
+ apiKey: "your-api-key",
40
+ secretKey: "your-secret-key",
41
+ });
42
+ ```
43
+
44
+ ### Environment Variables
45
+
46
+ We recommend storing credentials in environment variables:
47
+
48
+ ```typescript
49
+ const client = createWahooClient({
50
+ apiKey: process.env.WAHOO_API_KEY!,
51
+ secretKey: process.env.WAHOO_SECRET_KEY!,
52
+ });
53
+ ```
54
+
33
55
  ## Authentication
34
56
 
35
57
  The SDK uses HMAC-SHA256 signature-based authentication. You need an API key and secret key from WahooPredict.
@@ -266,44 +288,93 @@ Common error types:
266
288
 
267
289
  ## TypeScript Support
268
290
 
269
- The SDK provides full TypeScript support with auto-generated types from the OpenAPI specification:
291
+ The SDK provides full TypeScript support with auto-generated types from the OpenAPI specification.
292
+
293
+ ### When You DON'T Need to Import Types
294
+
295
+ For most usage, TypeScript inference handles everything:
270
296
 
271
297
  ```typescript
272
- import type { paths, components } from "@wahoopredict/trading-sdk";
298
+ // Just works no type imports needed
299
+ const { data, error } = await client.POST("/event/positions", {
300
+ body: { page: 1, limit: 20 },
301
+ });
302
+
303
+ // TypeScript knows data.data is Position[]
304
+ data?.data.forEach((position) => {
305
+ console.log(position.id, position.avgPrice); // Full autocomplete
306
+ });
307
+ ```
308
+
309
+ ### When You NEED to Import Types
310
+
311
+ Import types when you're writing functions that accept or return SDK data:
312
+
313
+ ```typescript
314
+ import type { components } from "@wahoopredict/trading-sdk";
273
315
 
274
- // Use component types
275
- type Event = components["schemas"]["Event"];
276
- type Order = components["schemas"]["Order"];
277
316
  type Position = components["schemas"]["Position"];
317
+ type Event = components["schemas"]["Event"];
278
318
 
279
- // Use path types for custom implementations
280
- type PlaceOrderBody =
281
- paths["/event/place-order"]["post"]["requestBody"]["content"]["application/json"];
282
- ```
319
+ // Now you can use Position in your own function signatures
320
+ function filterProfitablePositions(positions: Position[]): Position[] {
321
+ return positions.filter((p) => parseFloat(p.part) > 100);
322
+ }
283
323
 
284
- ## Configuration
324
+ async function getEventWithPositions(client: WahooClient, eventId: string) {
325
+ const [event, positions] = await Promise.all([
326
+ client.GET("/event/event-details/{eventId}", {
327
+ params: { path: { eventId } },
328
+ }),
329
+ client.POST("/event/positions", { body: { page: 1, limit: 100 } }),
330
+ ]);
331
+
332
+ return {
333
+ event: event.data as Event | undefined,
334
+ positions: positions.data?.data as Position[] | undefined,
335
+ };
336
+ }
337
+ ```
285
338
 
286
- ### Custom Base URL
339
+ ### Common Type Extractions
287
340
 
288
341
  ```typescript
289
- const client = createWahooClient({
290
- apiKey: "your-api-key",
291
- secretKey: "your-secret-key",
292
- baseUrl: "https://staging-api.wahoopredict.com/oapi/v2", // Optional
293
- });
342
+ import type { components, operations } from "@wahoopredict/trading-sdk";
343
+
344
+ // Entity types
345
+ type Event = components["schemas"]["Event"];
346
+ type Position = components["schemas"]["Position"];
347
+ type Order = components["schemas"]["Order"];
348
+ type Outcome = components["schemas"]["Outcome"];
349
+ type OutcomeOption = components["schemas"]["OutcomeOption"];
350
+
351
+ // Request body types (for building params programmatically)
352
+ type PlaceOrderParams = components["schemas"]["placeOrderRequestBody"];
353
+ type EventsListParams =
354
+ operations["getEventsList"]["requestBody"]["content"]["application/json"];
355
+
356
+ // Response types (for annotating wrapper function returns)
357
+ type EventsListResponse =
358
+ operations["getEventsList"]["responses"]["200"]["content"]["application/json"];
359
+ type EventsListItem = EventsListResponse["data"][number];
294
360
  ```
295
361
 
296
- ### Environment Variables
362
+ ### Using `paths` for Advanced Type Access
297
363
 
298
- We recommend storing credentials in environment variables:
364
+ The `paths` type gives you access to request/response types for any endpoint:
299
365
 
300
366
  ```typescript
301
- const client = createWahooClient({
302
- apiKey: process.env.WAHOO_API_KEY!,
303
- secretKey: process.env.WAHOO_SECRET_KEY!,
304
- });
305
- ```
367
+ import type { paths } from "@wahoopredict/trading-sdk";
306
368
 
307
- ## License
369
+ // Extract request body type
370
+ type PlaceOrderBody =
371
+ paths["/event/place-order"]["post"]["requestBody"]["content"]["application/json"];
308
372
 
309
- MIT
373
+ // Extract successful response type
374
+ type PlaceOrderResponse =
375
+ paths["/event/place-order"]["post"]["responses"]["200"]["content"]["application/json"];
376
+
377
+ // Extract error response type
378
+ type PlaceOrderError =
379
+ paths["/event/place-order"]["post"]["responses"]["400"]["content"]["application/json"];
380
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wahoopredict/trading-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "TypeScript SDK for the WahooPredict trading API",
5
5
  "author": "WahooPredict",
6
6
  "license": "MIT",