@skinpricer/sdk 0.2.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/dist/index.js CHANGED
@@ -34,11 +34,23 @@ var ParseError = class extends SkinpricerError {
34
34
  };
35
35
 
36
36
  // src/version.ts
37
- var VERSION = "0.1.0";
37
+ var VERSION = "0.3.0";
38
38
 
39
39
  // src/config.ts
40
40
  var DEFAULT_BASE_URL = "https://pricing.skinpricer.com/v1";
41
+ var DEFAULT_PUBLIC_BASE_URL = "https://api.skinpricer.com/v1";
41
42
  var DEFAULT_TIMEOUT_MS = 3e4;
43
+ function derivePublicBaseUrl(baseUrl) {
44
+ try {
45
+ const parsed = new URL(baseUrl);
46
+ if (parsed.hostname.startsWith("pricing.")) {
47
+ parsed.hostname = `api.${parsed.hostname.slice("pricing.".length)}`;
48
+ return parsed.toString().replace(/\/+$/, "");
49
+ }
50
+ } catch {
51
+ }
52
+ return DEFAULT_PUBLIC_BASE_URL;
53
+ }
42
54
  var DEFAULT_RETRY = {
43
55
  maxRetries: 2,
44
56
  baseDelayMs: 250,
@@ -84,9 +96,13 @@ function resolveConfig(config) {
84
96
  "A non-empty `apiKey` is required to construct SkinpricerClient."
85
97
  );
86
98
  }
99
+ const baseUrl = normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL);
87
100
  return {
88
101
  apiKey: config.apiKey,
89
- baseUrl: normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL),
102
+ baseUrl,
103
+ publicBaseUrl: normalizeBaseUrl(
104
+ config.publicBaseUrl ?? derivePublicBaseUrl(baseUrl)
105
+ ),
90
106
  fetch: resolveFetch(config.fetch),
91
107
  timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
92
108
  retry: resolveRetry(config.retry),
@@ -342,7 +358,7 @@ function serializeQuery(params) {
342
358
  // src/http/request-builder.ts
343
359
  function buildRequest(config, input) {
344
360
  const queryString = input.query ? serializeQuery(input.query) : "";
345
- const url = joinUrl(config.baseUrl, input.path) + queryString;
361
+ const url = joinUrl(input.baseUrl ?? config.baseUrl, input.path) + queryString;
346
362
  const headers = {
347
363
  Accept: "application/json",
348
364
  "User-Agent": config.userAgent,
@@ -437,6 +453,10 @@ var HttpClient = class {
437
453
  }
438
454
  config;
439
455
  throttleUntil = 0;
456
+ /** Base URL for keyless public-service endpoints (see {@link ResolvedConfig.publicBaseUrl}). */
457
+ get publicBaseUrl() {
458
+ return this.config.publicBaseUrl;
459
+ }
440
460
  async request(input, options = {}) {
441
461
  const prepared = buildRequest(this.config, input);
442
462
  const retry = resolveRequestRetry(this.config.retry, options.retry);
@@ -608,24 +628,32 @@ var BaseResource = class {
608
628
  var MAX_IDS_PER_REQUEST = 100;
609
629
  var DEFAULT_BATCH_CONCURRENCY = 5;
610
630
  var AggregationsResource = class extends BaseResource {
611
- /** GET /v1/aggregations/min-prices — minimum sell price per market (max 100 ids). */
631
+ /** GET /v1/aggregations/min-prices — minimum sell price per market. Pass up to 100 `ids` or `marketHashNames`. */
612
632
  minPrices(params, options) {
613
633
  return this.call(
614
634
  {
615
635
  method: "GET",
616
636
  path: "/aggregations/min-prices",
617
- query: { ids: params.ids, markets: params.markets }
637
+ query: {
638
+ ids: params.ids,
639
+ marketHashNames: params.marketHashNames,
640
+ markets: params.markets
641
+ }
618
642
  },
619
643
  options
620
644
  );
621
645
  }
622
- /** GET /v1/aggregations/max-orders — maximum buy order per market (max 100 ids). */
646
+ /** GET /v1/aggregations/max-orders — maximum buy order per market. Pass up to 100 `ids` or `marketHashNames`. */
623
647
  maxOrders(params, options) {
624
648
  return this.call(
625
649
  {
626
650
  method: "GET",
627
651
  path: "/aggregations/max-orders",
628
- query: { ids: params.ids, markets: params.markets }
652
+ query: {
653
+ ids: params.ids,
654
+ marketHashNames: params.marketHashNames,
655
+ markets: params.markets
656
+ }
629
657
  },
630
658
  options
631
659
  );
@@ -874,6 +902,65 @@ var ItemsResource = class extends BaseResource {
874
902
  }
875
903
  };
876
904
 
905
+ // src/resources/liquidity.ts
906
+ var LiquidityResource = class extends BaseResource {
907
+ /** `GET /v1/liquidity/:marketHashName` — full liquidity model for one item. */
908
+ get(marketHashName, params = {}, options) {
909
+ return this.call(
910
+ {
911
+ method: "GET",
912
+ path: `/liquidity/${encodePathSegment(marketHashName)}`,
913
+ query: { askPrice: params.askPrice, market: params.market }
914
+ },
915
+ options
916
+ );
917
+ }
918
+ /** `GET /v1/liquidity/summary/:marketHashName` — slim badge-only projection. */
919
+ summary(marketHashName, params = {}, options) {
920
+ return this.call(
921
+ {
922
+ method: "GET",
923
+ path: `/liquidity/summary/${encodePathSegment(marketHashName)}`,
924
+ query: { askPrice: params.askPrice, market: params.market }
925
+ },
926
+ options
927
+ );
928
+ }
929
+ /** `POST /v1/liquidity/batch` — score up to 100 items in one call. */
930
+ batch(body, options) {
931
+ return this.call(
932
+ {
933
+ method: "POST",
934
+ path: "/liquidity/batch",
935
+ body: { marketHashNames: body.marketHashNames, market: body.market }
936
+ },
937
+ options
938
+ );
939
+ }
940
+ /**
941
+ * `GET /v1/liquidity/items` — Enterprise: the whole-catalog liquidity map,
942
+ * rematerialized every ~10 minutes. Poll {@link manifest} and compare
943
+ * `version` before refetching this heavier payload.
944
+ */
945
+ bulk(options) {
946
+ return this.call(
947
+ { method: "GET", path: "/liquidity/items" },
948
+ options
949
+ );
950
+ }
951
+ /**
952
+ * `GET /v1/liquidity/items/manifest` — Enterprise: a cheap change-probe for
953
+ * the {@link bulk} map (`version`, `calculatedAt`, `cadence`, `markets`,
954
+ * `itemCount`). Refetch the bulk map only when `version` changes.
955
+ */
956
+ manifest(options) {
957
+ return this.call(
958
+ { method: "GET", path: "/liquidity/items/manifest" },
959
+ options
960
+ );
961
+ }
962
+ };
963
+
877
964
  // src/resources/market-analytics.ts
878
965
  var MarketAnalyticsResource = class extends BaseResource {
879
966
  /** `GET /v1/market-analytics/:marketHashName` — per-market analytics rows. */
@@ -889,6 +976,22 @@ var MarketAnalyticsResource = class extends BaseResource {
889
976
  }
890
977
  };
891
978
 
979
+ // src/resources/markets.ts
980
+ var MarketsResource = class extends BaseResource {
981
+ /**
982
+ * `GET /v1/markets/health` — per-market ingest status, last event time, and
983
+ * listing counts for every integrated market. Returns a plain array of
984
+ * {@link import("../types/markets").MarketHealthRow}.
985
+ */
986
+ health(options) {
987
+ return this.call(
988
+ // Keyless: served by the public `api.` host, not the pricing base.
989
+ { method: "GET", path: "/markets/health", baseUrl: this.http.publicBaseUrl },
990
+ options
991
+ );
992
+ }
993
+ };
994
+
892
995
  // src/resources/nbbo.ts
893
996
  var NbboResource = class extends BaseResource {
894
997
  /** `GET /v1/nbbo` — best bid/ask across markets. Pass `id` or `marketHashName`. */
@@ -996,6 +1099,8 @@ var SkinpricerClient = class {
996
1099
  marketAnalytics;
997
1100
  attributePrices;
998
1101
  buff163;
1102
+ liquidity;
1103
+ markets;
999
1104
  httpClient;
1000
1105
  constructor(config) {
1001
1106
  this.httpClient = new HttpClient(resolveConfig(config));
@@ -1010,6 +1115,8 @@ var SkinpricerClient = class {
1010
1115
  this.marketAnalytics = new MarketAnalyticsResource(this.httpClient);
1011
1116
  this.attributePrices = new AttributePricesResource(this.httpClient);
1012
1117
  this.buff163 = new Buff163Resource(this.httpClient);
1118
+ this.liquidity = new LiquidityResource(this.httpClient);
1119
+ this.markets = new MarketsResource(this.httpClient);
1013
1120
  }
1014
1121
  };
1015
1122
 
@@ -1019,6 +1126,7 @@ var KNOWN_MARKETS = [
1019
1126
  "skindeck",
1020
1127
  "buff163",
1021
1128
  "csfloat",
1129
+ "csdeals",
1022
1130
  "marketcsgo",
1023
1131
  "cstrade",
1024
1132
  "dmarket",
@@ -1028,6 +1136,7 @@ var KNOWN_MARKETS = [
1028
1136
  "whitemarket",
1029
1137
  "waxpeer",
1030
1138
  "lootfarm",
1139
+ "avanmarket",
1031
1140
  "tradeit-store",
1032
1141
  "tradeit-trade",
1033
1142
  "steamcommunity"
@@ -1040,6 +1149,39 @@ var ATTRIBUTE_MARKETS = [
1040
1149
  "dmarket"
1041
1150
  ];
1042
1151
 
1152
+ // src/types/liquidity.ts
1153
+ var LIQUIDITY_BADGES = [
1154
+ "EXTREMELY_LIQUID",
1155
+ "VERY_LIQUID",
1156
+ "LIQUID",
1157
+ "ILLIQUID",
1158
+ "VERY_ILLIQUID",
1159
+ "EXTREMELY_ILLIQUID",
1160
+ "UNTRADED"
1161
+ ];
1162
+ var LIQUIDITY_CONFIDENCE = [
1163
+ "HIGH",
1164
+ "MEDIUM",
1165
+ "LOW",
1166
+ "CRITICAL"
1167
+ ];
1168
+ var LIQUIDITY_LABELS = [
1169
+ "extremely_liquid",
1170
+ "very_liquid",
1171
+ "liquid",
1172
+ "illiquid",
1173
+ "very_illiquid",
1174
+ "extremely_illiquid",
1175
+ "unknown"
1176
+ ];
1177
+ var SUPPORTED_LIQUIDITY_MARKETS = [
1178
+ "skinport",
1179
+ "marketcsgo",
1180
+ "dmarket",
1181
+ "csdeals",
1182
+ "csfloat"
1183
+ ];
1184
+
1043
1185
  // src/utils/money.ts
1044
1186
  function centsToUsd(cents) {
1045
1187
  return cents / 100;
@@ -1056,6 +1198,6 @@ function parseIsoDate(value) {
1056
1198
  return new Date(value);
1057
1199
  }
1058
1200
 
1059
- export { APIError, ATTRIBUTE_MARKETS, AggregationsResource, ArbitrageResource, AttributePricesResource, AuthenticationError, BaseResource, Buff163Resource, ConfigurationError, DEFAULT_BASE_URL, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, FeatureNotAvailableError, HistoryResource, ItemsResource, KNOWN_MARKETS, MarketAnalyticsResource, NbboResource, NetworkError, NotFoundError, ParseError, PermissionError, PricingResource, RESPONSE_META, RateLimitError, RecommendationsResource, ServerError, SkinpricerClient, SkinpricerError, StatusResource, TimeoutError, VERSION, ValidationError, centsToUsd, chunk, errorFromResponse, formatUsd, getMeta, mapWithConcurrency, parseIsoDate, resolveConfig };
1201
+ export { APIError, ATTRIBUTE_MARKETS, AggregationsResource, ArbitrageResource, AttributePricesResource, AuthenticationError, BaseResource, Buff163Resource, ConfigurationError, DEFAULT_BASE_URL, DEFAULT_PUBLIC_BASE_URL, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, FeatureNotAvailableError, HistoryResource, ItemsResource, KNOWN_MARKETS, LIQUIDITY_BADGES, LIQUIDITY_CONFIDENCE, LIQUIDITY_LABELS, LiquidityResource, MarketAnalyticsResource, MarketsResource, NbboResource, NetworkError, NotFoundError, ParseError, PermissionError, PricingResource, RESPONSE_META, RateLimitError, RecommendationsResource, SUPPORTED_LIQUIDITY_MARKETS, ServerError, SkinpricerClient, SkinpricerError, StatusResource, TimeoutError, VERSION, ValidationError, centsToUsd, chunk, errorFromResponse, formatUsd, getMeta, mapWithConcurrency, parseIsoDate, resolveConfig };
1060
1202
  //# sourceMappingURL=index.js.map
1061
1203
  //# sourceMappingURL=index.js.map