@predictorsdk/client 0.1.2 → 0.2.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
@@ -27,6 +27,26 @@ export declare class PredictorSDKClient {
27
27
  */
28
28
  getSportsMatchingMarkets(request?: PredictorSDK.GetSportsMatchingMarketsRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.SportsMatchingResponse>;
29
29
  private __getSportsMatchingMarkets;
30
+ /**
31
+ * Returns per-second price data for a Binance trading pair. When called without a time range, returns the latest price. With `start_time` and `end_time`, returns historical per-second prices in newest-first order. Supports cursor-based pagination for large result sets. Unknown or invalid symbols return `200` with `{"prices":[]}` and omit `total`.
32
+ *
33
+ * @param {PredictorSDK.GetBinanceCryptoPricesRequest} request
34
+ * @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
35
+ *
36
+ * @throws {@link PredictorSDK.BadRequestError}
37
+ * @throws {@link PredictorSDK.UnauthorizedError}
38
+ * @throws {@link PredictorSDK.ForbiddenError}
39
+ * @throws {@link PredictorSDK.TooManyRequestsError}
40
+ * @throws {@link PredictorSDK.BadGatewayError}
41
+ * @throws {@link PredictorSDK.ServiceUnavailableError}
42
+ *
43
+ * @example
44
+ * await client.getBinanceCryptoPrices({
45
+ * currency: "btcusdt"
46
+ * })
47
+ */
48
+ getBinanceCryptoPrices(request: PredictorSDK.GetBinanceCryptoPricesRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.CryptoPricesResponse>;
49
+ private __getBinanceCryptoPrices;
30
50
  /**
31
51
  * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
32
52
  * This is useful for making requests to endpoints not yet supported in the SDK.
package/dist/Client.js CHANGED
@@ -117,6 +117,123 @@ export class PredictorSDKClient {
117
117
  }
118
118
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/matching-markets/sports");
119
119
  }
120
+ /**
121
+ * Returns per-second price data for a Binance trading pair. When called without a time range, returns the latest price. With `start_time` and `end_time`, returns historical per-second prices in newest-first order. Supports cursor-based pagination for large result sets. Unknown or invalid symbols return `200` with `{"prices":[]}` and omit `total`.
122
+ *
123
+ * @param {PredictorSDK.GetBinanceCryptoPricesRequest} request
124
+ * @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
125
+ *
126
+ * @throws {@link PredictorSDK.BadRequestError}
127
+ * @throws {@link PredictorSDK.UnauthorizedError}
128
+ * @throws {@link PredictorSDK.ForbiddenError}
129
+ * @throws {@link PredictorSDK.TooManyRequestsError}
130
+ * @throws {@link PredictorSDK.BadGatewayError}
131
+ * @throws {@link PredictorSDK.ServiceUnavailableError}
132
+ *
133
+ * @example
134
+ * await client.getBinanceCryptoPrices({
135
+ * currency: "btcusdt"
136
+ * })
137
+ */
138
+ getBinanceCryptoPrices(request, requestOptions) {
139
+ return core.HttpResponsePromise.fromPromise(this.__getBinanceCryptoPrices(request, requestOptions));
140
+ }
141
+ async __getBinanceCryptoPrices(request, requestOptions) {
142
+ const { currency, startTime, endTime, limit, paginationKey } = request;
143
+ const _queryParams = {
144
+ currency,
145
+ start_time: startTime,
146
+ end_time: endTime,
147
+ limit,
148
+ pagination_key: paginationKey,
149
+ };
150
+ const _authRequest = await this._options.authProvider.getAuthRequest();
151
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
152
+ const _response = await core.fetcher({
153
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
154
+ (await core.Supplier.get(this._options.environment)) ??
155
+ environments.PredictorSDKEnvironment.Production, "v1/crypto-prices/binance"),
156
+ method: "GET",
157
+ headers: _headers,
158
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
159
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
160
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
161
+ abortSignal: requestOptions?.abortSignal,
162
+ fetchFn: this._options?.fetch,
163
+ logging: this._options.logging,
164
+ });
165
+ if (_response.ok) {
166
+ return {
167
+ data: serializers.CryptoPricesResponse.parseOrThrow(_response.body, {
168
+ unrecognizedObjectKeys: "passthrough",
169
+ allowUnrecognizedUnionMembers: true,
170
+ allowUnrecognizedEnumValues: true,
171
+ skipValidation: true,
172
+ breadcrumbsPrefix: ["response"],
173
+ }),
174
+ rawResponse: _response.rawResponse,
175
+ };
176
+ }
177
+ if (_response.error.reason === "status-code") {
178
+ switch (_response.error.statusCode) {
179
+ case 400:
180
+ throw new PredictorSDK.BadRequestError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
181
+ unrecognizedObjectKeys: "passthrough",
182
+ allowUnrecognizedUnionMembers: true,
183
+ allowUnrecognizedEnumValues: true,
184
+ skipValidation: true,
185
+ breadcrumbsPrefix: ["response"],
186
+ }), _response.rawResponse);
187
+ case 401:
188
+ throw new PredictorSDK.UnauthorizedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
189
+ unrecognizedObjectKeys: "passthrough",
190
+ allowUnrecognizedUnionMembers: true,
191
+ allowUnrecognizedEnumValues: true,
192
+ skipValidation: true,
193
+ breadcrumbsPrefix: ["response"],
194
+ }), _response.rawResponse);
195
+ case 403:
196
+ throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
197
+ unrecognizedObjectKeys: "passthrough",
198
+ allowUnrecognizedUnionMembers: true,
199
+ allowUnrecognizedEnumValues: true,
200
+ skipValidation: true,
201
+ breadcrumbsPrefix: ["response"],
202
+ }), _response.rawResponse);
203
+ case 429:
204
+ throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
205
+ unrecognizedObjectKeys: "passthrough",
206
+ allowUnrecognizedUnionMembers: true,
207
+ allowUnrecognizedEnumValues: true,
208
+ skipValidation: true,
209
+ breadcrumbsPrefix: ["response"],
210
+ }), _response.rawResponse);
211
+ case 502:
212
+ throw new PredictorSDK.BadGatewayError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
213
+ unrecognizedObjectKeys: "passthrough",
214
+ allowUnrecognizedUnionMembers: true,
215
+ allowUnrecognizedEnumValues: true,
216
+ skipValidation: true,
217
+ breadcrumbsPrefix: ["response"],
218
+ }), _response.rawResponse);
219
+ case 503:
220
+ throw new PredictorSDK.ServiceUnavailableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
221
+ unrecognizedObjectKeys: "passthrough",
222
+ allowUnrecognizedUnionMembers: true,
223
+ allowUnrecognizedEnumValues: true,
224
+ skipValidation: true,
225
+ breadcrumbsPrefix: ["response"],
226
+ }), _response.rawResponse);
227
+ default:
228
+ throw new errors.PredictorSDKError({
229
+ statusCode: _response.error.statusCode,
230
+ body: _response.error.body,
231
+ rawResponse: _response.rawResponse,
232
+ });
233
+ }
234
+ }
235
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/crypto-prices/binance");
236
+ }
120
237
  /**
121
238
  * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
122
239
  * This is useful for making requests to endpoints not yet supported in the SDK.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * currency: "btcusdt"
5
+ * }
6
+ */
7
+ export interface GetBinanceCryptoPricesRequest {
8
+ /** Binance trading pair (e.g. `btcusdt`, `ethusdt`, `solusdt`). Must contain only alphanumeric characters (no hyphens, underscores, or other separators). Uppercase is accepted and automatically lowercased (e.g. `BTCUSDT` → `btcusdt`). Must be a valid Binance symbol; unknown symbols return `200` with an empty `prices` array. */
9
+ currency: string;
10
+ /** Start of the time range as a Unix timestamp in milliseconds (inclusive). Negative values are clamped to 0. */
11
+ startTime?: number;
12
+ /** End of the time range as a Unix timestamp in milliseconds (inclusive). Negative values are clamped to 0. */
13
+ endTime?: number;
14
+ /** Maximum number of prices to return. Defaults to 100 when a time range is present. Values above 100 are silently clamped to 100. Without a time range, this parameter is ignored — the endpoint always returns the single latest price. */
15
+ limit?: number;
16
+ /** Base64-encoded cursor from a previous response to fetch the next page of results. */
17
+ paginationKey?: string;
18
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1 +1,2 @@
1
+ export type { GetBinanceCryptoPricesRequest } from "./GetBinanceCryptoPricesRequest.js";
1
2
  export type { GetSportsMatchingMarketsRequest } from "./GetSportsMatchingMarketsRequest.js";
@@ -0,0 +1,6 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as PredictorSDK from "../index.js";
4
+ export declare class BadGatewayError extends errors.PredictorSDKError {
5
+ constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
6
+ }
@@ -0,0 +1,17 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as errors from "../../errors/index.js";
3
+ export class BadGatewayError extends errors.PredictorSDKError {
4
+ constructor(body, rawResponse) {
5
+ super({
6
+ message: "BadGatewayError",
7
+ statusCode: 502,
8
+ body: body,
9
+ rawResponse: rawResponse,
10
+ });
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
16
+ }
17
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./BadGatewayError.js";
1
2
  export * from "./BadRequestError.js";
2
3
  export * from "./ForbiddenError.js";
3
4
  export * from "./ServiceUnavailableError.js";
@@ -1,3 +1,4 @@
1
+ export * from "./BadGatewayError.js";
1
2
  export * from "./BadRequestError.js";
2
3
  export * from "./ForbiddenError.js";
3
4
  export * from "./ServiceUnavailableError.js";
@@ -0,0 +1,8 @@
1
+ export interface CryptoPriceItem {
2
+ /** Trading pair in lowercase (e.g. `btcusdt`). */
3
+ symbol: string;
4
+ /** Close price for the 1-second interval. */
5
+ value: number;
6
+ /** Unix timestamp in milliseconds for the start of the 1-second interval. */
7
+ timestamp: number;
8
+ }
@@ -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 CryptoPricesResponse {
3
+ prices: PredictorSDK.CryptoPriceItem[];
4
+ /** Base64-encoded cursor for fetching the next page. Absent when there are no more results. */
5
+ paginationKey?: string;
6
+ /** Number of prices in this response page. Omitted on empty responses for unknown symbols. */
7
+ total?: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,4 +1,6 @@
1
1
  export interface ErrorResponse {
2
2
  error: string;
3
+ /** Additional detail about the error. May be present, including on some validation errors. */
4
+ message?: string;
3
5
  statusCode: number;
4
6
  }
@@ -1,3 +1,5 @@
1
+ export * from "./CryptoPriceItem.js";
2
+ export * from "./CryptoPricesResponse.js";
1
3
  export * from "./ErrorResponse.js";
2
4
  export * from "./PlatformMarket.js";
3
5
  export * from "./PlatformMarketPlatform.js";
@@ -1,3 +1,5 @@
1
+ export * from "./CryptoPriceItem.js";
2
+ export * from "./CryptoPricesResponse.js";
1
3
  export * from "./ErrorResponse.js";
2
4
  export * from "./PlatformMarket.js";
3
5
  export * from "./PlatformMarketPlatform.js";
@@ -0,0 +1,11 @@
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 CryptoPriceItem: core.serialization.ObjectSchema<serializers.CryptoPriceItem.Raw, PredictorSDK.CryptoPriceItem>;
5
+ export declare namespace CryptoPriceItem {
6
+ interface Raw {
7
+ symbol: string;
8
+ value: number;
9
+ timestamp: number;
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as core from "../../core/index.js";
3
+ export const CryptoPriceItem = core.serialization.object({
4
+ symbol: core.serialization.string(),
5
+ value: core.serialization.number(),
6
+ timestamp: core.serialization.number(),
7
+ });
@@ -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 { CryptoPriceItem } from "./CryptoPriceItem.js";
5
+ export declare const CryptoPricesResponse: core.serialization.ObjectSchema<serializers.CryptoPricesResponse.Raw, PredictorSDK.CryptoPricesResponse>;
6
+ export declare namespace CryptoPricesResponse {
7
+ interface Raw {
8
+ prices: CryptoPriceItem.Raw[];
9
+ pagination_key?: string | null;
10
+ total?: number | null;
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 { CryptoPriceItem } from "./CryptoPriceItem.js";
4
+ export const CryptoPricesResponse = core.serialization.object({
5
+ prices: core.serialization.list(CryptoPriceItem),
6
+ paginationKey: core.serialization.property("pagination_key", core.serialization.string().optional()),
7
+ total: core.serialization.number().optional(),
8
+ });
@@ -5,6 +5,7 @@ export declare const ErrorResponse: core.serialization.ObjectSchema<serializers.
5
5
  export declare namespace ErrorResponse {
6
6
  interface Raw {
7
7
  error: string;
8
+ message?: string | null;
8
9
  status_code: number;
9
10
  }
10
11
  }
@@ -2,5 +2,6 @@
2
2
  import * as core from "../../core/index.js";
3
3
  export const ErrorResponse = core.serialization.object({
4
4
  error: core.serialization.string(),
5
+ message: core.serialization.string().optional(),
5
6
  statusCode: core.serialization.property("status_code", core.serialization.number()),
6
7
  });
@@ -1,3 +1,5 @@
1
+ export * from "./CryptoPriceItem.js";
2
+ export * from "./CryptoPricesResponse.js";
1
3
  export * from "./ErrorResponse.js";
2
4
  export * from "./PlatformMarket.js";
3
5
  export * from "./PlatformMarketPlatform.js";
@@ -1,3 +1,5 @@
1
+ export * from "./CryptoPriceItem.js";
2
+ export * from "./CryptoPricesResponse.js";
1
3
  export * from "./ErrorResponse.js";
2
4
  export * from "./PlatformMarket.js";
3
5
  export * from "./PlatformMarketPlatform.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predictorsdk/client",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "The official TypeScript/JavaScript client for the PredictorSDK matching markets API",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -47,7 +47,7 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/node": "^22.0.0",
50
+ "@types/node": "^25.5.2",
51
51
  "typescript": "^5.7.0"
52
52
  }
53
53
  }