@predictorsdk/client 0.8.0 → 0.9.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/dist/Client.d.ts CHANGED
@@ -46,6 +46,21 @@ export declare class PredictorSDKClient {
46
46
  */
47
47
  getMarkets(request?: PredictorSDK.GetMarketsRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.MarketsListResponse>;
48
48
  private __getMarkets;
49
+ /**
50
+ * Returns the canonical top-level categories that can be used to filter unified market discovery with `GET /v1/markets?category=...`. Categories are PredictorSDK-normalized buckets, not provider-native tags. Sports is one category among many; sport/league facets may be added later as deeper filters without changing this top-level list.
51
+ *
52
+ * @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
53
+ *
54
+ * @throws {@link PredictorSDK.UnauthorizedError}
55
+ * @throws {@link PredictorSDK.PaymentRequiredError}
56
+ * @throws {@link PredictorSDK.ForbiddenError}
57
+ * @throws {@link PredictorSDK.TooManyRequestsError}
58
+ *
59
+ * @example
60
+ * await client.getCategories()
61
+ */
62
+ getCategories(requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.CategoriesResponse>;
63
+ private __getCategories;
49
64
  /**
50
65
  * Returns a single market across the six supported platforms (Kalshi, Polymarket, Predict, SX Bet, Hyperliquid, AlphaArcade). The `market_id` is either the composite form returned by `GET /v1/markets` (`{provider}:{native_id}`, e.g. `kalshi:KXNBA-26-SAS`) or the platform-native identifier. Composite IDs dispatch unambiguously by prefix. Native IDs are routed by format inference: Kalshi tickers match the all-caps-with-hyphens shape (`KX…-…`); SX Bet hashes match `0x` + 64 hex characters; numeric ids and kebab-case slugs are shared shape between Polymarket and Predict and probe Polymarket first, falling back to Predict on 404. Hyperliquid integer outcome ids collide with Polymarket/Predict numeric ids and are deliberately not inferred — route them via the composite form (`hyperliquid:<id>`) or `?platform=hyperliquid` (alias `hl`). AlphaArcade market ids are ULIDs (26-char Crockford base32, e.g. `01KQV5TQ9CE20WPEVJZX2ETNQD`); like Hyperliquid they are not inferred in v1 — route them via the composite form (`alpha-arcade:<ulid>`) or `?platform=alpha-arcade` (alias `aa`). Pass `?platform=` explicitly to skip the probe.
51
66
  *
package/dist/Client.js CHANGED
@@ -153,10 +153,16 @@ export class PredictorSDKClient {
153
153
  return core.HttpResponsePromise.fromPromise(this.__getMarkets(request, requestOptions));
154
154
  }
155
155
  async __getMarkets(request = {}, requestOptions) {
156
- const { limit, cursor } = request;
156
+ const { limit, cursor, category } = request;
157
157
  const _queryParams = {
158
158
  limit,
159
159
  cursor,
160
+ category: category != null
161
+ ? serializers.MarketCategory.jsonOrThrow(category, {
162
+ unrecognizedObjectKeys: "strip",
163
+ omitUndefined: true,
164
+ })
165
+ : undefined,
160
166
  };
161
167
  const _authRequest = await this._options.authProvider.getAuthRequest();
162
168
  const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
@@ -249,6 +255,94 @@ export class PredictorSDKClient {
249
255
  }
250
256
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/markets");
251
257
  }
258
+ /**
259
+ * Returns the canonical top-level categories that can be used to filter unified market discovery with `GET /v1/markets?category=...`. Categories are PredictorSDK-normalized buckets, not provider-native tags. Sports is one category among many; sport/league facets may be added later as deeper filters without changing this top-level list.
260
+ *
261
+ * @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
262
+ *
263
+ * @throws {@link PredictorSDK.UnauthorizedError}
264
+ * @throws {@link PredictorSDK.PaymentRequiredError}
265
+ * @throws {@link PredictorSDK.ForbiddenError}
266
+ * @throws {@link PredictorSDK.TooManyRequestsError}
267
+ *
268
+ * @example
269
+ * await client.getCategories()
270
+ */
271
+ getCategories(requestOptions) {
272
+ return core.HttpResponsePromise.fromPromise(this.__getCategories(requestOptions));
273
+ }
274
+ async __getCategories(requestOptions) {
275
+ const _authRequest = await this._options.authProvider.getAuthRequest();
276
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
277
+ const _response = await core.fetcher({
278
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
279
+ (await core.Supplier.get(this._options.environment)) ??
280
+ environments.PredictorSDKEnvironment.Production, "v1/categories"),
281
+ method: "GET",
282
+ headers: _headers,
283
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
284
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
285
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
286
+ abortSignal: requestOptions?.abortSignal,
287
+ fetchFn: this._options?.fetch,
288
+ logging: this._options.logging,
289
+ });
290
+ if (_response.ok) {
291
+ return {
292
+ data: serializers.CategoriesResponse.parseOrThrow(_response.body, {
293
+ unrecognizedObjectKeys: "passthrough",
294
+ allowUnrecognizedUnionMembers: true,
295
+ allowUnrecognizedEnumValues: true,
296
+ skipValidation: true,
297
+ breadcrumbsPrefix: ["response"],
298
+ }),
299
+ rawResponse: _response.rawResponse,
300
+ };
301
+ }
302
+ if (_response.error.reason === "status-code") {
303
+ switch (_response.error.statusCode) {
304
+ case 401:
305
+ throw new PredictorSDK.UnauthorizedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
306
+ unrecognizedObjectKeys: "passthrough",
307
+ allowUnrecognizedUnionMembers: true,
308
+ allowUnrecognizedEnumValues: true,
309
+ skipValidation: true,
310
+ breadcrumbsPrefix: ["response"],
311
+ }), _response.rawResponse);
312
+ case 402:
313
+ throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
314
+ unrecognizedObjectKeys: "passthrough",
315
+ allowUnrecognizedUnionMembers: true,
316
+ allowUnrecognizedEnumValues: true,
317
+ skipValidation: true,
318
+ breadcrumbsPrefix: ["response"],
319
+ }), _response.rawResponse);
320
+ case 403:
321
+ throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
322
+ unrecognizedObjectKeys: "passthrough",
323
+ allowUnrecognizedUnionMembers: true,
324
+ allowUnrecognizedEnumValues: true,
325
+ skipValidation: true,
326
+ breadcrumbsPrefix: ["response"],
327
+ }), _response.rawResponse);
328
+ case 429:
329
+ throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
330
+ unrecognizedObjectKeys: "passthrough",
331
+ allowUnrecognizedUnionMembers: true,
332
+ allowUnrecognizedEnumValues: true,
333
+ skipValidation: true,
334
+ breadcrumbsPrefix: ["response"],
335
+ }), _response.rawResponse);
336
+ default:
337
+ throw new errors.PredictorSDKError({
338
+ statusCode: _response.error.statusCode,
339
+ body: _response.error.body,
340
+ rawResponse: _response.rawResponse,
341
+ });
342
+ }
343
+ }
344
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/categories");
345
+ }
252
346
  /**
253
347
  * Returns a single market across the six supported platforms (Kalshi, Polymarket, Predict, SX Bet, Hyperliquid, AlphaArcade). The `market_id` is either the composite form returned by `GET /v1/markets` (`{provider}:{native_id}`, e.g. `kalshi:KXNBA-26-SAS`) or the platform-native identifier. Composite IDs dispatch unambiguously by prefix. Native IDs are routed by format inference: Kalshi tickers match the all-caps-with-hyphens shape (`KX…-…`); SX Bet hashes match `0x` + 64 hex characters; numeric ids and kebab-case slugs are shared shape between Polymarket and Predict and probe Polymarket first, falling back to Predict on 404. Hyperliquid integer outcome ids collide with Polymarket/Predict numeric ids and are deliberately not inferred — route them via the composite form (`hyperliquid:<id>`) or `?platform=hyperliquid` (alias `hl`). AlphaArcade market ids are ULIDs (26-char Crockford base32, e.g. `01KQV5TQ9CE20WPEVJZX2ETNQD`); like Hyperliquid they are not inferred in v1 — route them via the composite form (`alpha-arcade:<ulid>`) or `?platform=alpha-arcade` (alias `aa`). Pass `?platform=` explicitly to skip the probe.
254
348
  *
@@ -1,3 +1,4 @@
1
+ import type * as PredictorSDK from "../../index.js";
1
2
  /**
2
3
  * @example
3
4
  * {}
@@ -7,4 +8,6 @@ export interface GetMarketsRequest {
7
8
  limit?: number;
8
9
  /** Opaque cursor from a previous response's `pagination.nextCursor` in the SDKs (raw JSON: `pagination.next_cursor`). */
9
10
  cursor?: string;
11
+ /** Canonical top-level category filter. This is PredictorSDK's normalized category, not a provider-native tag. Cursors are bound to the category filter used to create them. */
12
+ category?: PredictorSDK.MarketCategory;
10
13
  }
@@ -0,0 +1,4 @@
1
+ import type * as PredictorSDK from "../index.js";
2
+ export interface CategoriesResponse {
3
+ data: PredictorSDK.CategoryInfo[];
4
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,8 @@
1
+ import type * as PredictorSDK from "../index.js";
2
+ export interface CategoryInfo {
3
+ id: PredictorSDK.MarketCategory;
4
+ /** Human-readable category label. */
5
+ name: string;
6
+ /** Short description of the category's intended scope. */
7
+ description: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,15 @@
1
+ /** PredictorSDK-normalized top-level category. This is intentionally broad and stable across providers; provider-native tags are not exposed as canonical categories. */
2
+ export declare const MarketCategory: {
3
+ readonly Sports: "sports";
4
+ readonly Politics: "politics";
5
+ readonly Crypto: "crypto";
6
+ readonly Finance: "finance";
7
+ readonly Economics: "economics";
8
+ readonly Weather: "weather";
9
+ readonly Culture: "culture";
10
+ readonly Technology: "technology";
11
+ readonly Entertainment: "entertainment";
12
+ readonly Other: "other";
13
+ readonly Unknown: "unknown";
14
+ };
15
+ export type MarketCategory = (typeof MarketCategory)[keyof typeof MarketCategory];
@@ -0,0 +1,15 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ /** PredictorSDK-normalized top-level category. This is intentionally broad and stable across providers; provider-native tags are not exposed as canonical categories. */
3
+ export const MarketCategory = {
4
+ Sports: "sports",
5
+ Politics: "politics",
6
+ Crypto: "crypto",
7
+ Finance: "finance",
8
+ Economics: "economics",
9
+ Weather: "weather",
10
+ Culture: "culture",
11
+ Technology: "technology",
12
+ Entertainment: "entertainment",
13
+ Other: "other",
14
+ Unknown: "unknown",
15
+ };
@@ -6,4 +6,5 @@ export interface UnifiedMarket {
6
6
  provider: PredictorSDK.UnifiedMarketProvider;
7
7
  /** Human-readable market title/question. */
8
8
  title: string;
9
+ category: PredictorSDK.MarketCategory;
9
10
  }
@@ -1,3 +1,5 @@
1
+ export * from "./CategoriesResponse.js";
2
+ export * from "./CategoryInfo.js";
1
3
  export * from "./CryptoPriceItem.js";
2
4
  export * from "./CryptoPricesResponse.js";
3
5
  export * from "./ErrorResponse.js";
@@ -7,6 +9,7 @@ export * from "./EventResponse.js";
7
9
  export * from "./EventResponsePlatform.js";
8
10
  export * from "./GetEventRequestPlatform.js";
9
11
  export * from "./GetMarketRequestPlatform.js";
12
+ export * from "./MarketCategory.js";
10
13
  export * from "./MarketDetailOutcome.js";
11
14
  export * from "./MarketDetailPricing.js";
12
15
  export * from "./MarketDetailPricingAvailability.js";
@@ -1,3 +1,5 @@
1
+ export * from "./CategoriesResponse.js";
2
+ export * from "./CategoryInfo.js";
1
3
  export * from "./CryptoPriceItem.js";
2
4
  export * from "./CryptoPricesResponse.js";
3
5
  export * from "./ErrorResponse.js";
@@ -7,6 +9,7 @@ export * from "./EventResponse.js";
7
9
  export * from "./EventResponsePlatform.js";
8
10
  export * from "./GetEventRequestPlatform.js";
9
11
  export * from "./GetMarketRequestPlatform.js";
12
+ export * from "./MarketCategory.js";
10
13
  export * from "./MarketDetailOutcome.js";
11
14
  export * from "./MarketDetailPricing.js";
12
15
  export * from "./MarketDetailPricingAvailability.js";
@@ -0,0 +1,10 @@
1
+ import type * as PredictorSDK from "../../api/index.js";
2
+ import * as core from "../../core/index.js";
3
+ import type * as serializers from "../index.js";
4
+ import { CategoryInfo } from "./CategoryInfo.js";
5
+ export declare const CategoriesResponse: core.serialization.ObjectSchema<serializers.CategoriesResponse.Raw, PredictorSDK.CategoriesResponse>;
6
+ export declare namespace CategoriesResponse {
7
+ interface Raw {
8
+ data: CategoryInfo.Raw[];
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.js";
3
+ import { CategoryInfo } from "./CategoryInfo.js";
4
+ export const CategoriesResponse = core.serialization.object({
5
+ data: core.serialization.list(CategoryInfo),
6
+ });
@@ -0,0 +1,12 @@
1
+ import type * as PredictorSDK from "../../api/index.js";
2
+ import * as core from "../../core/index.js";
3
+ import type * as serializers from "../index.js";
4
+ import { MarketCategory } from "./MarketCategory.js";
5
+ export declare const CategoryInfo: core.serialization.ObjectSchema<serializers.CategoryInfo.Raw, PredictorSDK.CategoryInfo>;
6
+ export declare namespace CategoryInfo {
7
+ interface Raw {
8
+ id: MarketCategory.Raw;
9
+ name: string;
10
+ description: string;
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.js";
3
+ import { MarketCategory } from "./MarketCategory.js";
4
+ export const CategoryInfo = core.serialization.object({
5
+ id: MarketCategory,
6
+ name: core.serialization.string(),
7
+ description: core.serialization.string(),
8
+ });
@@ -0,0 +1,7 @@
1
+ import type * as PredictorSDK from "../../api/index.js";
2
+ import * as core from "../../core/index.js";
3
+ import type * as serializers from "../index.js";
4
+ export declare const MarketCategory: core.serialization.Schema<serializers.MarketCategory.Raw, PredictorSDK.MarketCategory>;
5
+ export declare namespace MarketCategory {
6
+ type Raw = "sports" | "politics" | "crypto" | "finance" | "economics" | "weather" | "culture" | "technology" | "entertainment" | "other" | "unknown";
7
+ }
@@ -0,0 +1,15 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.js";
3
+ export const MarketCategory = core.serialization.enum_([
4
+ "sports",
5
+ "politics",
6
+ "crypto",
7
+ "finance",
8
+ "economics",
9
+ "weather",
10
+ "culture",
11
+ "technology",
12
+ "entertainment",
13
+ "other",
14
+ "unknown",
15
+ ]);
@@ -1,6 +1,7 @@
1
1
  import type * as PredictorSDK from "../../api/index.js";
2
2
  import * as core from "../../core/index.js";
3
3
  import type * as serializers from "../index.js";
4
+ import { MarketCategory } from "./MarketCategory.js";
4
5
  import { UnifiedMarketProvider } from "./UnifiedMarketProvider.js";
5
6
  export declare const UnifiedMarket: core.serialization.ObjectSchema<serializers.UnifiedMarket.Raw, PredictorSDK.UnifiedMarket>;
6
7
  export declare namespace UnifiedMarket {
@@ -8,5 +9,6 @@ export declare namespace UnifiedMarket {
8
9
  id: string;
9
10
  provider: UnifiedMarketProvider.Raw;
10
11
  title: string;
12
+ category: MarketCategory.Raw;
11
13
  }
12
14
  }
@@ -1,8 +1,10 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  import * as core from "../../core/index.js";
3
+ import { MarketCategory } from "./MarketCategory.js";
3
4
  import { UnifiedMarketProvider } from "./UnifiedMarketProvider.js";
4
5
  export const UnifiedMarket = core.serialization.object({
5
6
  id: core.serialization.string(),
6
7
  provider: UnifiedMarketProvider,
7
8
  title: core.serialization.string(),
9
+ category: MarketCategory,
8
10
  });
@@ -1,3 +1,5 @@
1
+ export * from "./CategoriesResponse.js";
2
+ export * from "./CategoryInfo.js";
1
3
  export * from "./CryptoPriceItem.js";
2
4
  export * from "./CryptoPricesResponse.js";
3
5
  export * from "./ErrorResponse.js";
@@ -7,6 +9,7 @@ export * from "./EventResponse.js";
7
9
  export * from "./EventResponsePlatform.js";
8
10
  export * from "./GetEventRequestPlatform.js";
9
11
  export * from "./GetMarketRequestPlatform.js";
12
+ export * from "./MarketCategory.js";
10
13
  export * from "./MarketDetailOutcome.js";
11
14
  export * from "./MarketDetailPricing.js";
12
15
  export * from "./MarketDetailPricingAvailability.js";
@@ -1,3 +1,5 @@
1
+ export * from "./CategoriesResponse.js";
2
+ export * from "./CategoryInfo.js";
1
3
  export * from "./CryptoPriceItem.js";
2
4
  export * from "./CryptoPricesResponse.js";
3
5
  export * from "./ErrorResponse.js";
@@ -7,6 +9,7 @@ export * from "./EventResponse.js";
7
9
  export * from "./EventResponsePlatform.js";
8
10
  export * from "./GetEventRequestPlatform.js";
9
11
  export * from "./GetMarketRequestPlatform.js";
12
+ export * from "./MarketCategory.js";
10
13
  export * from "./MarketDetailOutcome.js";
11
14
  export * from "./MarketDetailPricing.js";
12
15
  export * from "./MarketDetailPricingAvailability.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predictorsdk/client",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "The official TypeScript/JavaScript client for the PredictorSDK matching markets API",
5
5
  "license": "MIT",
6
6
  "keywords": [