@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/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,14 @@ interface ClientConfig {
|
|
|
65
65
|
apiKey: string;
|
|
66
66
|
/** Base URL including the version prefix. */
|
|
67
67
|
baseUrl?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Base URL (incl. version prefix) for the keyless public-service endpoints
|
|
70
|
+
* that live off the pricing host — currently only `markets.health`. Defaults
|
|
71
|
+
* to deriving the `api.` host from {@link baseUrl} (e.g.
|
|
72
|
+
* `pricing.skinpricer.com` → `api.skinpricer.com`), falling back to
|
|
73
|
+
* `https://api.skinpricer.com/v1`.
|
|
74
|
+
*/
|
|
75
|
+
publicBaseUrl?: string;
|
|
68
76
|
/** Custom `fetch` implementation. Defaults to the global `fetch`. */
|
|
69
77
|
fetch?: FetchLike;
|
|
70
78
|
/** Per-request timeout in ms. Defaults to 30000; `0` disables it. */
|
|
@@ -84,6 +92,7 @@ interface ClientConfig {
|
|
|
84
92
|
interface ResolvedConfig {
|
|
85
93
|
apiKey: string;
|
|
86
94
|
baseUrl: string;
|
|
95
|
+
publicBaseUrl: string;
|
|
87
96
|
fetch: FetchLike;
|
|
88
97
|
timeoutMs: number;
|
|
89
98
|
retry: RetryConfig | null;
|
|
@@ -94,6 +103,7 @@ interface ResolvedConfig {
|
|
|
94
103
|
hooks: ClientHooks;
|
|
95
104
|
}
|
|
96
105
|
declare const DEFAULT_BASE_URL = "https://pricing.skinpricer.com/v1";
|
|
106
|
+
declare const DEFAULT_PUBLIC_BASE_URL = "https://api.skinpricer.com/v1";
|
|
97
107
|
declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
98
108
|
declare const DEFAULT_RETRY: RetryConfig;
|
|
99
109
|
declare function resolveConfig(config: ClientConfig): ResolvedConfig;
|
|
@@ -125,6 +135,8 @@ interface BuildRequestInput {
|
|
|
125
135
|
path: string;
|
|
126
136
|
query?: QueryParams;
|
|
127
137
|
body?: unknown;
|
|
138
|
+
/** Overrides `config.baseUrl` for this request (e.g. keyless public-service endpoints). */
|
|
139
|
+
baseUrl?: string;
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
interface RequestOptions {
|
|
@@ -136,18 +148,53 @@ declare class HttpClient {
|
|
|
136
148
|
private readonly config;
|
|
137
149
|
private throttleUntil;
|
|
138
150
|
constructor(config: ResolvedConfig);
|
|
151
|
+
/** Base URL for keyless public-service endpoints (see {@link ResolvedConfig.publicBaseUrl}). */
|
|
152
|
+
get publicBaseUrl(): string;
|
|
139
153
|
request<T>(input: BuildRequestInput, options?: RequestOptions): Promise<HttpResponse<T>>;
|
|
140
154
|
private recordRateLimit;
|
|
141
155
|
private awaitThrottle;
|
|
142
156
|
}
|
|
143
157
|
|
|
144
|
-
/**
|
|
145
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Market ids the API integrates — the canonical join keys returned by
|
|
160
|
+
* `GET /v1/markets/health` and used across pricing / nbbo / aggregation
|
|
161
|
+
* responses. Kept in sync with that registry (18 integrated markets as of
|
|
162
|
+
* 2026-06). A market id appears here once the backend integrates it, regardless
|
|
163
|
+
* of live/degraded/stale status; ids prepared but not yet ingesting (e.g.
|
|
164
|
+
* bitskins, skinbaron) are intentionally excluded until they show in health.
|
|
165
|
+
*/
|
|
166
|
+
declare const KNOWN_MARKETS: readonly ["skinport", "skindeck", "buff163", "csfloat", "csdeals", "marketcsgo", "cstrade", "dmarket", "itrade", "lis-skins", "swapgg", "whitemarket", "waxpeer", "lootfarm", "avanmarket", "tradeit-store", "tradeit-trade", "steamcommunity"];
|
|
146
167
|
/** A known market id, or any other string. */
|
|
147
168
|
type KnownMarket = (typeof KNOWN_MARKETS)[number] | (string & Record<never, never>);
|
|
148
169
|
/** Markets that expose attribute (float/fade/tag) bucket pricing. */
|
|
149
170
|
declare const ATTRIBUTE_MARKETS: readonly ["buff163", "steamcommunity", "marketcsgo", "csfloat", "dmarket"];
|
|
150
171
|
type AttributeMarket = (typeof ATTRIBUTE_MARKETS)[number] | (string & Record<never, never>);
|
|
172
|
+
/**
|
|
173
|
+
* Per-market ingest status reported by `GET /v1/markets/health`. Distinct from
|
|
174
|
+
* the freshness endpoint's `MarketHealthStatus` (`healthy | degraded | stale`)
|
|
175
|
+
* in `./status` — the registry uses `live | warn | stale`.
|
|
176
|
+
*/
|
|
177
|
+
type MarketRegistryStatus = "live" | "warn" | "stale";
|
|
178
|
+
/**
|
|
179
|
+
* One market's health row from `GET /v1/markets/health`. The `id` is the
|
|
180
|
+
* canonical join key used across pricing / nbbo / aggregation responses (see
|
|
181
|
+
* {@link KNOWN_MARKETS}). A market appears here once integrated, at any status.
|
|
182
|
+
*/
|
|
183
|
+
interface MarketHealthRow {
|
|
184
|
+
id: string;
|
|
185
|
+
status: MarketRegistryStatus;
|
|
186
|
+
/** ISO timestamp of the latest ingest event from this marketplace. */
|
|
187
|
+
lastEventAt: string;
|
|
188
|
+
listingsCount: number;
|
|
189
|
+
/**
|
|
190
|
+
* Optional 48 × 5-min uptime tiers covering the trailing 4h. Each entry is
|
|
191
|
+
* 0 (down) / 1 (degraded) / 2 (live), oldest first. Absent when the backend
|
|
192
|
+
* doesn't yet emit per-bucket health.
|
|
193
|
+
*/
|
|
194
|
+
healthBars?: readonly number[];
|
|
195
|
+
}
|
|
196
|
+
/** `GET /v1/markets/health` — a plain array of per-market health rows. */
|
|
197
|
+
type MarketHealthResponse = MarketHealthRow[];
|
|
151
198
|
|
|
152
199
|
/** An ISO-8601 timestamp string. */
|
|
153
200
|
type IsoDateString = string;
|
|
@@ -199,8 +246,10 @@ interface PaginationMeta {
|
|
|
199
246
|
}
|
|
200
247
|
|
|
201
248
|
interface AggregationsParams {
|
|
202
|
-
/** Canonical item ids (1–100). */
|
|
203
|
-
ids
|
|
249
|
+
/** Canonical item ids (1–100). Provide this or {@link AggregationsParams.marketHashNames}. */
|
|
250
|
+
ids?: string[];
|
|
251
|
+
/** Market hash names (1–100). Provide this or {@link AggregationsParams.ids}. */
|
|
252
|
+
marketHashNames?: string[];
|
|
204
253
|
markets?: KnownMarket[];
|
|
205
254
|
}
|
|
206
255
|
/** Per-market minimum sell price (snake_case). */
|
|
@@ -256,9 +305,9 @@ interface AggregationsBatchParams {
|
|
|
256
305
|
concurrency?: number;
|
|
257
306
|
}
|
|
258
307
|
declare class AggregationsResource extends BaseResource {
|
|
259
|
-
/** GET /v1/aggregations/min-prices — minimum sell price per market
|
|
308
|
+
/** GET /v1/aggregations/min-prices — minimum sell price per market. Pass up to 100 `ids` or `marketHashNames`. */
|
|
260
309
|
minPrices(params: AggregationsParams, options?: RequestOptions): Promise<MinPricesResponse>;
|
|
261
|
-
/** GET /v1/aggregations/max-orders — maximum buy order per market
|
|
310
|
+
/** GET /v1/aggregations/max-orders — maximum buy order per market. Pass up to 100 `ids` or `marketHashNames`. */
|
|
262
311
|
maxOrders(params: AggregationsParams, options?: RequestOptions): Promise<MaxOrdersResponse>;
|
|
263
312
|
/** Like `minPrices` but splits more than 100 ids into batches and merges them. */
|
|
264
313
|
minPricesAll(ids: string[], params?: AggregationsBatchParams, options?: RequestOptions): Promise<MinPricesResponse>;
|
|
@@ -665,6 +714,135 @@ declare class ItemsResource extends BaseResource {
|
|
|
665
714
|
searchEach(params?: ItemSearchParams, options?: RequestOptions): AsyncGenerator<CurrentPriceResponse>;
|
|
666
715
|
}
|
|
667
716
|
|
|
717
|
+
declare const LIQUIDITY_BADGES: readonly ["EXTREMELY_LIQUID", "VERY_LIQUID", "LIQUID", "ILLIQUID", "VERY_ILLIQUID", "EXTREMELY_ILLIQUID", "UNTRADED"];
|
|
718
|
+
type LiquidityBadge = (typeof LIQUIDITY_BADGES)[number];
|
|
719
|
+
declare const LIQUIDITY_CONFIDENCE: readonly ["HIGH", "MEDIUM", "LOW", "CRITICAL"];
|
|
720
|
+
type LiquidityConfidence = (typeof LIQUIDITY_CONFIDENCE)[number];
|
|
721
|
+
type LiquidityCoverage = "full" | "partial" | "none";
|
|
722
|
+
/** Lowercase label form of the badge; `UNTRADED` maps to `"unknown"`, no `"moderate"` tier. */
|
|
723
|
+
declare const LIQUIDITY_LABELS: readonly ["extremely_liquid", "very_liquid", "liquid", "illiquid", "very_illiquid", "extremely_illiquid", "unknown"];
|
|
724
|
+
type LiquidityLabel = (typeof LIQUIDITY_LABELS)[number];
|
|
725
|
+
declare const SUPPORTED_LIQUIDITY_MARKETS: readonly ["skinport", "marketcsgo", "dmarket", "csdeals", "csfloat"];
|
|
726
|
+
type SupportedLiquidityMarket = (typeof SUPPORTED_LIQUIDITY_MARKETS)[number];
|
|
727
|
+
interface LiquidityParams {
|
|
728
|
+
/** Hypothetical ask (USD cents) to estimate against; defaults to the best ask. */
|
|
729
|
+
askPrice?: Cents;
|
|
730
|
+
market?: SupportedLiquidityMarket;
|
|
731
|
+
}
|
|
732
|
+
/** Per-market row; every metric is null when that market has no data. */
|
|
733
|
+
interface LiquidityMarketMetric {
|
|
734
|
+
market: string;
|
|
735
|
+
salesPerDay: number | null;
|
|
736
|
+
activeListings: number | null;
|
|
737
|
+
bestAskUsdCents: Cents | null;
|
|
738
|
+
medianTimeToSellHours: number | null;
|
|
739
|
+
p90TimeToSellHours: number | null;
|
|
740
|
+
salesDataAgeMinutes: number | null;
|
|
741
|
+
listingsDataAgeMinutes: number | null;
|
|
742
|
+
}
|
|
743
|
+
/** `GET /v1/liquidity/:marketHashName` — full liquidity model for one item. */
|
|
744
|
+
interface LiquidityResponse {
|
|
745
|
+
canonicalItemId: string;
|
|
746
|
+
marketHashName: string;
|
|
747
|
+
liquidityBadge: LiquidityBadge;
|
|
748
|
+
confidence: LiquidityConfidence;
|
|
749
|
+
coverage: LiquidityCoverage;
|
|
750
|
+
medianTimeToSellHours: number | null;
|
|
751
|
+
p90TimeToSellHours: number | null;
|
|
752
|
+
bestMarketToList: string | null;
|
|
753
|
+
salesPerDay: number | null;
|
|
754
|
+
activeListings: number | null;
|
|
755
|
+
referenceAskUsdCents: Cents | null;
|
|
756
|
+
marketWideSalesPerDay: number | null;
|
|
757
|
+
marketWideListings: number | null;
|
|
758
|
+
marketsWithSales: number;
|
|
759
|
+
marketsWithDepth: number;
|
|
760
|
+
/** Whole-market saturation (hours), NOT a per-listing estimate. */
|
|
761
|
+
marketWideMedianTimeToSellHours: number | null;
|
|
762
|
+
marketWideP90TimeToSellHours: number | null;
|
|
763
|
+
metrics: LiquidityMarketMetric[];
|
|
764
|
+
/** Data-quality flags, e.g. `sales_data_stale:marketcsgo`. */
|
|
765
|
+
notes: string[];
|
|
766
|
+
calculatedAt: IsoDateString;
|
|
767
|
+
}
|
|
768
|
+
/** `GET /v1/liquidity/summary/:marketHashName` — slim badge-only projection. */
|
|
769
|
+
interface LiquiditySummaryResponse {
|
|
770
|
+
marketHashName: string;
|
|
771
|
+
liquidityBadge: LiquidityBadge;
|
|
772
|
+
liquidity: LiquidityLabel;
|
|
773
|
+
/** Human time-to-sell, e.g. `"2 - 6 hours"` (`"No recent sales"` when untraded). */
|
|
774
|
+
estimatedSaleTime: string;
|
|
775
|
+
confidence: LiquidityConfidence;
|
|
776
|
+
/** 0-100, higher sells faster; null when untraded. */
|
|
777
|
+
score: number | null;
|
|
778
|
+
bestMarketToList: string | null;
|
|
779
|
+
calculatedAt: IsoDateString;
|
|
780
|
+
}
|
|
781
|
+
/** Request body for `POST /v1/liquidity/batch` (1-100 names). */
|
|
782
|
+
interface LiquidityBatchBody {
|
|
783
|
+
marketHashNames: string[];
|
|
784
|
+
market?: SupportedLiquidityMarket;
|
|
785
|
+
}
|
|
786
|
+
/** `POST /v1/liquidity/batch` — up to 100 full results in one call. */
|
|
787
|
+
interface LiquidityBatchResponse {
|
|
788
|
+
results: LiquidityResponse[];
|
|
789
|
+
notFound: string[];
|
|
790
|
+
requested: number;
|
|
791
|
+
calculatedAt: IsoDateString;
|
|
792
|
+
}
|
|
793
|
+
/** Bulk-map entry. `market_hash_name` and `estimated_sale_time` are snake_case on the wire. */
|
|
794
|
+
interface LiquidityBulkItem {
|
|
795
|
+
market_hash_name: string;
|
|
796
|
+
liquidity: LiquidityLabel;
|
|
797
|
+
estimated_sale_time: string;
|
|
798
|
+
liquidityBadge: LiquidityBadge;
|
|
799
|
+
confidence: LiquidityConfidence;
|
|
800
|
+
score: number | null;
|
|
801
|
+
bestMarketToList: string | null;
|
|
802
|
+
/** Reserved; always `{}` for now. */
|
|
803
|
+
variants: Record<string, never>;
|
|
804
|
+
}
|
|
805
|
+
/** `GET /v1/liquidity/items/manifest` — cheap change-probe; compare `version` before refetching. */
|
|
806
|
+
interface LiquidityBulkManifest {
|
|
807
|
+
/** Snapshot version / ETag. */
|
|
808
|
+
version: string;
|
|
809
|
+
calculatedAt: IsoDateString;
|
|
810
|
+
/** Recompute cadence as an ISO-8601 duration, e.g. `"PT10M"`. */
|
|
811
|
+
cadence: string;
|
|
812
|
+
markets: string[];
|
|
813
|
+
itemCount: number;
|
|
814
|
+
}
|
|
815
|
+
/** `GET /v1/liquidity/items` — Enterprise: whole-catalog map keyed by market_hash_name. */
|
|
816
|
+
interface LiquidityBulkResponse extends LiquidityBulkManifest {
|
|
817
|
+
items: Record<string, LiquidityBulkItem>;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Liquidity & expected time-to-sell, from cross-market order-book depth and
|
|
822
|
+
* sales velocity. The single + summary + batch endpoints are Pro; the bulk map
|
|
823
|
+
* + manifest are Enterprise.
|
|
824
|
+
*/
|
|
825
|
+
declare class LiquidityResource extends BaseResource {
|
|
826
|
+
/** `GET /v1/liquidity/:marketHashName` — full liquidity model for one item. */
|
|
827
|
+
get(marketHashName: string, params?: LiquidityParams, options?: RequestOptions): Promise<LiquidityResponse>;
|
|
828
|
+
/** `GET /v1/liquidity/summary/:marketHashName` — slim badge-only projection. */
|
|
829
|
+
summary(marketHashName: string, params?: LiquidityParams, options?: RequestOptions): Promise<LiquiditySummaryResponse>;
|
|
830
|
+
/** `POST /v1/liquidity/batch` — score up to 100 items in one call. */
|
|
831
|
+
batch(body: LiquidityBatchBody, options?: RequestOptions): Promise<LiquidityBatchResponse>;
|
|
832
|
+
/**
|
|
833
|
+
* `GET /v1/liquidity/items` — Enterprise: the whole-catalog liquidity map,
|
|
834
|
+
* rematerialized every ~10 minutes. Poll {@link manifest} and compare
|
|
835
|
+
* `version` before refetching this heavier payload.
|
|
836
|
+
*/
|
|
837
|
+
bulk(options?: RequestOptions): Promise<LiquidityBulkResponse>;
|
|
838
|
+
/**
|
|
839
|
+
* `GET /v1/liquidity/items/manifest` — Enterprise: a cheap change-probe for
|
|
840
|
+
* the {@link bulk} map (`version`, `calculatedAt`, `cadence`, `markets`,
|
|
841
|
+
* `itemCount`). Refetch the bulk map only when `version` changes.
|
|
842
|
+
*/
|
|
843
|
+
manifest(options?: RequestOptions): Promise<LiquidityBulkManifest>;
|
|
844
|
+
}
|
|
845
|
+
|
|
668
846
|
interface MarketAnalyticsParams {
|
|
669
847
|
markets?: KnownMarket[];
|
|
670
848
|
/** Historical analytics window in hours (1–168, default 24). */
|
|
@@ -705,6 +883,16 @@ declare class MarketAnalyticsResource extends BaseResource {
|
|
|
705
883
|
get(marketHashName: string, params?: MarketAnalyticsParams, options?: RequestOptions): Promise<MarketAnalyticsResponse>;
|
|
706
884
|
}
|
|
707
885
|
|
|
886
|
+
/** Market registry health & integration status. */
|
|
887
|
+
declare class MarketsResource extends BaseResource {
|
|
888
|
+
/**
|
|
889
|
+
* `GET /v1/markets/health` — per-market ingest status, last event time, and
|
|
890
|
+
* listing counts for every integrated market. Returns a plain array of
|
|
891
|
+
* {@link import("../types/markets").MarketHealthRow}.
|
|
892
|
+
*/
|
|
893
|
+
health(options?: RequestOptions): Promise<MarketHealthResponse>;
|
|
894
|
+
}
|
|
895
|
+
|
|
708
896
|
interface NbboParams {
|
|
709
897
|
/** Canonical item id. Provide this or `marketHashName`. */
|
|
710
898
|
id?: string;
|
|
@@ -712,6 +900,30 @@ interface NbboParams {
|
|
|
712
900
|
marketHashName?: string;
|
|
713
901
|
markets?: KnownMarket[];
|
|
714
902
|
}
|
|
903
|
+
/** Fee-aware, executability-ranked best price for one side. Ask `price` is the total a buyer pays; bid `price` is the net a seller receives after fees. */
|
|
904
|
+
interface ExecutionAdjustedBestPrice {
|
|
905
|
+
market: string;
|
|
906
|
+
price: Cents;
|
|
907
|
+
rawPrice: Cents;
|
|
908
|
+
appliedFeeBps: number;
|
|
909
|
+
withdrawalFlatUsdCents?: Cents;
|
|
910
|
+
executability: number;
|
|
911
|
+
updatedAt: IsoDateString;
|
|
912
|
+
isStale: boolean;
|
|
913
|
+
reasons: string[];
|
|
914
|
+
}
|
|
915
|
+
/** Execution-adjusted NBBO block: fee-aware best bid/ask re-ranked by executability. */
|
|
916
|
+
interface ExecutionAdjustedNbbo {
|
|
917
|
+
bestAsk: ExecutionAdjustedBestPrice | null;
|
|
918
|
+
bestBid: ExecutionAdjustedBestPrice | null;
|
|
919
|
+
spreadBps: number | null;
|
|
920
|
+
locked: boolean;
|
|
921
|
+
crossed: boolean;
|
|
922
|
+
executableConfidence: number;
|
|
923
|
+
reasons: string[];
|
|
924
|
+
feeModelVersion: string;
|
|
925
|
+
calculatedAt: IsoDateString;
|
|
926
|
+
}
|
|
715
927
|
/** `GET /v1/nbbo` (camelCase). */
|
|
716
928
|
interface NbboResponse {
|
|
717
929
|
marketHashName: string;
|
|
@@ -725,6 +937,8 @@ interface NbboResponse {
|
|
|
725
937
|
crossed: boolean;
|
|
726
938
|
confidence: number;
|
|
727
939
|
calculatedAt: IsoDateString;
|
|
940
|
+
/** Execution-adjusted "real best market"; null when no quotes. */
|
|
941
|
+
executionAdjusted: ExecutionAdjustedNbbo | null;
|
|
728
942
|
}
|
|
729
943
|
interface NbboDepthParams extends NbboParams {
|
|
730
944
|
/** Aggregated depth levels per side (1–50, default 10). */
|
|
@@ -858,6 +1072,8 @@ declare class SkinpricerClient {
|
|
|
858
1072
|
readonly marketAnalytics: MarketAnalyticsResource;
|
|
859
1073
|
readonly attributePrices: AttributePricesResource;
|
|
860
1074
|
readonly buff163: Buff163Resource;
|
|
1075
|
+
readonly liquidity: LiquidityResource;
|
|
1076
|
+
readonly markets: MarketsResource;
|
|
861
1077
|
private readonly httpClient;
|
|
862
1078
|
constructor(config: ClientConfig);
|
|
863
1079
|
}
|
|
@@ -942,6 +1158,6 @@ declare function chunk<T>(items: readonly T[], size: number): T[][];
|
|
|
942
1158
|
/** Runs `fn` over `items` with at most `limit` concurrent executions, keeping order. */
|
|
943
1159
|
declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
944
1160
|
|
|
945
|
-
declare const VERSION = "0.
|
|
1161
|
+
declare const VERSION = "0.3.0";
|
|
946
1162
|
|
|
947
|
-
export { APIError, ATTRIBUTE_MARKETS, type AggregatePriceData, type AggregationsBatchParams, type AggregationsParams, AggregationsResource, type AllItemsItem, type AllItemsLatestPrice, type AllItemsPriceAggregates, type AllItemsResponse, type ArbitrageFreshness, type ArbitrageOpportunitiesResponse, type ArbitrageOpportunity, type ArbitrageParams, type ArbitrageQuote, ArbitrageResource, type ArbitrageSort, type AttributeBucketDimensions, type AttributeGranularity, type AttributeHistoryBucket, type AttributeHistoryItem, type AttributeHistoryParams, type AttributeHistoryPoint, type AttributeHistoryResponse, type AttributeLatestParams, type AttributeLatestResponse, type AttributeMarket, type AttributePriceBucket, type AttributePriceItem, AttributePricesResource, type AttributeRangeDimension, type AttributeType, type AuthScheme, AuthenticationError, BaseResource, type BestPrice, type Buff163AttributeHistoryResponse, type Buff163AttributeLatestResponse, type Buff163HistoryParams, type Buff163LatestParams, Buff163Resource, type Cents, type ClientConfig, type ClientHooks, ConfigurationError, type CurrentPriceParams, type CurrentPriceResponse, DEFAULT_BASE_URL, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, type ErrorResponseInput, FeatureNotAvailableError, type FormatUsdOptions, type FreshnessResponse, type HistoryListingType, type HistoryListingTypeInput, HistoryResource, type IsoDateString, type ItemMaxOrders, type ItemMinPrices, type ItemPriceListResponse, type ItemSearchParams, ItemsResource, KNOWN_MARKETS, type KnownMarket, type MarketAnalyticsParams, type MarketAnalyticsPoint, MarketAnalyticsResource, type MarketAnalyticsResponse, type MarketFreshness, type MarketHealthStatus, type MarketLatency, type MarketLatencyResponse, type MarketMaxOrder, type MarketMinPrice, type MarketPricePoint, type MarketSeries, type MaxOrdersResponse, type MinPricesResponse, type NbboBestPrice, type NbboDepthLevel, type NbboDepthParams, type NbboDepthQuote, type NbboDepthResponse, type NbboParams, NbboResource, type NbboResponse, NetworkError, NotFoundError, type PaginationMeta, ParseError, PermissionError, type PriceHistoryByMarketResponse, type PriceHistoryInterval, type PriceHistoryParams, type PriceHistoryPoint, type PriceHistoryResponse, type PricingListing, type PricingListingFloatCoverage, type PricingListingFloatSummary, type PricingListingObservedFloatSource, type PricingListingsParams, type PricingListingsResponse, PricingResource, RESPONSE_META, RateLimitError, type RateLimitErrorOptions, type RateLimitInfo, type RateLimitWindow, type RecommendationParams, type RecommendationResponse, RecommendationsResource, type RequestHookContext, type RequestOptions, type ResolvedConfig, type ResponseHookContext, type ResponseMeta, type RetryConfig, type RetryHookContext, type SalesHistoryWindow, ServerError, SkinpricerClient, SkinpricerError, type SkinpricerErrorOptions, StatusResource, TimeoutError, VERSION, ValidationError, type ValidationErrorOptions, type WithMeta, centsToUsd, chunk, errorFromResponse, formatUsd, getMeta, mapWithConcurrency, parseIsoDate, resolveConfig };
|
|
1163
|
+
export { APIError, ATTRIBUTE_MARKETS, type AggregatePriceData, type AggregationsBatchParams, type AggregationsParams, AggregationsResource, type AllItemsItem, type AllItemsLatestPrice, type AllItemsPriceAggregates, type AllItemsResponse, type ArbitrageFreshness, type ArbitrageOpportunitiesResponse, type ArbitrageOpportunity, type ArbitrageParams, type ArbitrageQuote, ArbitrageResource, type ArbitrageSort, type AttributeBucketDimensions, type AttributeGranularity, type AttributeHistoryBucket, type AttributeHistoryItem, type AttributeHistoryParams, type AttributeHistoryPoint, type AttributeHistoryResponse, type AttributeLatestParams, type AttributeLatestResponse, type AttributeMarket, type AttributePriceBucket, type AttributePriceItem, AttributePricesResource, type AttributeRangeDimension, type AttributeType, type AuthScheme, AuthenticationError, BaseResource, type BestPrice, type Buff163AttributeHistoryResponse, type Buff163AttributeLatestResponse, type Buff163HistoryParams, type Buff163LatestParams, Buff163Resource, type Cents, type ClientConfig, type ClientHooks, ConfigurationError, type CurrentPriceParams, type CurrentPriceResponse, DEFAULT_BASE_URL, DEFAULT_PUBLIC_BASE_URL, DEFAULT_RETRY, DEFAULT_TIMEOUT_MS, type ErrorResponseInput, type ExecutionAdjustedBestPrice, type ExecutionAdjustedNbbo, FeatureNotAvailableError, type FormatUsdOptions, type FreshnessResponse, type HistoryListingType, type HistoryListingTypeInput, HistoryResource, type IsoDateString, type ItemMaxOrders, type ItemMinPrices, type ItemPriceListResponse, type ItemSearchParams, ItemsResource, KNOWN_MARKETS, type KnownMarket, LIQUIDITY_BADGES, LIQUIDITY_CONFIDENCE, LIQUIDITY_LABELS, type LiquidityBadge, type LiquidityBatchBody, type LiquidityBatchResponse, type LiquidityBulkItem, type LiquidityBulkManifest, type LiquidityBulkResponse, type LiquidityConfidence, type LiquidityCoverage, type LiquidityLabel, type LiquidityMarketMetric, type LiquidityParams, LiquidityResource, type LiquidityResponse, type LiquiditySummaryResponse, type MarketAnalyticsParams, type MarketAnalyticsPoint, MarketAnalyticsResource, type MarketAnalyticsResponse, type MarketFreshness, type MarketHealthResponse, type MarketHealthRow, type MarketHealthStatus, type MarketLatency, type MarketLatencyResponse, type MarketMaxOrder, type MarketMinPrice, type MarketPricePoint, type MarketRegistryStatus, type MarketSeries, MarketsResource, type MaxOrdersResponse, type MinPricesResponse, type NbboBestPrice, type NbboDepthLevel, type NbboDepthParams, type NbboDepthQuote, type NbboDepthResponse, type NbboParams, NbboResource, type NbboResponse, NetworkError, NotFoundError, type PaginationMeta, ParseError, PermissionError, type PriceHistoryByMarketResponse, type PriceHistoryInterval, type PriceHistoryParams, type PriceHistoryPoint, type PriceHistoryResponse, type PricingListing, type PricingListingFloatCoverage, type PricingListingFloatSummary, type PricingListingObservedFloatSource, type PricingListingsParams, type PricingListingsResponse, PricingResource, RESPONSE_META, RateLimitError, type RateLimitErrorOptions, type RateLimitInfo, type RateLimitWindow, type RecommendationParams, type RecommendationResponse, RecommendationsResource, type RequestHookContext, type RequestOptions, type ResolvedConfig, type ResponseHookContext, type ResponseMeta, type RetryConfig, type RetryHookContext, SUPPORTED_LIQUIDITY_MARKETS, type SalesHistoryWindow, ServerError, SkinpricerClient, SkinpricerError, type SkinpricerErrorOptions, StatusResource, type SupportedLiquidityMarket, TimeoutError, VERSION, ValidationError, type ValidationErrorOptions, type WithMeta, centsToUsd, chunk, errorFromResponse, formatUsd, getMeta, mapWithConcurrency, parseIsoDate, resolveConfig };
|
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.
|
|
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
|
|
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
|
|
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: {
|
|
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
|
|
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: {
|
|
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
|