@predictorsdk/client 0.1.1 → 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/README.md +1 -1
- package/dist/Client.d.ts +20 -0
- package/dist/Client.js +164 -7
- package/dist/api/client/requests/GetBinanceCryptoPricesRequest.d.ts +18 -0
- package/dist/api/client/requests/GetBinanceCryptoPricesRequest.js +2 -0
- package/dist/api/client/requests/GetSportsMatchingMarketsRequest.d.ts +4 -4
- package/dist/api/client/requests/index.d.ts +1 -0
- package/dist/api/errors/BadGatewayError.d.ts +6 -0
- package/dist/api/errors/BadGatewayError.js +17 -0
- package/dist/api/errors/index.d.ts +1 -0
- package/dist/api/errors/index.js +1 -0
- package/dist/api/types/CryptoPriceItem.d.ts +8 -0
- package/dist/api/types/CryptoPriceItem.js +2 -0
- package/dist/api/types/CryptoPricesResponse.d.ts +8 -0
- package/dist/api/types/CryptoPricesResponse.js +2 -0
- package/dist/api/types/ErrorResponse.d.ts +3 -1
- package/dist/api/types/PlatformMarket.d.ts +8 -16
- package/dist/api/types/PlatformMarket.js +1 -9
- package/dist/api/types/PlatformMarketPlatform.d.ts +7 -0
- package/dist/api/types/PlatformMarketPlatform.js +7 -0
- package/dist/api/types/index.d.ts +3 -0
- package/dist/api/types/index.js +3 -0
- package/dist/core/auth/BasicAuth.d.ts +2 -2
- package/dist/core/auth/BasicAuth.js +6 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/schemas/Schema.d.ts +88 -0
- package/dist/core/schemas/Schema.js +22 -0
- package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/dist/core/schemas/builders/bigint/bigint.js +53 -0
- package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
- package/dist/core/schemas/builders/bigint/index.js +1 -0
- package/dist/core/schemas/builders/date/date.d.ts +2 -0
- package/dist/core/schemas/builders/date/date.js +62 -0
- package/dist/core/schemas/builders/date/index.d.ts +1 -0
- package/dist/core/schemas/builders/date/index.js +1 -0
- package/dist/core/schemas/builders/enum/enum.d.ts +2 -0
- package/dist/core/schemas/builders/enum/enum.js +35 -0
- package/dist/core/schemas/builders/enum/index.d.ts +1 -0
- package/dist/core/schemas/builders/enum/index.js +1 -0
- package/dist/core/schemas/builders/index.d.ts +14 -0
- package/dist/core/schemas/builders/index.js +14 -0
- package/dist/core/schemas/builders/lazy/index.d.ts +3 -0
- package/dist/core/schemas/builders/lazy/index.js +2 -0
- package/dist/core/schemas/builders/lazy/lazy.d.ts +5 -0
- package/dist/core/schemas/builders/lazy/lazy.js +22 -0
- package/dist/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
- package/dist/core/schemas/builders/lazy/lazyObject.js +17 -0
- package/dist/core/schemas/builders/list/index.d.ts +1 -0
- package/dist/core/schemas/builders/list/index.js +1 -0
- package/dist/core/schemas/builders/list/list.d.ts +2 -0
- package/dist/core/schemas/builders/list/list.js +49 -0
- package/dist/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
- package/dist/core/schemas/builders/literals/booleanLiteral.js +25 -0
- package/dist/core/schemas/builders/literals/index.d.ts +2 -0
- package/dist/core/schemas/builders/literals/index.js +2 -0
- package/dist/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
- package/dist/core/schemas/builders/literals/stringLiteral.js +25 -0
- package/dist/core/schemas/builders/object/index.d.ts +6 -0
- package/dist/core/schemas/builders/object/index.js +3 -0
- package/dist/core/schemas/builders/object/object.d.ts +3 -0
- package/dist/core/schemas/builders/object/object.js +381 -0
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +4 -0
- package/dist/core/schemas/builders/object/property.d.ts +8 -0
- package/dist/core/schemas/builders/object/property.js +11 -0
- package/dist/core/schemas/builders/object/types.d.ts +31 -0
- package/dist/core/schemas/builders/object/types.js +1 -0
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +62 -0
- package/dist/core/schemas/builders/object-like/index.d.ts +2 -0
- package/dist/core/schemas/builders/object-like/index.js +1 -0
- package/dist/core/schemas/builders/object-like/types.d.ts +7 -0
- package/dist/core/schemas/builders/object-like/types.js +1 -0
- package/dist/core/schemas/builders/primitives/any.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/any.js +6 -0
- package/dist/core/schemas/builders/primitives/boolean.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/boolean.js +22 -0
- package/dist/core/schemas/builders/primitives/index.d.ts +6 -0
- package/dist/core/schemas/builders/primitives/index.js +6 -0
- package/dist/core/schemas/builders/primitives/never.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/never.js +11 -0
- package/dist/core/schemas/builders/primitives/number.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/number.js +22 -0
- package/dist/core/schemas/builders/primitives/string.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/string.js +22 -0
- package/dist/core/schemas/builders/primitives/unknown.d.ts +2 -0
- package/dist/core/schemas/builders/primitives/unknown.js +3 -0
- package/dist/core/schemas/builders/record/index.d.ts +2 -0
- package/dist/core/schemas/builders/record/index.js +1 -0
- package/dist/core/schemas/builders/record/record.d.ts +4 -0
- package/dist/core/schemas/builders/record/record.js +133 -0
- package/dist/core/schemas/builders/record/types.d.ts +6 -0
- package/dist/core/schemas/builders/record/types.js +1 -0
- package/dist/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
- package/dist/core/schemas/builders/schema-utils/JsonError.js +9 -0
- package/dist/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
- package/dist/core/schemas/builders/schema-utils/ParseError.js +9 -0
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +21 -0
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +150 -0
- package/dist/core/schemas/builders/schema-utils/index.d.ts +4 -0
- package/dist/core/schemas/builders/schema-utils/index.js +3 -0
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +6 -0
- package/dist/core/schemas/builders/set/index.d.ts +1 -0
- package/dist/core/schemas/builders/set/index.js +1 -0
- package/dist/core/schemas/builders/set/set.d.ts +2 -0
- package/dist/core/schemas/builders/set/set.js +42 -0
- package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
- package/dist/core/schemas/builders/undiscriminated-union/index.js +1 -0
- package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
- package/dist/core/schemas/builders/undiscriminated-union/types.js +1 -0
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +39 -0
- package/dist/core/schemas/builders/union/discriminant.d.ts +5 -0
- package/dist/core/schemas/builders/union/discriminant.js +6 -0
- package/dist/core/schemas/builders/union/index.d.ts +4 -0
- package/dist/core/schemas/builders/union/index.js +2 -0
- package/dist/core/schemas/builders/union/types.d.ts +13 -0
- package/dist/core/schemas/builders/union/types.js +1 -0
- package/dist/core/schemas/builders/union/union.d.ts +4 -0
- package/dist/core/schemas/builders/union/union.js +127 -0
- package/dist/core/schemas/index.d.ts +2 -0
- package/dist/core/schemas/index.js +1 -0
- package/dist/core/schemas/utils/MaybePromise.d.ts +1 -0
- package/dist/core/schemas/utils/MaybePromise.js +1 -0
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -0
- package/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +15 -0
- package/dist/core/schemas/utils/entries.d.ts +1 -0
- package/dist/core/schemas/utils/entries.js +3 -0
- package/dist/core/schemas/utils/filterObject.d.ts +1 -0
- package/dist/core/schemas/utils/filterObject.js +10 -0
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +24 -0
- package/dist/core/schemas/utils/isPlainObject.d.ts +1 -0
- package/dist/core/schemas/utils/isPlainObject.js +12 -0
- package/dist/core/schemas/utils/keys.d.ts +1 -0
- package/dist/core/schemas/utils/keys.js +3 -0
- package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/dist/core/schemas/utils/maybeSkipValidation.js +28 -0
- package/dist/core/schemas/utils/partition.d.ts +1 -0
- package/dist/core/schemas/utils/partition.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.js +1 -0
- package/dist/serialization/types/CryptoPriceItem.d.ts +11 -0
- package/dist/serialization/types/CryptoPriceItem.js +7 -0
- package/dist/serialization/types/CryptoPricesResponse.d.ts +12 -0
- package/dist/serialization/types/CryptoPricesResponse.js +8 -0
- package/dist/serialization/types/ErrorResponse.d.ts +11 -0
- package/dist/serialization/types/ErrorResponse.js +7 -0
- package/dist/serialization/types/PlatformMarket.d.ts +16 -0
- package/dist/serialization/types/PlatformMarket.js +12 -0
- package/dist/serialization/types/PlatformMarketPlatform.d.ts +7 -0
- package/dist/serialization/types/PlatformMarketPlatform.js +3 -0
- package/dist/serialization/types/SportsMatchingResponse.d.ts +10 -0
- package/dist/serialization/types/SportsMatchingResponse.js +6 -0
- package/dist/serialization/types/index.d.ts +6 -0
- package/dist/serialization/types/index.js +6 -0
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ import { PredictorSDKClient } from "@predictorsdk/client";
|
|
|
16
16
|
const client = new PredictorSDKClient({ token: "your-api-key" });
|
|
17
17
|
|
|
18
18
|
const { markets } = await client.getSportsMatchingMarkets({
|
|
19
|
-
|
|
19
|
+
kalshiEventTicker: "KXMLB-25-NYM-COL-2025-04-03",
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
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
|
@@ -6,6 +6,7 @@ import * as core from "./core/index.js";
|
|
|
6
6
|
import * as environments from "./environments.js";
|
|
7
7
|
import { handleNonStatusCodeError } from "./errors/handleNonStatusCodeError.js";
|
|
8
8
|
import * as errors from "./errors/index.js";
|
|
9
|
+
import * as serializers from "./serialization/index.js";
|
|
9
10
|
export class PredictorSDKClient {
|
|
10
11
|
_options;
|
|
11
12
|
constructor(options) {
|
|
@@ -30,7 +31,7 @@ export class PredictorSDKClient {
|
|
|
30
31
|
return core.HttpResponsePromise.fromPromise(this.__getSportsMatchingMarkets(request, requestOptions));
|
|
31
32
|
}
|
|
32
33
|
async __getSportsMatchingMarkets(request = {}, requestOptions) {
|
|
33
|
-
const {
|
|
34
|
+
const { kalshiEventTicker, polymarketMarketSlug, predictMarketId, sxbetMarketId } = request;
|
|
34
35
|
const _queryParams = {
|
|
35
36
|
kalshi_event_ticker: kalshiEventTicker,
|
|
36
37
|
polymarket_market_slug: polymarketMarketSlug,
|
|
@@ -53,20 +54,59 @@ export class PredictorSDKClient {
|
|
|
53
54
|
logging: this._options.logging,
|
|
54
55
|
});
|
|
55
56
|
if (_response.ok) {
|
|
56
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
data: serializers.SportsMatchingResponse.parseOrThrow(_response.body, {
|
|
59
|
+
unrecognizedObjectKeys: "passthrough",
|
|
60
|
+
allowUnrecognizedUnionMembers: true,
|
|
61
|
+
allowUnrecognizedEnumValues: true,
|
|
62
|
+
skipValidation: true,
|
|
63
|
+
breadcrumbsPrefix: ["response"],
|
|
64
|
+
}),
|
|
65
|
+
rawResponse: _response.rawResponse,
|
|
66
|
+
};
|
|
57
67
|
}
|
|
58
68
|
if (_response.error.reason === "status-code") {
|
|
59
69
|
switch (_response.error.statusCode) {
|
|
60
70
|
case 400:
|
|
61
|
-
throw new PredictorSDK.BadRequestError(_response.error.body,
|
|
71
|
+
throw new PredictorSDK.BadRequestError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
72
|
+
unrecognizedObjectKeys: "passthrough",
|
|
73
|
+
allowUnrecognizedUnionMembers: true,
|
|
74
|
+
allowUnrecognizedEnumValues: true,
|
|
75
|
+
skipValidation: true,
|
|
76
|
+
breadcrumbsPrefix: ["response"],
|
|
77
|
+
}), _response.rawResponse);
|
|
62
78
|
case 401:
|
|
63
|
-
throw new PredictorSDK.UnauthorizedError(_response.error.body,
|
|
79
|
+
throw new PredictorSDK.UnauthorizedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
80
|
+
unrecognizedObjectKeys: "passthrough",
|
|
81
|
+
allowUnrecognizedUnionMembers: true,
|
|
82
|
+
allowUnrecognizedEnumValues: true,
|
|
83
|
+
skipValidation: true,
|
|
84
|
+
breadcrumbsPrefix: ["response"],
|
|
85
|
+
}), _response.rawResponse);
|
|
64
86
|
case 403:
|
|
65
|
-
throw new PredictorSDK.ForbiddenError(_response.error.body,
|
|
87
|
+
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
88
|
+
unrecognizedObjectKeys: "passthrough",
|
|
89
|
+
allowUnrecognizedUnionMembers: true,
|
|
90
|
+
allowUnrecognizedEnumValues: true,
|
|
91
|
+
skipValidation: true,
|
|
92
|
+
breadcrumbsPrefix: ["response"],
|
|
93
|
+
}), _response.rawResponse);
|
|
66
94
|
case 429:
|
|
67
|
-
throw new PredictorSDK.TooManyRequestsError(_response.error.body,
|
|
95
|
+
throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
96
|
+
unrecognizedObjectKeys: "passthrough",
|
|
97
|
+
allowUnrecognizedUnionMembers: true,
|
|
98
|
+
allowUnrecognizedEnumValues: true,
|
|
99
|
+
skipValidation: true,
|
|
100
|
+
breadcrumbsPrefix: ["response"],
|
|
101
|
+
}), _response.rawResponse);
|
|
68
102
|
case 503:
|
|
69
|
-
throw new PredictorSDK.ServiceUnavailableError(_response.error.body,
|
|
103
|
+
throw new PredictorSDK.ServiceUnavailableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
104
|
+
unrecognizedObjectKeys: "passthrough",
|
|
105
|
+
allowUnrecognizedUnionMembers: true,
|
|
106
|
+
allowUnrecognizedEnumValues: true,
|
|
107
|
+
skipValidation: true,
|
|
108
|
+
breadcrumbsPrefix: ["response"],
|
|
109
|
+
}), _response.rawResponse);
|
|
70
110
|
default:
|
|
71
111
|
throw new errors.PredictorSDKError({
|
|
72
112
|
statusCode: _response.error.statusCode,
|
|
@@ -77,6 +117,123 @@ export class PredictorSDKClient {
|
|
|
77
117
|
}
|
|
78
118
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/matching-markets/sports");
|
|
79
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
|
+
}
|
|
80
237
|
/**
|
|
81
238
|
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
82
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
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export interface GetSportsMatchingMarketsRequest {
|
|
6
6
|
/** Kalshi event ticker(s) to find matching markets for (e.g. `KXNFLGAME-25AUG16ARIDEN`). Provide the parameter multiple times for multiple tickers. Only one filter type may be used per request. */
|
|
7
|
-
|
|
7
|
+
kalshiEventTicker?: string | string[];
|
|
8
8
|
/** Polymarket market slug(s) to find matching markets for (e.g. `nfl-ari-den-2025-08-16`). Provide the parameter multiple times for multiple slugs. Only one filter type may be used per request. */
|
|
9
|
-
|
|
9
|
+
polymarketMarketSlug?: string | string[];
|
|
10
10
|
/** Predict market ID(s) to find matching markets for (e.g. `110629`). Provide the parameter multiple times for multiple IDs. Only one filter type may be used per request. */
|
|
11
|
-
|
|
11
|
+
predictMarketId?: string | string[];
|
|
12
12
|
/** SX Bet market ID(s) to find matching markets for (e.g. `0x4c000abdbf197ef32ecdf15561b1d636f1e5b02629f466678757fd83e2ec3599`). Provide the parameter multiple times for multiple IDs. Only one filter type may be used per request. */
|
|
13
|
-
|
|
13
|
+
sxbetMarketId?: string | string[];
|
|
14
14
|
}
|
|
@@ -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
|
+
}
|
package/dist/api/errors/index.js
CHANGED
|
@@ -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,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
|
+
}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../index.js";
|
|
1
2
|
export interface PlatformMarket {
|
|
2
|
-
platform:
|
|
3
|
+
platform: PredictorSDK.PlatformMarketPlatform;
|
|
3
4
|
/** Kalshi event ticker. Present when platform is KALSHI. */
|
|
4
|
-
|
|
5
|
+
eventTicker?: string;
|
|
5
6
|
/** Kalshi market tickers. Present when platform is KALSHI. */
|
|
6
|
-
|
|
7
|
+
marketTickers?: string[];
|
|
7
8
|
/** Polymarket market slug. Present when platform is POLYMARKET. */
|
|
8
|
-
|
|
9
|
+
marketSlug?: string;
|
|
9
10
|
/** Polymarket token IDs. Present when platform is POLYMARKET. */
|
|
10
|
-
|
|
11
|
+
tokenIds?: string[];
|
|
11
12
|
/** Source market ID. Present for platforms other than Kalshi and Polymarket. */
|
|
12
|
-
|
|
13
|
+
marketId?: string;
|
|
13
14
|
/** Source outcome IDs. Present for platforms that use outcome IDs. */
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export declare namespace PlatformMarket {
|
|
17
|
-
const Platform: {
|
|
18
|
-
readonly Kalshi: "KALSHI";
|
|
19
|
-
readonly Polymarket: "POLYMARKET";
|
|
20
|
-
readonly Predict: "PREDICT";
|
|
21
|
-
readonly Sxbet: "SXBET";
|
|
22
|
-
};
|
|
23
|
-
type Platform = (typeof Platform)[keyof typeof Platform];
|
|
15
|
+
outcomeIds?: string[];
|
|
24
16
|
}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
export
|
|
3
|
-
(function (PlatformMarket) {
|
|
4
|
-
PlatformMarket.Platform = {
|
|
5
|
-
Kalshi: "KALSHI",
|
|
6
|
-
Polymarket: "POLYMARKET",
|
|
7
|
-
Predict: "PREDICT",
|
|
8
|
-
Sxbet: "SXBET",
|
|
9
|
-
};
|
|
10
|
-
})(PlatformMarket || (PlatformMarket = {}));
|
|
2
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PlatformMarketPlatform: {
|
|
2
|
+
readonly Kalshi: "KALSHI";
|
|
3
|
+
readonly Polymarket: "POLYMARKET";
|
|
4
|
+
readonly Predict: "PREDICT";
|
|
5
|
+
readonly Sxbet: "SXBET";
|
|
6
|
+
};
|
|
7
|
+
export type PlatformMarketPlatform = (typeof PlatformMarketPlatform)[keyof typeof PlatformMarketPlatform];
|
package/dist/api/types/index.js
CHANGED
|
@@ -5,7 +5,12 @@ export const BasicAuth = {
|
|
|
5
5
|
if (basicAuth == null) {
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
8
|
-
const
|
|
8
|
+
const username = basicAuth.username ?? "";
|
|
9
|
+
const password = basicAuth.password ?? "";
|
|
10
|
+
if (username === "" && password === "") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const token = base64Encode(`${username}:${password}`);
|
|
9
14
|
return `Basic ${token}`;
|
|
10
15
|
},
|
|
11
16
|
fromAuthorizationHeader: (header) => {
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { SchemaUtils } from "./builders/index.js";
|
|
2
|
+
export type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
3
|
+
export type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
|
|
4
|
+
export type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
|
|
5
|
+
export interface BaseSchema<Raw, Parsed> {
|
|
6
|
+
parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid<Parsed>;
|
|
7
|
+
json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid<Raw>;
|
|
8
|
+
getType: () => SchemaType | SchemaType;
|
|
9
|
+
}
|
|
10
|
+
export declare const SchemaType: {
|
|
11
|
+
readonly BIGINT: "bigint";
|
|
12
|
+
readonly DATE: "date";
|
|
13
|
+
readonly ENUM: "enum";
|
|
14
|
+
readonly LIST: "list";
|
|
15
|
+
readonly STRING_LITERAL: "stringLiteral";
|
|
16
|
+
readonly BOOLEAN_LITERAL: "booleanLiteral";
|
|
17
|
+
readonly OBJECT: "object";
|
|
18
|
+
readonly ANY: "any";
|
|
19
|
+
readonly BOOLEAN: "boolean";
|
|
20
|
+
readonly NUMBER: "number";
|
|
21
|
+
readonly STRING: "string";
|
|
22
|
+
readonly UNKNOWN: "unknown";
|
|
23
|
+
readonly NEVER: "never";
|
|
24
|
+
readonly RECORD: "record";
|
|
25
|
+
readonly SET: "set";
|
|
26
|
+
readonly UNION: "union";
|
|
27
|
+
readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion";
|
|
28
|
+
readonly NULLABLE: "nullable";
|
|
29
|
+
readonly OPTIONAL: "optional";
|
|
30
|
+
readonly OPTIONAL_NULLABLE: "optionalNullable";
|
|
31
|
+
};
|
|
32
|
+
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
33
|
+
export type MaybeValid<T> = Valid<T> | Invalid;
|
|
34
|
+
export interface Valid<T> {
|
|
35
|
+
ok: true;
|
|
36
|
+
value: T;
|
|
37
|
+
}
|
|
38
|
+
export interface Invalid {
|
|
39
|
+
ok: false;
|
|
40
|
+
errors: ValidationError[];
|
|
41
|
+
}
|
|
42
|
+
export interface ValidationError {
|
|
43
|
+
path: string[];
|
|
44
|
+
message: string;
|
|
45
|
+
}
|
|
46
|
+
export interface SchemaOptions {
|
|
47
|
+
/**
|
|
48
|
+
* how to handle unrecognized keys in objects
|
|
49
|
+
*
|
|
50
|
+
* @default "fail"
|
|
51
|
+
*/
|
|
52
|
+
unrecognizedObjectKeys?: "fail" | "passthrough" | "strip";
|
|
53
|
+
/**
|
|
54
|
+
* whether to fail when an unrecognized discriminant value is
|
|
55
|
+
* encountered in a union
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
allowUnrecognizedUnionMembers?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* whether to fail when an unrecognized enum value is encountered
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
allowUnrecognizedEnumValues?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* whether to allow data that doesn't conform to the schema.
|
|
68
|
+
* invalid data is passed through without transformation.
|
|
69
|
+
*
|
|
70
|
+
* when this is enabled, .parse() and .json() will always
|
|
71
|
+
* return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()`
|
|
72
|
+
* will never fail.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
skipValidation?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* each validation failure contains a "path" property, which is
|
|
79
|
+
* the breadcrumbs to the offending node in the JSON. you can supply
|
|
80
|
+
* a prefix that is prepended to all the errors' paths. this can be
|
|
81
|
+
* helpful for zurg's internal debug logging.
|
|
82
|
+
*/
|
|
83
|
+
breadcrumbsPrefix?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* whether to send 'null' for optional properties explicitly set to 'undefined'.
|
|
86
|
+
*/
|
|
87
|
+
omitUndefined?: boolean;
|
|
88
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const SchemaType = {
|
|
2
|
+
BIGINT: "bigint",
|
|
3
|
+
DATE: "date",
|
|
4
|
+
ENUM: "enum",
|
|
5
|
+
LIST: "list",
|
|
6
|
+
STRING_LITERAL: "stringLiteral",
|
|
7
|
+
BOOLEAN_LITERAL: "booleanLiteral",
|
|
8
|
+
OBJECT: "object",
|
|
9
|
+
ANY: "any",
|
|
10
|
+
BOOLEAN: "boolean",
|
|
11
|
+
NUMBER: "number",
|
|
12
|
+
STRING: "string",
|
|
13
|
+
UNKNOWN: "unknown",
|
|
14
|
+
NEVER: "never",
|
|
15
|
+
RECORD: "record",
|
|
16
|
+
SET: "set",
|
|
17
|
+
UNION: "union",
|
|
18
|
+
UNDISCRIMINATED_UNION: "undiscriminatedUnion",
|
|
19
|
+
NULLABLE: "nullable",
|
|
20
|
+
OPTIONAL: "optional",
|
|
21
|
+
OPTIONAL_NULLABLE: "optionalNullable",
|
|
22
|
+
};
|