@skinpricer/sdk 0.2.0 → 0.4.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/index.cjs CHANGED
@@ -35,12 +35,383 @@ var ConfigurationError = class extends SkinpricerError {
35
35
  var ParseError = class extends SkinpricerError {
36
36
  };
37
37
 
38
+ // src/utils/url.ts
39
+ function encodePathSegment(segment) {
40
+ return encodeURIComponent(segment);
41
+ }
42
+ function joinUrl(baseUrl, path) {
43
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
44
+ return `${baseUrl}${normalizedPath}`;
45
+ }
46
+
47
+ // src/meta.ts
48
+ var RESPONSE_META = /* @__PURE__ */ Symbol("skinpricer.responseMeta");
49
+ function attachMeta(data, meta) {
50
+ if (data !== null && typeof data === "object") {
51
+ Object.defineProperty(data, RESPONSE_META, {
52
+ value: meta,
53
+ enumerable: false,
54
+ writable: false,
55
+ configurable: true
56
+ });
57
+ }
58
+ return data;
59
+ }
60
+ function getMeta(value) {
61
+ if (value !== null && typeof value === "object") {
62
+ return value[RESPONSE_META];
63
+ }
64
+ return void 0;
65
+ }
66
+
67
+ // src/resources/resource.ts
68
+ function assertPathSegments(path) {
69
+ const segments = path.split("/").slice(1);
70
+ if (segments.some(
71
+ (segment) => segment === "" || segment === "." || segment === ".."
72
+ )) {
73
+ throw new ConfigurationError(
74
+ `Path segments cannot be empty, "." or "..": "${path}"`
75
+ );
76
+ }
77
+ }
78
+ var BaseResource = class {
79
+ constructor(http, game) {
80
+ this.http = http;
81
+ this.game = game;
82
+ }
83
+ http;
84
+ game;
85
+ /** Performs a request and returns the data with {@link ResponseMeta} attached. */
86
+ async call(input, options) {
87
+ assertPathSegments(input.path);
88
+ const scoped = this.game === void 0 ? input : {
89
+ ...input,
90
+ baseUrl: this.http.versionedBaseUrl("v2", input.baseUrl),
91
+ query: { ...input.query, game: this.game }
92
+ };
93
+ const { data, meta } = await this.http.request(scoped, options);
94
+ return attachMeta(data, meta);
95
+ }
96
+ };
97
+
98
+ // src/resources/history.ts
99
+ function historyQuery(params) {
100
+ return {
101
+ from: params.from,
102
+ to: params.to,
103
+ markets: params.markets,
104
+ listingType: params.listingType,
105
+ salesWindow: params.salesWindow,
106
+ interval: params.interval
107
+ };
108
+ }
109
+ var HistoryResource = class extends BaseResource {
110
+ /** `GET /v1/pricing/:marketHashName/history` — aggregated time series. */
111
+ get(marketHashName, params = {}, options) {
112
+ return this.call(
113
+ {
114
+ method: "GET",
115
+ path: `/pricing/${encodePathSegment(marketHashName)}/history`,
116
+ query: historyQuery(params)
117
+ },
118
+ options
119
+ );
120
+ }
121
+ /** `GET /v1/pricing/:marketHashName/history/markets` — per-market series. */
122
+ byMarket(marketHashName, params = {}, options) {
123
+ return this.call(
124
+ {
125
+ method: "GET",
126
+ path: `/pricing/${encodePathSegment(marketHashName)}/history/markets`,
127
+ query: historyQuery(params)
128
+ },
129
+ options
130
+ );
131
+ }
132
+ };
133
+
134
+ // src/resources/items.ts
135
+ var ItemSearchResource = class extends BaseResource {
136
+ /** GET /v1/items — paginated item search with current pricing. */
137
+ search(params = {}, options) {
138
+ return this.call(
139
+ {
140
+ method: "GET",
141
+ path: "/items",
142
+ query: {
143
+ search: params.search,
144
+ markets: params.markets,
145
+ page: params.page,
146
+ perPage: params.perPage
147
+ }
148
+ },
149
+ options
150
+ );
151
+ }
152
+ /** Async iterator over every matching item, walking pages. */
153
+ async *searchEach(params = {}, options) {
154
+ let page = params.page ?? 1;
155
+ for (; ; ) {
156
+ const res = await this.search({ ...params, page }, options);
157
+ for (const item of res.data) {
158
+ yield item;
159
+ }
160
+ const next = res.pagination.nextPage;
161
+ if (next === null || next <= page) return;
162
+ page = next;
163
+ }
164
+ }
165
+ };
166
+ var ItemsResource = class extends ItemSearchResource {
167
+ /** GET /v1/items/all — every tracked item with latest prices (capped, unpaginated). */
168
+ all(options) {
169
+ return this.call(
170
+ { method: "GET", path: "/items/all" },
171
+ options
172
+ );
173
+ }
174
+ };
175
+
176
+ // src/resources/liquidity.ts
177
+ var ItemLiquidityResource = class extends BaseResource {
178
+ /** `GET /v1/liquidity/:marketHashName` — full liquidity model for one item. */
179
+ get(marketHashName, params = {}, options) {
180
+ return this.call(
181
+ {
182
+ method: "GET",
183
+ path: `/liquidity/${encodePathSegment(marketHashName)}`,
184
+ query: { askPrice: params.askPrice, market: params.market }
185
+ },
186
+ options
187
+ );
188
+ }
189
+ /** `GET /v1/liquidity/summary/:marketHashName` — slim badge-only projection. */
190
+ summary(marketHashName, params = {}, options) {
191
+ return this.call(
192
+ {
193
+ method: "GET",
194
+ path: `/liquidity/summary/${encodePathSegment(marketHashName)}`,
195
+ query: { askPrice: params.askPrice, market: params.market }
196
+ },
197
+ options
198
+ );
199
+ }
200
+ /** `POST /v1/liquidity/batch` — score up to 100 items in one call. */
201
+ batch(body, options) {
202
+ return this.call(
203
+ {
204
+ method: "POST",
205
+ path: "/liquidity/batch",
206
+ body: { marketHashNames: body.marketHashNames, market: body.market }
207
+ },
208
+ options
209
+ );
210
+ }
211
+ };
212
+ var LiquidityResource = class extends ItemLiquidityResource {
213
+ /** `GET /v1/liquidity/:marketHashName`. `"items"` is reserved for {@link bulk}. */
214
+ get(marketHashName, params = {}, options) {
215
+ if (marketHashName === "items") {
216
+ return Promise.reject(
217
+ new ConfigurationError(
218
+ '"items" is not an item name. Use `bulk()` for the whole-catalog map.'
219
+ )
220
+ );
221
+ }
222
+ return super.get(marketHashName, params, options);
223
+ }
224
+ bulk(params = {}, options) {
225
+ return this.call(
226
+ {
227
+ method: "GET",
228
+ path: "/liquidity/items",
229
+ ifNoneMatch: params.ifNoneMatch
230
+ },
231
+ options
232
+ );
233
+ }
234
+ manifest(params = {}, options) {
235
+ return this.call(
236
+ {
237
+ method: "GET",
238
+ path: "/liquidity/items/manifest",
239
+ ifNoneMatch: params.ifNoneMatch
240
+ },
241
+ options
242
+ );
243
+ }
244
+ };
245
+
246
+ // src/resources/markets.ts
247
+ var MarketsResource = class extends BaseResource {
248
+ /**
249
+ * `GET /v1/markets/health` — per-market ingest status, last event time, and
250
+ * listing counts for every integrated market. Returns a plain array of
251
+ * {@link import("../types/markets").MarketHealthRow}.
252
+ */
253
+ health(options) {
254
+ return this.call(
255
+ // Keyless: served by the public `api.` host, not the pricing base.
256
+ {
257
+ method: "GET",
258
+ authenticated: false,
259
+ path: "/markets/health",
260
+ baseUrl: this.http.publicBaseUrl
261
+ },
262
+ options
263
+ );
264
+ }
265
+ };
266
+
267
+ // src/resources/nbbo.ts
268
+ var NbboResource = class extends BaseResource {
269
+ /** `GET /v1/nbbo` — best bid/ask across markets. Pass `id` or `marketHashName`. */
270
+ get(params, options) {
271
+ return this.call(
272
+ {
273
+ method: "GET",
274
+ path: "/nbbo",
275
+ query: {
276
+ id: params.id,
277
+ market_hash_name: params.marketHashName,
278
+ markets: params.markets
279
+ }
280
+ },
281
+ options
282
+ );
283
+ }
284
+ /** `GET /v1/nbbo/depth` — aggregated order-book depth per side. */
285
+ depth(params, options) {
286
+ return this.call(
287
+ {
288
+ method: "GET",
289
+ path: "/nbbo/depth",
290
+ query: {
291
+ id: params.id,
292
+ market_hash_name: params.marketHashName,
293
+ markets: params.markets,
294
+ depth: params.depth
295
+ }
296
+ },
297
+ options
298
+ );
299
+ }
300
+ };
301
+
302
+ // src/resources/pricing.ts
303
+ var PricingResource = class extends BaseResource {
304
+ /** `GET /v1/pricing/:marketHashName` — full cross-market pricing snapshot. */
305
+ get(marketHashName, params = {}, options) {
306
+ return this.call(
307
+ {
308
+ method: "GET",
309
+ path: `/pricing/${encodePathSegment(marketHashName)}`,
310
+ query: { markets: params.markets }
311
+ },
312
+ options
313
+ );
314
+ }
315
+ /** `GET /v1/pricing/:marketHashName/listings` — individual listing samples. */
316
+ listings(marketHashName, params = {}, options) {
317
+ return this.call(
318
+ {
319
+ method: "GET",
320
+ path: `/pricing/${encodePathSegment(marketHashName)}/listings`,
321
+ query: { limit: params.limit, markets: params.markets }
322
+ },
323
+ options
324
+ );
325
+ }
326
+ };
327
+
328
+ // src/resources/schema.ts
329
+ var SchemaResource = class extends BaseResource {
330
+ /** Full catalog snapshot. A matching conditional ETag returns null. */
331
+ snapshot(params = {}, options) {
332
+ return this.call(
333
+ { method: "GET", path: "/schema", ifNoneMatch: params.ifNoneMatch },
334
+ options
335
+ );
336
+ }
337
+ /** Look up one item by canonical id or exact name; v2 also accepts its game-scoped slug. */
338
+ get(idOrName, options) {
339
+ return this.call(
340
+ { method: "GET", path: `/schema/items/${encodePathSegment(idOrName)}` },
341
+ options
342
+ );
343
+ }
344
+ /** One page of items changed after a catalog version or timestamp. */
345
+ changes(params, options) {
346
+ return this.call(
347
+ {
348
+ method: "GET",
349
+ path: "/schema/changes",
350
+ query: {
351
+ since: params.since,
352
+ cursor: params.cursor,
353
+ limit: params.limit
354
+ }
355
+ },
356
+ options
357
+ );
358
+ }
359
+ /** Iterate changes without moving the original version boundary while paging. */
360
+ async *changesEach(params, options) {
361
+ let cursor = params.cursor;
362
+ for (; ; ) {
363
+ const response = await this.changes({ ...params, cursor }, options);
364
+ for (const item of response.items) yield item;
365
+ const next = response.nextCursor;
366
+ if (!response.hasMore || next === null || next === cursor) return;
367
+ cursor = next;
368
+ }
369
+ }
370
+ };
371
+
372
+ // src/game-client.ts
373
+ var GameClient = class {
374
+ constructor(http, game) {
375
+ this.game = game;
376
+ if (game !== "cs2" && game !== "rust") {
377
+ throw new ConfigurationError('The game must be "cs2" or "rust".');
378
+ }
379
+ this.pricing = new PricingResource(http, game);
380
+ this.history = new HistoryResource(http, game);
381
+ this.items = new ItemSearchResource(http, game);
382
+ this.nbbo = new NbboResource(http, game);
383
+ this.liquidity = new ItemLiquidityResource(http, game);
384
+ this.schema = new SchemaResource(http, game);
385
+ this.markets = new MarketsResource(http, game);
386
+ }
387
+ game;
388
+ pricing;
389
+ history;
390
+ items;
391
+ nbbo;
392
+ liquidity;
393
+ schema;
394
+ markets;
395
+ };
396
+
38
397
  // src/version.ts
39
- var VERSION = "0.1.0";
398
+ var VERSION = "0.4.0";
40
399
 
41
400
  // src/config.ts
42
401
  var DEFAULT_BASE_URL = "https://pricing.skinpricer.com/v1";
402
+ var DEFAULT_PUBLIC_BASE_URL = "https://api.skinpricer.com/v1";
43
403
  var DEFAULT_TIMEOUT_MS = 3e4;
404
+ function derivePublicBaseUrl(baseUrl) {
405
+ try {
406
+ const parsed = new URL(baseUrl);
407
+ if (parsed.hostname.startsWith("pricing.")) {
408
+ parsed.hostname = `api.${parsed.hostname.slice("pricing.".length)}`;
409
+ return parsed.toString().replace(/\/+$/, "");
410
+ }
411
+ } catch {
412
+ }
413
+ return DEFAULT_PUBLIC_BASE_URL;
414
+ }
44
415
  var DEFAULT_RETRY = {
45
416
  maxRetries: 2,
46
417
  baseDelayMs: 250,
@@ -86,9 +457,13 @@ function resolveConfig(config) {
86
457
  "A non-empty `apiKey` is required to construct SkinpricerClient."
87
458
  );
88
459
  }
460
+ const baseUrl = normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL);
89
461
  return {
90
462
  apiKey: config.apiKey,
91
- baseUrl: normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL),
463
+ baseUrl,
464
+ publicBaseUrl: normalizeBaseUrl(
465
+ config.publicBaseUrl ?? derivePublicBaseUrl(baseUrl)
466
+ ),
92
467
  fetch: resolveFetch(config.fetch),
93
468
  timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
94
469
  retry: resolveRetry(config.retry),
@@ -288,8 +663,10 @@ function tryJsonParse(text) {
288
663
  return void 0;
289
664
  }
290
665
  }
291
- async function parseResponse(response) {
666
+ async function parseResponse(response, allowNotModified = false) {
292
667
  const meta = buildMeta(response);
668
+ if (allowNotModified && response.status === 304)
669
+ return { data: null, meta };
293
670
  const text = await response.text();
294
671
  if (response.ok) {
295
672
  if (text.length === 0) {
@@ -312,15 +689,6 @@ async function parseResponse(response) {
312
689
  throw errorFromResponse({ status: response.status, body, meta });
313
690
  }
314
691
 
315
- // src/utils/url.ts
316
- function encodePathSegment(segment) {
317
- return encodeURIComponent(segment);
318
- }
319
- function joinUrl(baseUrl, path) {
320
- const normalizedPath = path.startsWith("/") ? path : `/${path}`;
321
- return `${baseUrl}${normalizedPath}`;
322
- }
323
-
324
692
  // src/http/query.ts
325
693
  function serializeQuery(params) {
326
694
  const search = new URLSearchParams();
@@ -344,19 +712,26 @@ function serializeQuery(params) {
344
712
  // src/http/request-builder.ts
345
713
  function buildRequest(config, input) {
346
714
  const queryString = input.query ? serializeQuery(input.query) : "";
347
- const url = joinUrl(config.baseUrl, input.path) + queryString;
715
+ const url = joinUrl(input.baseUrl ?? config.baseUrl, input.path) + queryString;
348
716
  const headers = {
349
717
  Accept: "application/json",
350
718
  "User-Agent": config.userAgent,
351
719
  "X-Skinpricer-Client": config.userAgent,
352
- ...config.headers
720
+ ...Object.fromEntries(
721
+ Object.entries(config.headers).filter(
722
+ ([name]) => name.toLowerCase() !== "authorization"
723
+ )
724
+ )
353
725
  };
354
726
  let body;
355
727
  if (input.body !== void 0) {
356
728
  body = JSON.stringify(input.body);
357
729
  headers["Content-Type"] = "application/json";
358
730
  }
359
- headers["Authorization"] = `${config.authScheme} ${config.apiKey}`;
731
+ if (input.authenticated !== false)
732
+ headers["Authorization"] = `${config.authScheme} ${config.apiKey}`;
733
+ if (input.ifNoneMatch !== void 0)
734
+ headers["If-None-Match"] = input.ifNoneMatch;
360
735
  const prepared = { url, method: input.method, headers };
361
736
  if (body !== void 0) prepared.body = body;
362
737
  return prepared;
@@ -439,6 +814,16 @@ var HttpClient = class {
439
814
  }
440
815
  config;
441
816
  throttleUntil = 0;
817
+ /** Base URL for keyless public-service endpoints (see {@link ResolvedConfig.publicBaseUrl}). */
818
+ get publicBaseUrl() {
819
+ return this.config.publicBaseUrl;
820
+ }
821
+ /** Selects an API version while retaining a configured gateway prefix. */
822
+ versionedBaseUrl(version, baseUrl = this.config.baseUrl) {
823
+ const url = new URL(baseUrl);
824
+ url.pathname = /\/v[0-9]+$/.test(url.pathname) ? url.pathname.replace(/\/v[0-9]+$/, `/${version}`) : `${url.pathname.replace(/\/$/, "")}/${version}`;
825
+ return url.toString().replace(/\/$/, "");
826
+ }
442
827
  async request(input, options = {}) {
443
828
  const prepared = buildRequest(this.config, input);
444
829
  const retry = resolveRequestRetry(this.config.retry, options.retry);
@@ -454,46 +839,18 @@ var HttpClient = class {
454
839
  url: prepared.url,
455
840
  attempt
456
841
  });
457
- let response;
458
842
  try {
459
- response = await this.config.fetch(prepared.url, {
843
+ const response = await this.config.fetch(prepared.url, {
460
844
  method: prepared.method,
461
845
  headers: prepared.headers,
462
846
  body: prepared.body,
463
847
  signal: handle.signal
464
848
  });
465
- } catch (error) {
849
+ const parsed = await parseResponse(
850
+ response,
851
+ input.ifNoneMatch !== void 0
852
+ );
466
853
  handle.cleanup();
467
- if (callerSignal?.aborted && !handle.didTimeout()) {
468
- throw abortError(callerSignal);
469
- }
470
- if (retry && shouldRetry({ method: input.method, attempt, retry, status: null })) {
471
- const delayMs = retryDelayMs({
472
- attempt,
473
- retry,
474
- retryAfterSeconds: null
475
- });
476
- await runHook(hooks.onRetry, {
477
- method: input.method,
478
- url: prepared.url,
479
- attempt,
480
- delayMs,
481
- status: null
482
- });
483
- await sleep(delayMs, callerSignal);
484
- attempt += 1;
485
- continue;
486
- }
487
- if (handle.didTimeout()) {
488
- throw new TimeoutError(`Request timed out after ${timeoutMs}ms`, {
489
- cause: error
490
- });
491
- }
492
- throw new NetworkError(networkMessage(error), { cause: error });
493
- }
494
- handle.cleanup();
495
- try {
496
- const parsed = await parseResponse(response);
497
854
  this.recordRateLimit(parsed.meta.rateLimit);
498
855
  await runHook(hooks.onResponse, {
499
856
  method: input.method,
@@ -504,30 +861,32 @@ var HttpClient = class {
504
861
  });
505
862
  return parsed;
506
863
  } catch (error) {
507
- if (error instanceof RateLimitError) {
508
- this.recordRateLimit(error.rateLimit, error.retryAfterSeconds);
864
+ handle.cleanup();
865
+ if (callerSignal?.aborted && !handle.didTimeout())
866
+ throw abortError(callerSignal);
867
+ const failure = handle.didTimeout() ? new TimeoutError(`Request timed out after ${timeoutMs}ms`, {
868
+ cause: error
869
+ }) : error instanceof SkinpricerError ? error : new NetworkError(networkMessage(error), { cause: error });
870
+ if (failure instanceof RateLimitError) {
871
+ this.recordRateLimit(failure.rateLimit, failure.retryAfterSeconds);
509
872
  }
510
- if (error instanceof SkinpricerError && error.status !== void 0 && retry && shouldRetry({
511
- method: input.method,
512
- attempt,
513
- retry,
514
- status: error.status
515
- })) {
516
- const retryAfterSeconds = error instanceof RateLimitError ? error.retryAfterSeconds : error.rateLimit?.retryAfterSeconds ?? null;
873
+ const status = failure.status ?? null;
874
+ if (retry && shouldRetry({ method: input.method, attempt, retry, status })) {
875
+ const retryAfterSeconds = failure instanceof RateLimitError ? failure.retryAfterSeconds : failure.rateLimit?.retryAfterSeconds ?? null;
517
876
  const delayMs = retryDelayMs({ attempt, retry, retryAfterSeconds });
518
877
  await runHook(hooks.onRetry, {
519
878
  method: input.method,
520
879
  url: prepared.url,
521
880
  attempt,
522
881
  delayMs,
523
- status: error.status,
524
- error
882
+ status,
883
+ error: failure
525
884
  });
526
885
  await sleep(delayMs, callerSignal);
527
886
  attempt += 1;
528
887
  continue;
529
888
  }
530
- throw error;
889
+ throw failure;
531
890
  }
532
891
  }
533
892
  }
@@ -573,61 +932,36 @@ async function mapWithConcurrency(items, limit, fn) {
573
932
  return results;
574
933
  }
575
934
 
576
- // src/meta.ts
577
- var RESPONSE_META = /* @__PURE__ */ Symbol("skinpricer.responseMeta");
578
- function attachMeta(data, meta) {
579
- if (data !== null && typeof data === "object") {
580
- Object.defineProperty(data, RESPONSE_META, {
581
- value: meta,
582
- enumerable: false,
583
- writable: false,
584
- configurable: true
585
- });
586
- }
587
- return data;
588
- }
589
- function getMeta(value) {
590
- if (value !== null && typeof value === "object") {
591
- return value[RESPONSE_META];
592
- }
593
- return void 0;
594
- }
595
-
596
- // src/resources/resource.ts
597
- var BaseResource = class {
598
- constructor(http) {
599
- this.http = http;
600
- }
601
- http;
602
- /** Performs a request and returns the data with {@link ResponseMeta} attached. */
603
- async call(input, options) {
604
- const { data, meta } = await this.http.request(input, options);
605
- return attachMeta(data, meta);
606
- }
607
- };
608
-
609
935
  // src/resources/aggregations.ts
610
936
  var MAX_IDS_PER_REQUEST = 100;
611
937
  var DEFAULT_BATCH_CONCURRENCY = 5;
612
938
  var AggregationsResource = class extends BaseResource {
613
- /** GET /v1/aggregations/min-prices — minimum sell price per market (max 100 ids). */
939
+ /** GET /v1/aggregations/min-prices — minimum sell price per market. Pass up to 100 `ids` or `marketHashNames`. */
614
940
  minPrices(params, options) {
615
941
  return this.call(
616
942
  {
617
943
  method: "GET",
618
944
  path: "/aggregations/min-prices",
619
- query: { ids: params.ids, markets: params.markets }
945
+ query: {
946
+ ids: params.ids,
947
+ marketHashNames: params.marketHashNames,
948
+ markets: params.markets
949
+ }
620
950
  },
621
951
  options
622
952
  );
623
953
  }
624
- /** GET /v1/aggregations/max-orders — maximum buy order per market (max 100 ids). */
954
+ /** GET /v1/aggregations/max-orders — maximum buy order per market. Pass up to 100 `ids` or `marketHashNames`. */
625
955
  maxOrders(params, options) {
626
956
  return this.call(
627
957
  {
628
958
  method: "GET",
629
959
  path: "/aggregations/max-orders",
630
- query: { ids: params.ids, markets: params.markets }
960
+ query: {
961
+ ids: params.ids,
962
+ marketHashNames: params.marketHashNames,
963
+ markets: params.markets
964
+ }
631
965
  },
632
966
  options
633
967
  );
@@ -800,82 +1134,6 @@ var Buff163Resource = class extends BaseResource {
800
1134
  }
801
1135
  };
802
1136
 
803
- // src/resources/history.ts
804
- function historyQuery(params) {
805
- return {
806
- from: params.from,
807
- to: params.to,
808
- markets: params.markets,
809
- listingType: params.listingType,
810
- salesWindow: params.salesWindow,
811
- interval: params.interval
812
- };
813
- }
814
- var HistoryResource = class extends BaseResource {
815
- /** `GET /v1/pricing/:marketHashName/history` — aggregated time series. */
816
- get(marketHashName, params = {}, options) {
817
- return this.call(
818
- {
819
- method: "GET",
820
- path: `/pricing/${encodePathSegment(marketHashName)}/history`,
821
- query: historyQuery(params)
822
- },
823
- options
824
- );
825
- }
826
- /** `GET /v1/pricing/:marketHashName/history/markets` — per-market series. */
827
- byMarket(marketHashName, params = {}, options) {
828
- return this.call(
829
- {
830
- method: "GET",
831
- path: `/pricing/${encodePathSegment(marketHashName)}/history/markets`,
832
- query: historyQuery(params)
833
- },
834
- options
835
- );
836
- }
837
- };
838
-
839
- // src/resources/items.ts
840
- var ItemsResource = class extends BaseResource {
841
- /** GET /v1/items — paginated item search with current pricing. */
842
- search(params = {}, options) {
843
- return this.call(
844
- {
845
- method: "GET",
846
- path: "/items",
847
- query: {
848
- search: params.search,
849
- markets: params.markets,
850
- page: params.page,
851
- perPage: params.perPage
852
- }
853
- },
854
- options
855
- );
856
- }
857
- /** GET /v1/items/all — every tracked item with latest prices (capped, unpaginated). */
858
- all(options) {
859
- return this.call(
860
- { method: "GET", path: "/items/all" },
861
- options
862
- );
863
- }
864
- /** Async iterator over every matching item, walking pages. */
865
- async *searchEach(params = {}, options) {
866
- let page = params.page ?? 1;
867
- for (; ; ) {
868
- const res = await this.search({ ...params, page }, options);
869
- for (const item of res.data) {
870
- yield item;
871
- }
872
- const next = res.pagination.nextPage;
873
- if (next === null || next <= page) return;
874
- page = next;
875
- }
876
- }
877
- };
878
-
879
1137
  // src/resources/market-analytics.ts
880
1138
  var MarketAnalyticsResource = class extends BaseResource {
881
1139
  /** `GET /v1/market-analytics/:marketHashName` — per-market analytics rows. */
@@ -891,61 +1149,16 @@ var MarketAnalyticsResource = class extends BaseResource {
891
1149
  }
892
1150
  };
893
1151
 
894
- // src/resources/nbbo.ts
895
- var NbboResource = class extends BaseResource {
896
- /** `GET /v1/nbbo` — best bid/ask across markets. Pass `id` or `marketHashName`. */
897
- get(params, options) {
898
- return this.call(
899
- {
900
- method: "GET",
901
- path: "/nbbo",
902
- query: {
903
- id: params.id,
904
- market_hash_name: params.marketHashName,
905
- markets: params.markets
906
- }
907
- },
908
- options
909
- );
910
- }
911
- /** `GET /v1/nbbo/depth` — aggregated order-book depth per side. */
912
- depth(params, options) {
913
- return this.call(
914
- {
915
- method: "GET",
916
- path: "/nbbo/depth",
917
- query: {
918
- id: params.id,
919
- market_hash_name: params.marketHashName,
920
- markets: params.markets,
921
- depth: params.depth
922
- }
923
- },
924
- options
925
- );
926
- }
927
- };
928
-
929
- // src/resources/pricing.ts
930
- var PricingResource = class extends BaseResource {
931
- /** `GET /v1/pricing/:marketHashName` — full cross-market pricing snapshot. */
932
- get(marketHashName, params = {}, options) {
933
- return this.call(
934
- {
935
- method: "GET",
936
- path: `/pricing/${encodePathSegment(marketHashName)}`,
937
- query: { markets: params.markets }
938
- },
939
- options
940
- );
941
- }
942
- /** `GET /v1/pricing/:marketHashName/listings` — individual listing samples. */
943
- listings(marketHashName, params = {}, options) {
1152
+ // src/resources/prices.ts
1153
+ var PricesResource = class extends BaseResource {
1154
+ latestAll(params, options) {
944
1155
  return this.call(
945
1156
  {
946
1157
  method: "GET",
947
- path: `/pricing/${encodePathSegment(marketHashName)}/listings`,
948
- query: { limit: params.limit, markets: params.markets }
1158
+ path: "/prices/latest",
1159
+ baseUrl: this.http.versionedBaseUrl("v2"),
1160
+ query: { game: params.game },
1161
+ ifNoneMatch: params.ifNoneMatch
949
1162
  },
950
1163
  options
951
1164
  );
@@ -998,6 +1211,14 @@ var SkinpricerClient = class {
998
1211
  marketAnalytics;
999
1212
  attributePrices;
1000
1213
  buff163;
1214
+ liquidity;
1215
+ markets;
1216
+ schema;
1217
+ prices;
1218
+ /** Access the v2 endpoints supported by the selected game. */
1219
+ forGame(game) {
1220
+ return new GameClient(this.httpClient, game);
1221
+ }
1001
1222
  httpClient;
1002
1223
  constructor(config) {
1003
1224
  this.httpClient = new HttpClient(resolveConfig(config));
@@ -1012,6 +1233,10 @@ var SkinpricerClient = class {
1012
1233
  this.marketAnalytics = new MarketAnalyticsResource(this.httpClient);
1013
1234
  this.attributePrices = new AttributePricesResource(this.httpClient);
1014
1235
  this.buff163 = new Buff163Resource(this.httpClient);
1236
+ this.liquidity = new LiquidityResource(this.httpClient);
1237
+ this.markets = new MarketsResource(this.httpClient);
1238
+ this.schema = new SchemaResource(this.httpClient);
1239
+ this.prices = new PricesResource(this.httpClient);
1015
1240
  }
1016
1241
  };
1017
1242
 
@@ -1021,6 +1246,7 @@ var KNOWN_MARKETS = [
1021
1246
  "skindeck",
1022
1247
  "buff163",
1023
1248
  "csfloat",
1249
+ "csdeals",
1024
1250
  "marketcsgo",
1025
1251
  "cstrade",
1026
1252
  "dmarket",
@@ -1030,9 +1256,15 @@ var KNOWN_MARKETS = [
1030
1256
  "whitemarket",
1031
1257
  "waxpeer",
1032
1258
  "lootfarm",
1259
+ "rapidskins",
1260
+ "avanmarket",
1033
1261
  "tradeit-store",
1034
1262
  "tradeit-trade",
1035
- "steamcommunity"
1263
+ "steamcommunity",
1264
+ "youpin",
1265
+ "mannco-store",
1266
+ "rusttm",
1267
+ "rustskins"
1036
1268
  ];
1037
1269
  var ATTRIBUTE_MARKETS = [
1038
1270
  "buff163",
@@ -1042,6 +1274,41 @@ var ATTRIBUTE_MARKETS = [
1042
1274
  "dmarket"
1043
1275
  ];
1044
1276
 
1277
+ // src/types/liquidity.ts
1278
+ var LIQUIDITY_BADGES = [
1279
+ "EXTREMELY_LIQUID",
1280
+ "VERY_LIQUID",
1281
+ "LIQUID",
1282
+ "ILLIQUID",
1283
+ "VERY_ILLIQUID",
1284
+ "EXTREMELY_ILLIQUID",
1285
+ "UNTRADED",
1286
+ "INSUFFICIENT_DATA"
1287
+ ];
1288
+ var LIQUIDITY_CONFIDENCE = [
1289
+ "HIGH",
1290
+ "MEDIUM",
1291
+ "LOW",
1292
+ "CRITICAL"
1293
+ ];
1294
+ var LIQUIDITY_LABELS = [
1295
+ "extremely_liquid",
1296
+ "very_liquid",
1297
+ "liquid",
1298
+ "illiquid",
1299
+ "very_illiquid",
1300
+ "extremely_illiquid",
1301
+ "unknown"
1302
+ ];
1303
+ var SUPPORTED_LIQUIDITY_MARKETS = [
1304
+ "skinport",
1305
+ "marketcsgo",
1306
+ "dmarket",
1307
+ "steamcommunity",
1308
+ "csfloat"
1309
+ ];
1310
+ var SUPPORTED_RUST_LIQUIDITY_MARKETS = ["rusttm", "skinport"];
1311
+
1045
1312
  // src/utils/money.ts
1046
1313
  function centsToUsd(cents) {
1047
1314
  return cents / 100;
@@ -1068,22 +1335,33 @@ exports.BaseResource = BaseResource;
1068
1335
  exports.Buff163Resource = Buff163Resource;
1069
1336
  exports.ConfigurationError = ConfigurationError;
1070
1337
  exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
1338
+ exports.DEFAULT_PUBLIC_BASE_URL = DEFAULT_PUBLIC_BASE_URL;
1071
1339
  exports.DEFAULT_RETRY = DEFAULT_RETRY;
1072
1340
  exports.DEFAULT_TIMEOUT_MS = DEFAULT_TIMEOUT_MS;
1073
1341
  exports.FeatureNotAvailableError = FeatureNotAvailableError;
1342
+ exports.GameClient = GameClient;
1074
1343
  exports.HistoryResource = HistoryResource;
1075
1344
  exports.ItemsResource = ItemsResource;
1076
1345
  exports.KNOWN_MARKETS = KNOWN_MARKETS;
1346
+ exports.LIQUIDITY_BADGES = LIQUIDITY_BADGES;
1347
+ exports.LIQUIDITY_CONFIDENCE = LIQUIDITY_CONFIDENCE;
1348
+ exports.LIQUIDITY_LABELS = LIQUIDITY_LABELS;
1349
+ exports.LiquidityResource = LiquidityResource;
1077
1350
  exports.MarketAnalyticsResource = MarketAnalyticsResource;
1351
+ exports.MarketsResource = MarketsResource;
1078
1352
  exports.NbboResource = NbboResource;
1079
1353
  exports.NetworkError = NetworkError;
1080
1354
  exports.NotFoundError = NotFoundError;
1081
1355
  exports.ParseError = ParseError;
1082
1356
  exports.PermissionError = PermissionError;
1357
+ exports.PricesResource = PricesResource;
1083
1358
  exports.PricingResource = PricingResource;
1084
1359
  exports.RESPONSE_META = RESPONSE_META;
1085
1360
  exports.RateLimitError = RateLimitError;
1086
1361
  exports.RecommendationsResource = RecommendationsResource;
1362
+ exports.SUPPORTED_LIQUIDITY_MARKETS = SUPPORTED_LIQUIDITY_MARKETS;
1363
+ exports.SUPPORTED_RUST_LIQUIDITY_MARKETS = SUPPORTED_RUST_LIQUIDITY_MARKETS;
1364
+ exports.SchemaResource = SchemaResource;
1087
1365
  exports.ServerError = ServerError;
1088
1366
  exports.SkinpricerClient = SkinpricerClient;
1089
1367
  exports.SkinpricerError = SkinpricerError;