@skinpricer/sdk 0.1.0 → 0.3.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/CHANGELOG.md +17 -0
- package/README.md +10 -0
- package/dist/index.cjs +156 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +224 -8
- package/dist/index.d.ts +224 -8
- package/dist/index.js +150 -8
- package/dist/index.js.map +1 -1
- package/package.json +19 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @skinpricer/sdk
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e114c14: Add liquidity and market-health resources, market-hash-name aggregation lookups, and sync the integrated-market list.
|
|
8
|
+
|
|
9
|
+
- New `liquidity` resource: `client.liquidity.get()`, `.summary()`, `.batch()`, `.bulk()`, and `.manifest()` for cross-market liquidity and expected time-to-sell. Exports `LiquidityResponse`, `LiquiditySummaryResponse`, `LiquidityBatchResponse`, `LiquidityBulkResponse`, `LiquidityBulkManifest`, `LiquidityBulkItem`, `LiquidityMarketMetric`, `LiquidityParams`, `LiquidityBatchBody`, plus the `LIQUIDITY_BADGES`, `LIQUIDITY_CONFIDENCE`, `LIQUIDITY_LABELS`, and `SUPPORTED_LIQUIDITY_MARKETS` constants.
|
|
10
|
+
- New `markets` resource: `client.markets.health()` returns per-market integration status as `MarketHealthRow[]`. It targets the public API host via the new `publicBaseUrl` config (derived from `baseUrl` by default), exported as `DEFAULT_PUBLIC_BASE_URL`.
|
|
11
|
+
- `aggregations.minPrices()` and `aggregations.maxOrders()` now accept `marketHashNames` as an alternative to `ids`.
|
|
12
|
+
- `KNOWN_MARKETS` now lists all 18 integrated markets (adds `avanmarket` and `csdeals`).
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 37a3bb0: Add `executionAdjusted` to the NBBO response (`client.nbbo.get()`): fee- and executability-adjusted best bid/ask (`price`, `rawPrice`, `appliedFeeBps`, `withdrawalFlatUsdCents`, `executability`, `reasons`) plus `spreadBps`, `locked`, `crossed`, `executableConfidence`, `reasons`, and `feeModelVersion`. Adds exported types `ExecutionAdjustedNbbo` and `ExecutionAdjustedBestPrice`.
|
|
19
|
+
|
|
3
20
|
## 0.1.0
|
|
4
21
|
|
|
5
22
|
Initial release.
|
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ const client = new SkinpricerClient({
|
|
|
68
68
|
| `client.marketAnalytics` | `get` |
|
|
69
69
|
| `client.attributePrices` | `latest`, `history` |
|
|
70
70
|
| `client.buff163` | `latest`, `history` |
|
|
71
|
+
| `client.liquidity` | `get`, `summary`, `batch`, `bulk`, `manifest` |
|
|
72
|
+
| `client.markets` | `health` |
|
|
71
73
|
|
|
72
74
|
Every method accepts an optional trailing `RequestOptions` (`{ signal, timeoutMs, retry }`).
|
|
73
75
|
|
|
@@ -152,6 +154,14 @@ const { items } = await client.aggregations.minPricesAll(thousandsOfIds, {
|
|
|
152
154
|
});
|
|
153
155
|
```
|
|
154
156
|
|
|
157
|
+
`minPrices` / `maxOrders` also accept `marketHashNames` instead of `ids` (provide either one):
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
await client.aggregations.minPrices({
|
|
161
|
+
marketHashNames: ["AK-47 | Redline (Field-Tested)"],
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
155
165
|
**Proactive rate-limit throttling** (opt-in) — when a response reports `X-RateLimit-Remaining: 0`, the client waits for the window to reset instead of firing a request that is guaranteed to 429:
|
|
156
166
|
|
|
157
167
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -36,11 +36,23 @@ var ParseError = class extends SkinpricerError {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// src/version.ts
|
|
39
|
-
var VERSION = "0.
|
|
39
|
+
var VERSION = "0.3.0";
|
|
40
40
|
|
|
41
41
|
// src/config.ts
|
|
42
42
|
var DEFAULT_BASE_URL = "https://pricing.skinpricer.com/v1";
|
|
43
|
+
var DEFAULT_PUBLIC_BASE_URL = "https://api.skinpricer.com/v1";
|
|
43
44
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
45
|
+
function derivePublicBaseUrl(baseUrl) {
|
|
46
|
+
try {
|
|
47
|
+
const parsed = new URL(baseUrl);
|
|
48
|
+
if (parsed.hostname.startsWith("pricing.")) {
|
|
49
|
+
parsed.hostname = `api.${parsed.hostname.slice("pricing.".length)}`;
|
|
50
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
return DEFAULT_PUBLIC_BASE_URL;
|
|
55
|
+
}
|
|
44
56
|
var DEFAULT_RETRY = {
|
|
45
57
|
maxRetries: 2,
|
|
46
58
|
baseDelayMs: 250,
|
|
@@ -86,9 +98,13 @@ function resolveConfig(config) {
|
|
|
86
98
|
"A non-empty `apiKey` is required to construct SkinpricerClient."
|
|
87
99
|
);
|
|
88
100
|
}
|
|
101
|
+
const baseUrl = normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL);
|
|
89
102
|
return {
|
|
90
103
|
apiKey: config.apiKey,
|
|
91
|
-
baseUrl
|
|
104
|
+
baseUrl,
|
|
105
|
+
publicBaseUrl: normalizeBaseUrl(
|
|
106
|
+
config.publicBaseUrl ?? derivePublicBaseUrl(baseUrl)
|
|
107
|
+
),
|
|
92
108
|
fetch: resolveFetch(config.fetch),
|
|
93
109
|
timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
94
110
|
retry: resolveRetry(config.retry),
|
|
@@ -344,7 +360,7 @@ function serializeQuery(params) {
|
|
|
344
360
|
// src/http/request-builder.ts
|
|
345
361
|
function buildRequest(config, input) {
|
|
346
362
|
const queryString = input.query ? serializeQuery(input.query) : "";
|
|
347
|
-
const url = joinUrl(config.baseUrl, input.path) + queryString;
|
|
363
|
+
const url = joinUrl(input.baseUrl ?? config.baseUrl, input.path) + queryString;
|
|
348
364
|
const headers = {
|
|
349
365
|
Accept: "application/json",
|
|
350
366
|
"User-Agent": config.userAgent,
|
|
@@ -439,6 +455,10 @@ var HttpClient = class {
|
|
|
439
455
|
}
|
|
440
456
|
config;
|
|
441
457
|
throttleUntil = 0;
|
|
458
|
+
/** Base URL for keyless public-service endpoints (see {@link ResolvedConfig.publicBaseUrl}). */
|
|
459
|
+
get publicBaseUrl() {
|
|
460
|
+
return this.config.publicBaseUrl;
|
|
461
|
+
}
|
|
442
462
|
async request(input, options = {}) {
|
|
443
463
|
const prepared = buildRequest(this.config, input);
|
|
444
464
|
const retry = resolveRequestRetry(this.config.retry, options.retry);
|
|
@@ -610,24 +630,32 @@ var BaseResource = class {
|
|
|
610
630
|
var MAX_IDS_PER_REQUEST = 100;
|
|
611
631
|
var DEFAULT_BATCH_CONCURRENCY = 5;
|
|
612
632
|
var AggregationsResource = class extends BaseResource {
|
|
613
|
-
/** GET /v1/aggregations/min-prices — minimum sell price per market
|
|
633
|
+
/** GET /v1/aggregations/min-prices — minimum sell price per market. Pass up to 100 `ids` or `marketHashNames`. */
|
|
614
634
|
minPrices(params, options) {
|
|
615
635
|
return this.call(
|
|
616
636
|
{
|
|
617
637
|
method: "GET",
|
|
618
638
|
path: "/aggregations/min-prices",
|
|
619
|
-
query: {
|
|
639
|
+
query: {
|
|
640
|
+
ids: params.ids,
|
|
641
|
+
marketHashNames: params.marketHashNames,
|
|
642
|
+
markets: params.markets
|
|
643
|
+
}
|
|
620
644
|
},
|
|
621
645
|
options
|
|
622
646
|
);
|
|
623
647
|
}
|
|
624
|
-
/** GET /v1/aggregations/max-orders — maximum buy order per market
|
|
648
|
+
/** GET /v1/aggregations/max-orders — maximum buy order per market. Pass up to 100 `ids` or `marketHashNames`. */
|
|
625
649
|
maxOrders(params, options) {
|
|
626
650
|
return this.call(
|
|
627
651
|
{
|
|
628
652
|
method: "GET",
|
|
629
653
|
path: "/aggregations/max-orders",
|
|
630
|
-
query: {
|
|
654
|
+
query: {
|
|
655
|
+
ids: params.ids,
|
|
656
|
+
marketHashNames: params.marketHashNames,
|
|
657
|
+
markets: params.markets
|
|
658
|
+
}
|
|
631
659
|
},
|
|
632
660
|
options
|
|
633
661
|
);
|
|
@@ -876,6 +904,65 @@ var ItemsResource = class extends BaseResource {
|
|
|
876
904
|
}
|
|
877
905
|
};
|
|
878
906
|
|
|
907
|
+
// src/resources/liquidity.ts
|
|
908
|
+
var LiquidityResource = class extends BaseResource {
|
|
909
|
+
/** `GET /v1/liquidity/:marketHashName` — full liquidity model for one item. */
|
|
910
|
+
get(marketHashName, params = {}, options) {
|
|
911
|
+
return this.call(
|
|
912
|
+
{
|
|
913
|
+
method: "GET",
|
|
914
|
+
path: `/liquidity/${encodePathSegment(marketHashName)}`,
|
|
915
|
+
query: { askPrice: params.askPrice, market: params.market }
|
|
916
|
+
},
|
|
917
|
+
options
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
/** `GET /v1/liquidity/summary/:marketHashName` — slim badge-only projection. */
|
|
921
|
+
summary(marketHashName, params = {}, options) {
|
|
922
|
+
return this.call(
|
|
923
|
+
{
|
|
924
|
+
method: "GET",
|
|
925
|
+
path: `/liquidity/summary/${encodePathSegment(marketHashName)}`,
|
|
926
|
+
query: { askPrice: params.askPrice, market: params.market }
|
|
927
|
+
},
|
|
928
|
+
options
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
/** `POST /v1/liquidity/batch` — score up to 100 items in one call. */
|
|
932
|
+
batch(body, options) {
|
|
933
|
+
return this.call(
|
|
934
|
+
{
|
|
935
|
+
method: "POST",
|
|
936
|
+
path: "/liquidity/batch",
|
|
937
|
+
body: { marketHashNames: body.marketHashNames, market: body.market }
|
|
938
|
+
},
|
|
939
|
+
options
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* `GET /v1/liquidity/items` — Enterprise: the whole-catalog liquidity map,
|
|
944
|
+
* rematerialized every ~10 minutes. Poll {@link manifest} and compare
|
|
945
|
+
* `version` before refetching this heavier payload.
|
|
946
|
+
*/
|
|
947
|
+
bulk(options) {
|
|
948
|
+
return this.call(
|
|
949
|
+
{ method: "GET", path: "/liquidity/items" },
|
|
950
|
+
options
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* `GET /v1/liquidity/items/manifest` — Enterprise: a cheap change-probe for
|
|
955
|
+
* the {@link bulk} map (`version`, `calculatedAt`, `cadence`, `markets`,
|
|
956
|
+
* `itemCount`). Refetch the bulk map only when `version` changes.
|
|
957
|
+
*/
|
|
958
|
+
manifest(options) {
|
|
959
|
+
return this.call(
|
|
960
|
+
{ method: "GET", path: "/liquidity/items/manifest" },
|
|
961
|
+
options
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
|
|
879
966
|
// src/resources/market-analytics.ts
|
|
880
967
|
var MarketAnalyticsResource = class extends BaseResource {
|
|
881
968
|
/** `GET /v1/market-analytics/:marketHashName` — per-market analytics rows. */
|
|
@@ -891,6 +978,22 @@ var MarketAnalyticsResource = class extends BaseResource {
|
|
|
891
978
|
}
|
|
892
979
|
};
|
|
893
980
|
|
|
981
|
+
// src/resources/markets.ts
|
|
982
|
+
var MarketsResource = class extends BaseResource {
|
|
983
|
+
/**
|
|
984
|
+
* `GET /v1/markets/health` — per-market ingest status, last event time, and
|
|
985
|
+
* listing counts for every integrated market. Returns a plain array of
|
|
986
|
+
* {@link import("../types/markets").MarketHealthRow}.
|
|
987
|
+
*/
|
|
988
|
+
health(options) {
|
|
989
|
+
return this.call(
|
|
990
|
+
// Keyless: served by the public `api.` host, not the pricing base.
|
|
991
|
+
{ method: "GET", path: "/markets/health", baseUrl: this.http.publicBaseUrl },
|
|
992
|
+
options
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
|
|
894
997
|
// src/resources/nbbo.ts
|
|
895
998
|
var NbboResource = class extends BaseResource {
|
|
896
999
|
/** `GET /v1/nbbo` — best bid/ask across markets. Pass `id` or `marketHashName`. */
|
|
@@ -998,6 +1101,8 @@ var SkinpricerClient = class {
|
|
|
998
1101
|
marketAnalytics;
|
|
999
1102
|
attributePrices;
|
|
1000
1103
|
buff163;
|
|
1104
|
+
liquidity;
|
|
1105
|
+
markets;
|
|
1001
1106
|
httpClient;
|
|
1002
1107
|
constructor(config) {
|
|
1003
1108
|
this.httpClient = new HttpClient(resolveConfig(config));
|
|
@@ -1012,6 +1117,8 @@ var SkinpricerClient = class {
|
|
|
1012
1117
|
this.marketAnalytics = new MarketAnalyticsResource(this.httpClient);
|
|
1013
1118
|
this.attributePrices = new AttributePricesResource(this.httpClient);
|
|
1014
1119
|
this.buff163 = new Buff163Resource(this.httpClient);
|
|
1120
|
+
this.liquidity = new LiquidityResource(this.httpClient);
|
|
1121
|
+
this.markets = new MarketsResource(this.httpClient);
|
|
1015
1122
|
}
|
|
1016
1123
|
};
|
|
1017
1124
|
|
|
@@ -1021,6 +1128,7 @@ var KNOWN_MARKETS = [
|
|
|
1021
1128
|
"skindeck",
|
|
1022
1129
|
"buff163",
|
|
1023
1130
|
"csfloat",
|
|
1131
|
+
"csdeals",
|
|
1024
1132
|
"marketcsgo",
|
|
1025
1133
|
"cstrade",
|
|
1026
1134
|
"dmarket",
|
|
@@ -1030,6 +1138,7 @@ var KNOWN_MARKETS = [
|
|
|
1030
1138
|
"whitemarket",
|
|
1031
1139
|
"waxpeer",
|
|
1032
1140
|
"lootfarm",
|
|
1141
|
+
"avanmarket",
|
|
1033
1142
|
"tradeit-store",
|
|
1034
1143
|
"tradeit-trade",
|
|
1035
1144
|
"steamcommunity"
|
|
@@ -1042,6 +1151,39 @@ var ATTRIBUTE_MARKETS = [
|
|
|
1042
1151
|
"dmarket"
|
|
1043
1152
|
];
|
|
1044
1153
|
|
|
1154
|
+
// src/types/liquidity.ts
|
|
1155
|
+
var LIQUIDITY_BADGES = [
|
|
1156
|
+
"EXTREMELY_LIQUID",
|
|
1157
|
+
"VERY_LIQUID",
|
|
1158
|
+
"LIQUID",
|
|
1159
|
+
"ILLIQUID",
|
|
1160
|
+
"VERY_ILLIQUID",
|
|
1161
|
+
"EXTREMELY_ILLIQUID",
|
|
1162
|
+
"UNTRADED"
|
|
1163
|
+
];
|
|
1164
|
+
var LIQUIDITY_CONFIDENCE = [
|
|
1165
|
+
"HIGH",
|
|
1166
|
+
"MEDIUM",
|
|
1167
|
+
"LOW",
|
|
1168
|
+
"CRITICAL"
|
|
1169
|
+
];
|
|
1170
|
+
var LIQUIDITY_LABELS = [
|
|
1171
|
+
"extremely_liquid",
|
|
1172
|
+
"very_liquid",
|
|
1173
|
+
"liquid",
|
|
1174
|
+
"illiquid",
|
|
1175
|
+
"very_illiquid",
|
|
1176
|
+
"extremely_illiquid",
|
|
1177
|
+
"unknown"
|
|
1178
|
+
];
|
|
1179
|
+
var SUPPORTED_LIQUIDITY_MARKETS = [
|
|
1180
|
+
"skinport",
|
|
1181
|
+
"marketcsgo",
|
|
1182
|
+
"dmarket",
|
|
1183
|
+
"csdeals",
|
|
1184
|
+
"csfloat"
|
|
1185
|
+
];
|
|
1186
|
+
|
|
1045
1187
|
// src/utils/money.ts
|
|
1046
1188
|
function centsToUsd(cents) {
|
|
1047
1189
|
return cents / 100;
|
|
@@ -1068,13 +1210,19 @@ exports.BaseResource = BaseResource;
|
|
|
1068
1210
|
exports.Buff163Resource = Buff163Resource;
|
|
1069
1211
|
exports.ConfigurationError = ConfigurationError;
|
|
1070
1212
|
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
|
|
1213
|
+
exports.DEFAULT_PUBLIC_BASE_URL = DEFAULT_PUBLIC_BASE_URL;
|
|
1071
1214
|
exports.DEFAULT_RETRY = DEFAULT_RETRY;
|
|
1072
1215
|
exports.DEFAULT_TIMEOUT_MS = DEFAULT_TIMEOUT_MS;
|
|
1073
1216
|
exports.FeatureNotAvailableError = FeatureNotAvailableError;
|
|
1074
1217
|
exports.HistoryResource = HistoryResource;
|
|
1075
1218
|
exports.ItemsResource = ItemsResource;
|
|
1076
1219
|
exports.KNOWN_MARKETS = KNOWN_MARKETS;
|
|
1220
|
+
exports.LIQUIDITY_BADGES = LIQUIDITY_BADGES;
|
|
1221
|
+
exports.LIQUIDITY_CONFIDENCE = LIQUIDITY_CONFIDENCE;
|
|
1222
|
+
exports.LIQUIDITY_LABELS = LIQUIDITY_LABELS;
|
|
1223
|
+
exports.LiquidityResource = LiquidityResource;
|
|
1077
1224
|
exports.MarketAnalyticsResource = MarketAnalyticsResource;
|
|
1225
|
+
exports.MarketsResource = MarketsResource;
|
|
1078
1226
|
exports.NbboResource = NbboResource;
|
|
1079
1227
|
exports.NetworkError = NetworkError;
|
|
1080
1228
|
exports.NotFoundError = NotFoundError;
|
|
@@ -1084,6 +1232,7 @@ exports.PricingResource = PricingResource;
|
|
|
1084
1232
|
exports.RESPONSE_META = RESPONSE_META;
|
|
1085
1233
|
exports.RateLimitError = RateLimitError;
|
|
1086
1234
|
exports.RecommendationsResource = RecommendationsResource;
|
|
1235
|
+
exports.SUPPORTED_LIQUIDITY_MARKETS = SUPPORTED_LIQUIDITY_MARKETS;
|
|
1087
1236
|
exports.ServerError = ServerError;
|
|
1088
1237
|
exports.SkinpricerClient = SkinpricerClient;
|
|
1089
1238
|
exports.SkinpricerError = SkinpricerError;
|