@skinpricer/sdk 0.1.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.
@@ -0,0 +1,947 @@
1
+ interface RateLimitWindow {
2
+ limit: number | null;
3
+ remaining: number | null;
4
+ resetSeconds: number | null;
5
+ }
6
+ interface RateLimitInfo {
7
+ limit: number | null;
8
+ remaining: number | null;
9
+ resetSeconds: number | null;
10
+ month: RateLimitWindow;
11
+ retryAfterSeconds: number | null;
12
+ }
13
+
14
+ interface SkinpricerErrorOptions {
15
+ status?: number;
16
+ code?: string;
17
+ requestId?: string | null;
18
+ responseBody?: unknown;
19
+ rateLimit?: RateLimitInfo;
20
+ cause?: unknown;
21
+ }
22
+ declare class SkinpricerError extends Error {
23
+ readonly status?: number;
24
+ readonly code?: string;
25
+ readonly requestId: string | null;
26
+ readonly responseBody?: unknown;
27
+ readonly rateLimit?: RateLimitInfo;
28
+ constructor(message: string, options?: SkinpricerErrorOptions);
29
+ static isSkinpricerError(value: unknown): value is SkinpricerError;
30
+ }
31
+
32
+ type HttpMethod = "GET" | "POST";
33
+ type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
34
+
35
+ interface RequestHookContext {
36
+ method: HttpMethod;
37
+ url: string;
38
+ attempt: number;
39
+ }
40
+ interface ResponseHookContext extends RequestHookContext {
41
+ status: number;
42
+ rateLimit: RateLimitInfo;
43
+ }
44
+ interface RetryHookContext extends RequestHookContext {
45
+ delayMs: number;
46
+ status: number | null;
47
+ error?: SkinpricerError;
48
+ }
49
+ interface ClientHooks {
50
+ onRequest?(ctx: RequestHookContext): void | Promise<void>;
51
+ onResponse?(ctx: ResponseHookContext): void | Promise<void>;
52
+ onRetry?(ctx: RetryHookContext): void | Promise<void>;
53
+ }
54
+
55
+ type AuthScheme = "Bearer" | "ApiKey";
56
+ interface RetryConfig {
57
+ maxRetries: number;
58
+ baseDelayMs: number;
59
+ maxDelayMs: number;
60
+ retryOnMethods: ReadonlyArray<HttpMethod>;
61
+ respectRetryAfter: boolean;
62
+ }
63
+ interface ClientConfig {
64
+ /** API key, e.g. `sk_live_...`. */
65
+ apiKey: string;
66
+ /** Base URL including the version prefix. */
67
+ baseUrl?: string;
68
+ /** Custom `fetch` implementation. Defaults to the global `fetch`. */
69
+ fetch?: FetchLike;
70
+ /** Per-request timeout in ms. Defaults to 30000; `0` disables it. */
71
+ timeoutMs?: number;
72
+ /** Retry behavior, or `false` to disable. */
73
+ retry?: Partial<RetryConfig> | false;
74
+ /** Extra headers merged into every request. */
75
+ headers?: Record<string, string>;
76
+ /** Authorization scheme. Defaults to `Bearer`. */
77
+ authScheme?: AuthScheme;
78
+ userAgent?: string;
79
+ /** Wait for the rate-limit window to reset when `remaining` hits 0. Off by default. */
80
+ autoThrottle?: boolean;
81
+ /** Hooks invoked around each request. */
82
+ hooks?: ClientHooks;
83
+ }
84
+ interface ResolvedConfig {
85
+ apiKey: string;
86
+ baseUrl: string;
87
+ fetch: FetchLike;
88
+ timeoutMs: number;
89
+ retry: RetryConfig | null;
90
+ headers: Record<string, string>;
91
+ authScheme: AuthScheme;
92
+ userAgent: string;
93
+ autoThrottle: boolean;
94
+ hooks: ClientHooks;
95
+ }
96
+ declare const DEFAULT_BASE_URL = "https://pricing.skinpricer.com/v1";
97
+ declare const DEFAULT_TIMEOUT_MS = 30000;
98
+ declare const DEFAULT_RETRY: RetryConfig;
99
+ declare function resolveConfig(config: ClientConfig): ResolvedConfig;
100
+
101
+ interface ResponseMeta {
102
+ status: number;
103
+ requestId: string | null;
104
+ rateLimit: RateLimitInfo;
105
+ headers: Headers;
106
+ }
107
+ declare const RESPONSE_META: unique symbol;
108
+ type WithMeta<T> = T & {
109
+ readonly [RESPONSE_META]?: ResponseMeta;
110
+ };
111
+ /** Reads the response metadata attached to a result, if present. */
112
+ declare function getMeta(value: unknown): ResponseMeta | undefined;
113
+
114
+ interface HttpResponse<T> {
115
+ data: T;
116
+ meta: ResponseMeta;
117
+ }
118
+
119
+ type QueryScalar = string | number | boolean;
120
+ type QueryValue = QueryScalar | QueryScalar[] | Date | null | undefined;
121
+ type QueryParams = Record<string, QueryValue>;
122
+
123
+ interface BuildRequestInput {
124
+ method: HttpMethod;
125
+ path: string;
126
+ query?: QueryParams;
127
+ body?: unknown;
128
+ }
129
+
130
+ interface RequestOptions {
131
+ signal?: AbortSignal;
132
+ timeoutMs?: number;
133
+ retry?: Partial<RetryConfig> | false;
134
+ }
135
+ declare class HttpClient {
136
+ private readonly config;
137
+ private throttleUntil;
138
+ constructor(config: ResolvedConfig);
139
+ request<T>(input: BuildRequestInput, options?: RequestOptions): Promise<HttpResponse<T>>;
140
+ private recordRateLimit;
141
+ private awaitThrottle;
142
+ }
143
+
144
+ /** Market ids the API integrates. */
145
+ declare const KNOWN_MARKETS: readonly ["skinport", "skindeck", "buff163", "csfloat", "marketcsgo", "cstrade", "dmarket", "itrade", "lis-skins", "swapgg", "whitemarket", "waxpeer", "lootfarm", "tradeit-store", "tradeit-trade", "steamcommunity"];
146
+ /** A known market id, or any other string. */
147
+ type KnownMarket = (typeof KNOWN_MARKETS)[number] | (string & Record<never, never>);
148
+ /** Markets that expose attribute (float/fade/tag) bucket pricing. */
149
+ declare const ATTRIBUTE_MARKETS: readonly ["buff163", "steamcommunity", "marketcsgo", "csfloat", "dmarket"];
150
+ type AttributeMarket = (typeof ATTRIBUTE_MARKETS)[number] | (string & Record<never, never>);
151
+
152
+ /** An ISO-8601 timestamp string. */
153
+ type IsoDateString = string;
154
+ /** A monetary value in integer USD cents. */
155
+ type Cents = number;
156
+ interface MarketPricePoint {
157
+ market: string;
158
+ price: Cents;
159
+ currency: string;
160
+ fetchedAt: IsoDateString;
161
+ ingestedAt?: IsoDateString;
162
+ quoteSize?: number;
163
+ totalQuantity?: number;
164
+ ingestLatencyMs?: number;
165
+ isStale?: boolean;
166
+ }
167
+ interface AggregatePriceData {
168
+ minPrice: Cents | null;
169
+ maxPrice: Cents | null;
170
+ avgPrice: Cents | null;
171
+ medianPrice: Cents | null;
172
+ stdDev: number | null;
173
+ marketCount?: number;
174
+ freshMarketCount?: number;
175
+ listingCount?: number;
176
+ updatedAt: IsoDateString;
177
+ }
178
+ interface NbboBestPrice {
179
+ market: string;
180
+ price: Cents;
181
+ updatedAt: IsoDateString;
182
+ isStale: boolean;
183
+ }
184
+ interface BestPrice {
185
+ market: string;
186
+ price: Cents;
187
+ updated_at: IsoDateString;
188
+ is_stale: boolean;
189
+ }
190
+ interface PaginationMeta {
191
+ perPage: number;
192
+ currentPage: number;
193
+ from: number;
194
+ to: number;
195
+ total: number;
196
+ lastPage: number;
197
+ prevPage: number | null;
198
+ nextPage: number | null;
199
+ }
200
+
201
+ interface AggregationsParams {
202
+ /** Canonical item ids (1–100). */
203
+ ids: string[];
204
+ markets?: KnownMarket[];
205
+ }
206
+ /** Per-market minimum sell price (snake_case). */
207
+ interface MarketMinPrice {
208
+ market_name: string;
209
+ offers: number;
210
+ price: Cents;
211
+ updated_at: IsoDateString;
212
+ is_stale?: boolean;
213
+ ingested_at?: IsoDateString;
214
+ ingest_latency_ms?: number;
215
+ }
216
+ interface ItemMinPrices {
217
+ canonical_item_id: string;
218
+ market_hash_name: string;
219
+ prices: MarketMinPrice[];
220
+ }
221
+ /** `GET /v1/aggregations/min-prices` (snake_case). */
222
+ interface MinPricesResponse {
223
+ items: ItemMinPrices[];
224
+ }
225
+ /** Per-market maximum buy order (snake_case). */
226
+ interface MarketMaxOrder {
227
+ market_name: string;
228
+ offers: number;
229
+ price: Cents;
230
+ updated_at: IsoDateString;
231
+ is_stale: boolean;
232
+ total_quantity?: number;
233
+ ingested_at?: IsoDateString;
234
+ ingest_latency_ms?: number;
235
+ }
236
+ interface ItemMaxOrders {
237
+ canonical_item_id: string;
238
+ market_hash_name: string;
239
+ orders: MarketMaxOrder[];
240
+ }
241
+ /** `GET /v1/aggregations/max-orders` (snake_case). */
242
+ interface MaxOrdersResponse {
243
+ items: ItemMaxOrders[];
244
+ }
245
+
246
+ /** Shared base for resource namespaces. Holds the {@link HttpClient}. */
247
+ declare abstract class BaseResource {
248
+ protected readonly http: HttpClient;
249
+ constructor(http: HttpClient);
250
+ /** Performs a request and returns the data with {@link ResponseMeta} attached. */
251
+ protected call<T>(input: BuildRequestInput, options?: RequestOptions): Promise<T>;
252
+ }
253
+
254
+ interface AggregationsBatchParams {
255
+ markets?: KnownMarket[];
256
+ concurrency?: number;
257
+ }
258
+ declare class AggregationsResource extends BaseResource {
259
+ /** GET /v1/aggregations/min-prices — minimum sell price per market (max 100 ids). */
260
+ minPrices(params: AggregationsParams, options?: RequestOptions): Promise<MinPricesResponse>;
261
+ /** GET /v1/aggregations/max-orders — maximum buy order per market (max 100 ids). */
262
+ maxOrders(params: AggregationsParams, options?: RequestOptions): Promise<MaxOrdersResponse>;
263
+ /** Like `minPrices` but splits more than 100 ids into batches and merges them. */
264
+ minPricesAll(ids: string[], params?: AggregationsBatchParams, options?: RequestOptions): Promise<MinPricesResponse>;
265
+ /** Like `maxOrders` but splits more than 100 ids into batches and merges them. */
266
+ maxOrdersAll(ids: string[], params?: AggregationsBatchParams, options?: RequestOptions): Promise<MaxOrdersResponse>;
267
+ private runBatched;
268
+ }
269
+
270
+ type ArbitrageSort = "estimatedNetCents" | "spreadBps";
271
+ interface ArbitrageParams {
272
+ /** Max opportunities to return (1–100, default 50). */
273
+ limit?: number;
274
+ /** Minimum cross-market spread in basis points (default 200). */
275
+ minSpreadBps?: number;
276
+ /** Minimum estimated buy-side notional in integer USD cents (default 1000). */
277
+ minNotionalCents?: number;
278
+ /** @deprecated Alias for {@link ArbitrageParams.minNotionalCents}. */
279
+ minNotional?: number;
280
+ sort?: ArbitrageSort;
281
+ markets?: KnownMarket[];
282
+ /** Internal shortlist size (50–2000, default 500). */
283
+ candidateLimit?: number;
284
+ }
285
+ interface ArbitrageQuote {
286
+ market: string;
287
+ price: Cents;
288
+ quoteSize: number;
289
+ updatedAt: IsoDateString;
290
+ isStale: boolean;
291
+ }
292
+ interface ArbitrageFreshness {
293
+ buyAgeMs: number;
294
+ sellAgeMs: number;
295
+ }
296
+ interface ArbitrageOpportunity {
297
+ canonicalItemId: string;
298
+ marketHashName: string;
299
+ slug: string;
300
+ imageUrl: string | null;
301
+ buy: ArbitrageQuote;
302
+ sell: ArbitrageQuote;
303
+ spreadBps: number;
304
+ spreadCents: Cents;
305
+ estimatedNetCents: Cents;
306
+ maxTradableQuantity: number;
307
+ estimatedNotionalCents: Cents;
308
+ feeNotes: string;
309
+ freshness: ArbitrageFreshness;
310
+ calculatedAt: IsoDateString;
311
+ }
312
+ /** `GET /v1/arbitrage/opportunities` (camelCase). */
313
+ interface ArbitrageOpportunitiesResponse {
314
+ opportunities: ArbitrageOpportunity[];
315
+ totalCandidates: number;
316
+ calculatedAt: IsoDateString;
317
+ }
318
+
319
+ /** Cross-market arbitrage opportunities. */
320
+ declare class ArbitrageResource extends BaseResource {
321
+ /** `GET /v1/arbitrage/opportunities` — ranked cross-market opportunities. */
322
+ opportunities(params?: ArbitrageParams, options?: RequestOptions): Promise<ArbitrageOpportunitiesResponse>;
323
+ }
324
+
325
+ type AttributeType = "float" | "fade" | "tag";
326
+ type AttributeGranularity = "10m" | "1h" | "1d";
327
+ interface AttributeRangeDimension {
328
+ min: number;
329
+ max: number;
330
+ minInclusive: boolean;
331
+ maxInclusive: boolean;
332
+ }
333
+ interface AttributeBucketDimensions {
334
+ variant: string | null;
335
+ float: AttributeRangeDimension | null;
336
+ fade: AttributeRangeDimension | null;
337
+ pattern: number | null;
338
+ finishCatalog: number | null;
339
+ paintSeed: number | null;
340
+ charmTemplate: number | null;
341
+ stickerScrape: number | null;
342
+ sourceTagId: number | null;
343
+ sourceTagName: string | null;
344
+ nameTag: string | null;
345
+ }
346
+ interface AttributePriceBucket {
347
+ bucketId: string;
348
+ bucketKey: string;
349
+ sourceBucketId: string;
350
+ bucketType: "attribute";
351
+ attributeType: AttributeType;
352
+ attributeTypes: AttributeType[];
353
+ sourceItemId: string;
354
+ dimensions: AttributeBucketDimensions;
355
+ askCents: Cents | null;
356
+ avgAskCents: Cents | null;
357
+ medianAskCents: Cents | null;
358
+ bidCents: Cents | null;
359
+ askListingCount: number | null;
360
+ bidOrderCount: number | null;
361
+ sourceUpdatedAt: IsoDateString;
362
+ collectedAt: IsoDateString;
363
+ }
364
+ interface AttributePriceItem {
365
+ canonicalItemId: string;
366
+ marketHashName: string;
367
+ market: string;
368
+ buckets: AttributePriceBucket[];
369
+ }
370
+ interface AttributeHistoryPoint {
371
+ bucketStart: IsoDateString;
372
+ openAskCents: Cents | null;
373
+ highAskCents: Cents | null;
374
+ lowAskCents: Cents | null;
375
+ closeAskCents: Cents | null;
376
+ avgAskCents: Cents | null;
377
+ closeBidCents: Cents | null;
378
+ askListingCount: number | null;
379
+ bidOrderCount: number | null;
380
+ firstObservedAt: IsoDateString;
381
+ lastObservedAt: IsoDateString;
382
+ }
383
+ interface AttributeHistoryBucket {
384
+ bucketId: string;
385
+ bucketKey: string;
386
+ sourceBucketId: string;
387
+ bucketType: "attribute";
388
+ attributeType: AttributeType;
389
+ attributeTypes: AttributeType[];
390
+ sourceItemId: string;
391
+ dimensions: AttributeBucketDimensions;
392
+ points: AttributeHistoryPoint[];
393
+ }
394
+ interface AttributeHistoryItem {
395
+ canonicalItemId: string;
396
+ marketHashName: string;
397
+ market: string;
398
+ buckets: AttributeHistoryBucket[];
399
+ }
400
+ interface AttributeLatestParams {
401
+ canonicalItemId?: string;
402
+ marketHashName?: string;
403
+ attributes?: AttributeType[];
404
+ /** Max attribute buckets to return (1–1000). */
405
+ limit?: number;
406
+ /** Opaque pagination cursor from a previous `nextCursor`. */
407
+ cursor?: string;
408
+ /** Supported markets to include. */
409
+ markets?: KnownMarket[];
410
+ }
411
+ interface AttributeLatestResponse {
412
+ bucketSchemaVersion: 1;
413
+ markets: string[];
414
+ currency: "USD";
415
+ asOf: IsoDateString;
416
+ items: AttributePriceItem[];
417
+ nextCursor: string | null;
418
+ sourceGaps: string[];
419
+ }
420
+ interface AttributeHistoryParams {
421
+ canonicalItemId?: string;
422
+ marketHashName?: string;
423
+ bucketId?: string;
424
+ bucketIds?: string[];
425
+ attributes?: AttributeType[];
426
+ from?: Date | string;
427
+ to?: Date | string;
428
+ granularity?: AttributeGranularity;
429
+ /** Max history points across all buckets (1–10000). */
430
+ limit?: number;
431
+ markets?: KnownMarket[];
432
+ }
433
+ interface AttributeHistoryResponse {
434
+ bucketSchemaVersion: 1;
435
+ markets: string[];
436
+ currency: "USD";
437
+ granularity: AttributeGranularity;
438
+ items: AttributeHistoryItem[];
439
+ sourceGaps: string[];
440
+ }
441
+ interface Buff163LatestParams {
442
+ canonicalItemId?: string;
443
+ marketHashName?: string;
444
+ attributes?: AttributeType[];
445
+ limit?: number;
446
+ cursor?: string;
447
+ }
448
+ interface Buff163AttributeLatestResponse {
449
+ bucketSchemaVersion: 1;
450
+ market: "buff163";
451
+ currency: "USD";
452
+ asOf: IsoDateString;
453
+ items: AttributePriceItem[];
454
+ nextCursor: string | null;
455
+ sourceGaps: string[];
456
+ }
457
+ interface Buff163HistoryParams {
458
+ canonicalItemId?: string;
459
+ marketHashName?: string;
460
+ bucketId?: string;
461
+ bucketIds?: string[];
462
+ attributes?: AttributeType[];
463
+ from?: Date | string;
464
+ to?: Date | string;
465
+ granularity?: AttributeGranularity;
466
+ limit?: number;
467
+ }
468
+ interface Buff163AttributeHistoryResponse {
469
+ bucketSchemaVersion: 1;
470
+ market: "buff163";
471
+ currency: "USD";
472
+ granularity: AttributeGranularity;
473
+ items: AttributeHistoryItem[];
474
+ sourceGaps: string[];
475
+ }
476
+
477
+ /** Cross-market attribute (float/fade/tag) bucket prices. */
478
+ declare class AttributePricesResource extends BaseResource {
479
+ /** GET /v1/attribute-prices/latest — latest attribute buckets across markets. */
480
+ latest(params?: AttributeLatestParams, options?: RequestOptions): Promise<AttributeLatestResponse>;
481
+ /** GET /v1/attribute-prices/history — OHLC attribute bucket history. */
482
+ history(params?: AttributeHistoryParams, options?: RequestOptions): Promise<AttributeHistoryResponse>;
483
+ /** Async iterator over every latest attribute item, following `nextCursor`. */
484
+ latestEach(params?: AttributeLatestParams, options?: RequestOptions): AsyncGenerator<AttributePriceItem>;
485
+ }
486
+
487
+ /** Buff163-specific attribute bucket prices. */
488
+ declare class Buff163Resource extends BaseResource {
489
+ /** GET /v1/markets/buff163/latest — latest Buff163 attribute buckets. */
490
+ latest(params?: Buff163LatestParams, options?: RequestOptions): Promise<Buff163AttributeLatestResponse>;
491
+ /** GET /v1/markets/buff163/history — OHLC Buff163 attribute bucket history. */
492
+ history(params?: Buff163HistoryParams, options?: RequestOptions): Promise<Buff163AttributeHistoryResponse>;
493
+ /** Async iterator over every latest Buff163 attribute item, following `nextCursor`. */
494
+ latestEach(params?: Buff163LatestParams, options?: RequestOptions): AsyncGenerator<AttributePriceItem>;
495
+ }
496
+
497
+ type HistoryListingType = "SELL_OFFER" | "BUY_ORDER" | "SALE_HISTORY";
498
+ /** Accepted on input; the backend also normalizes `SELL`/`BUY`/`SALES`. */
499
+ type HistoryListingTypeInput = HistoryListingType | "SELL" | "BUY" | "SALES";
500
+ type SalesHistoryWindow = "24h" | "7d" | "30d" | "90d";
501
+ type PriceHistoryInterval = "MINUTE_5" | "MINUTE_15" | "HOUR_1" | "HOUR_6" | "DAY_1";
502
+ interface PriceHistoryParams {
503
+ /** Start of the range (Date or ISO string). */
504
+ from?: Date | string;
505
+ /** End of the range (Date or ISO string). */
506
+ to?: Date | string;
507
+ /** Markets to include; when set, `byMarket` returns per-market series. */
508
+ markets?: KnownMarket[];
509
+ listingType?: HistoryListingTypeInput;
510
+ salesWindow?: SalesHistoryWindow;
511
+ interval?: PriceHistoryInterval;
512
+ }
513
+ interface PriceHistoryPoint {
514
+ timestamp: IsoDateString;
515
+ avgPrice: Cents | null;
516
+ medianPrice: Cents | null;
517
+ minPrice: Cents | null;
518
+ maxPrice: Cents | null;
519
+ listingCount: number | null;
520
+ totalQuantity: number | null;
521
+ volume: number | null;
522
+ bestBidCents: Cents | null;
523
+ bestAskCents: Cents | null;
524
+ spreadBps: number | null;
525
+ }
526
+ /** `GET /v1/pricing/:marketHashName/history` (camelCase). */
527
+ interface PriceHistoryResponse {
528
+ canonicalItemId: string;
529
+ name: string;
530
+ history: PriceHistoryPoint[];
531
+ listingType: HistoryListingType;
532
+ salesWindow: SalesHistoryWindow | null;
533
+ }
534
+ interface MarketSeries {
535
+ market: string;
536
+ history: PriceHistoryPoint[];
537
+ }
538
+ /** `GET /v1/pricing/:marketHashName/history/markets` (camelCase). */
539
+ interface PriceHistoryByMarketResponse {
540
+ canonicalItemId: string;
541
+ name: string;
542
+ series: MarketSeries[];
543
+ listingType: HistoryListingType;
544
+ salesWindow: SalesHistoryWindow | null;
545
+ }
546
+
547
+ /** Historical price series for an item. */
548
+ declare class HistoryResource extends BaseResource {
549
+ /** `GET /v1/pricing/:marketHashName/history` — aggregated time series. */
550
+ get(marketHashName: string, params?: PriceHistoryParams, options?: RequestOptions): Promise<PriceHistoryResponse>;
551
+ /** `GET /v1/pricing/:marketHashName/history/markets` — per-market series. */
552
+ byMarket(marketHashName: string, params?: PriceHistoryParams, options?: RequestOptions): Promise<PriceHistoryByMarketResponse>;
553
+ }
554
+
555
+ interface CurrentPriceParams {
556
+ /** Restrict the response to these market ids. */
557
+ markets?: KnownMarket[];
558
+ }
559
+ /** `GET /v1/pricing/:marketHashName` (camelCase). */
560
+ interface CurrentPriceResponse {
561
+ canonicalItemId: string;
562
+ name: string;
563
+ aggregate?: AggregatePriceData;
564
+ markets: MarketPricePoint[];
565
+ buyOrders?: MarketPricePoint[];
566
+ bestAsk?: NbboBestPrice | null;
567
+ bestBid?: NbboBestPrice | null;
568
+ spreadBps?: number | null;
569
+ marketCount?: number;
570
+ freshMarketCount?: number;
571
+ calculatedAt: IsoDateString;
572
+ }
573
+ interface PricingListingsParams {
574
+ /** Max listing samples to return (1–2000, default 500). */
575
+ limit?: number;
576
+ markets?: KnownMarket[];
577
+ }
578
+ interface PricingListing {
579
+ listingId: string | null;
580
+ market: string;
581
+ price: Cents;
582
+ currency: "USD";
583
+ floatValue: number | null;
584
+ paintSeed: number | null;
585
+ paintIndex: number | null;
586
+ inspectLink: string | null;
587
+ stickers: unknown[];
588
+ isStatTrak: boolean;
589
+ fetchedAt: IsoDateString;
590
+ }
591
+ interface PricingListingFloatCoverage {
592
+ coverage: "none" | "partial" | "complete";
593
+ sampledListings: number;
594
+ listingsWithFloat: number;
595
+ marketsWithFloat: string[];
596
+ marketsWithoutFloat: string[];
597
+ }
598
+ interface PricingListingObservedFloatSource {
599
+ market: string;
600
+ price: Cents;
601
+ fetchedAt: IsoDateString;
602
+ }
603
+ interface PricingListingFloatSummary {
604
+ observed: number;
605
+ itemMin: number | null;
606
+ itemMax: number | null;
607
+ observedSource: PricingListingObservedFloatSource;
608
+ }
609
+ /** `GET /v1/pricing/:marketHashName/listings` (camelCase). */
610
+ interface PricingListingsResponse {
611
+ marketHashName: string;
612
+ canonicalItemId: string;
613
+ totalListings: number;
614
+ sampledListings: number;
615
+ floatCoverage: PricingListingFloatCoverage;
616
+ floatSummary: PricingListingFloatSummary | null;
617
+ listings: PricingListing[];
618
+ calculatedAt: IsoDateString;
619
+ }
620
+
621
+ interface ItemSearchParams {
622
+ /** Case-insensitive contains match on item name. */
623
+ search?: string;
624
+ markets?: KnownMarket[];
625
+ /** 1-based page number (default 1). */
626
+ page?: number;
627
+ /** Items per page (1–100, default 10). */
628
+ perPage?: number;
629
+ }
630
+ /** `GET /v1/items` — paginated (camelCase). */
631
+ interface ItemPriceListResponse {
632
+ data: CurrentPriceResponse[];
633
+ pagination: PaginationMeta;
634
+ }
635
+ interface AllItemsLatestPrice {
636
+ market: string;
637
+ effectiveUsdCents: Cents;
638
+ fetchedAt: IsoDateString;
639
+ originalCurrency: string;
640
+ }
641
+ interface AllItemsPriceAggregates {
642
+ minPrice: Cents | null;
643
+ maxPrice: Cents | null;
644
+ avgPrice: Cents | null;
645
+ medianPrice: Cents | null;
646
+ stdDev: number | null;
647
+ updatedAt: IsoDateString;
648
+ }
649
+ interface AllItemsItem {
650
+ id: string;
651
+ name: string;
652
+ latestPrices: AllItemsLatestPrice[];
653
+ priceAggregates: AllItemsPriceAggregates | null;
654
+ }
655
+ /** `GET /v1/items/all` — a plain array (camelCase). */
656
+ type AllItemsResponse = AllItemsItem[];
657
+
658
+ /** Item discovery / search. */
659
+ declare class ItemsResource extends BaseResource {
660
+ /** GET /v1/items — paginated item search with current pricing. */
661
+ search(params?: ItemSearchParams, options?: RequestOptions): Promise<ItemPriceListResponse>;
662
+ /** GET /v1/items/all — every tracked item with latest prices (capped, unpaginated). */
663
+ all(options?: RequestOptions): Promise<AllItemsResponse>;
664
+ /** Async iterator over every matching item, walking pages. */
665
+ searchEach(params?: ItemSearchParams, options?: RequestOptions): AsyncGenerator<CurrentPriceResponse>;
666
+ }
667
+
668
+ interface MarketAnalyticsParams {
669
+ markets?: KnownMarket[];
670
+ /** Historical analytics window in hours (1–168, default 24). */
671
+ windowHours?: number;
672
+ }
673
+ /** Per-market analytics row (snake_case fields, camelCase `market`). */
674
+ interface MarketAnalyticsPoint {
675
+ market: string;
676
+ current_ask: Cents | null;
677
+ current_bid: Cents | null;
678
+ spread_bps: number | null;
679
+ ask_is_stale: boolean | null;
680
+ bid_is_stale: boolean | null;
681
+ current_listing_count: number | null;
682
+ current_buy_order_count: number | null;
683
+ current_bid_quantity: number | null;
684
+ sell_avg_price: Cents | null;
685
+ sell_min_price: Cents | null;
686
+ sell_max_price: Cents | null;
687
+ sell_avg_listing_count: number | null;
688
+ buy_avg_price: Cents | null;
689
+ buy_max_price: Cents | null;
690
+ buy_avg_order_count: number | null;
691
+ buy_avg_total_quantity: number | null;
692
+ }
693
+ /** `GET /v1/market-analytics/:marketHashName` (snake_case top-level). */
694
+ interface MarketAnalyticsResponse {
695
+ canonical_item_id: string;
696
+ market_hash_name: string;
697
+ window_hours: number;
698
+ markets: MarketAnalyticsPoint[];
699
+ calculated_at: IsoDateString;
700
+ }
701
+
702
+ /** Per-market current + historical analytics for an item. */
703
+ declare class MarketAnalyticsResource extends BaseResource {
704
+ /** `GET /v1/market-analytics/:marketHashName` — per-market analytics rows. */
705
+ get(marketHashName: string, params?: MarketAnalyticsParams, options?: RequestOptions): Promise<MarketAnalyticsResponse>;
706
+ }
707
+
708
+ interface NbboParams {
709
+ /** Canonical item id. Provide this or `marketHashName`. */
710
+ id?: string;
711
+ /** Market hash name. Sent as the `market_hash_name` query param. */
712
+ marketHashName?: string;
713
+ markets?: KnownMarket[];
714
+ }
715
+ /** `GET /v1/nbbo` (camelCase). */
716
+ interface NbboResponse {
717
+ marketHashName: string;
718
+ canonicalItemId: string;
719
+ bestAsk: NbboBestPrice | null;
720
+ bestBid: NbboBestPrice | null;
721
+ spreadBps: number | null;
722
+ marketCount: number;
723
+ freshMarketCount: number;
724
+ locked: boolean;
725
+ crossed: boolean;
726
+ confidence: number;
727
+ calculatedAt: IsoDateString;
728
+ }
729
+ interface NbboDepthParams extends NbboParams {
730
+ /** Aggregated depth levels per side (1–50, default 10). */
731
+ depth?: number;
732
+ }
733
+ interface NbboDepthQuote {
734
+ market: string;
735
+ level: number;
736
+ price: Cents;
737
+ quantity: number;
738
+ ordersCount: number;
739
+ updatedAt: IsoDateString;
740
+ isStale: boolean;
741
+ }
742
+ interface NbboDepthLevel {
743
+ rank: number;
744
+ price: Cents;
745
+ quantity: number;
746
+ ordersCount: number;
747
+ marketCount: number;
748
+ cumulativeQuantity: number;
749
+ updatedAt: IsoDateString;
750
+ isStale: boolean;
751
+ quotes: NbboDepthQuote[];
752
+ }
753
+ /** `GET /v1/nbbo/depth` (camelCase). */
754
+ interface NbboDepthResponse {
755
+ marketHashName: string;
756
+ canonicalItemId: string;
757
+ depth: number;
758
+ marketCount: number;
759
+ asks: NbboDepthLevel[];
760
+ bids: NbboDepthLevel[];
761
+ spreadBps: number | null;
762
+ locked: boolean;
763
+ crossed: boolean;
764
+ calculatedAt: IsoDateString;
765
+ }
766
+
767
+ /** National Best Bid and Offer (top of book) and aggregated depth. */
768
+ declare class NbboResource extends BaseResource {
769
+ /** `GET /v1/nbbo` — best bid/ask across markets. Pass `id` or `marketHashName`. */
770
+ get(params: NbboParams, options?: RequestOptions): Promise<NbboResponse>;
771
+ /** `GET /v1/nbbo/depth` — aggregated order-book depth per side. */
772
+ depth(params: NbboDepthParams, options?: RequestOptions): Promise<NbboDepthResponse>;
773
+ }
774
+
775
+ /** Current cross-market pricing for a single item. */
776
+ declare class PricingResource extends BaseResource {
777
+ /** `GET /v1/pricing/:marketHashName` — full cross-market pricing snapshot. */
778
+ get(marketHashName: string, params?: CurrentPriceParams, options?: RequestOptions): Promise<CurrentPriceResponse>;
779
+ /** `GET /v1/pricing/:marketHashName/listings` — individual listing samples. */
780
+ listings(marketHashName: string, params?: PricingListingsParams, options?: RequestOptions): Promise<PricingListingsResponse>;
781
+ }
782
+
783
+ interface RecommendationParams {
784
+ markets?: KnownMarket[];
785
+ }
786
+ /** `GET /v1/recommendations/:marketHashName` (snake_case). */
787
+ interface RecommendationResponse {
788
+ canonical_item_id: string;
789
+ market_hash_name: string;
790
+ suggested_price: Cents | null;
791
+ strategy: string;
792
+ confidence: number;
793
+ liquidity_score: number;
794
+ unstable_reasons: string[];
795
+ best_ask: BestPrice | null;
796
+ best_bid: BestPrice | null;
797
+ spread_bps: number | null;
798
+ market_count: number;
799
+ fresh_market_count: number;
800
+ listing_count: number;
801
+ buy_order_count: number;
802
+ total_bid_quantity: number;
803
+ calculated_at: IsoDateString;
804
+ }
805
+
806
+ /** Suggested executable price and liquidity signals for an item. */
807
+ declare class RecommendationsResource extends BaseResource {
808
+ /** `GET /v1/recommendations/:marketHashName` — suggested price + confidence. */
809
+ get(marketHashName: string, params?: RecommendationParams, options?: RequestOptions): Promise<RecommendationResponse>;
810
+ }
811
+
812
+ type MarketHealthStatus = "healthy" | "degraded" | "stale";
813
+ interface MarketFreshness {
814
+ market: string;
815
+ delay_seconds: number;
816
+ last_update: IsoDateString;
817
+ status: MarketHealthStatus;
818
+ }
819
+ /** `GET /v1/status/freshness` (snake_case). */
820
+ interface FreshnessResponse {
821
+ markets: MarketFreshness[];
822
+ overall_status: MarketHealthStatus;
823
+ checked_at: IsoDateString;
824
+ }
825
+ interface MarketLatency {
826
+ market: string;
827
+ avg_latency_ms: number;
828
+ p95_latency_ms: number;
829
+ p99_latency_ms: number;
830
+ fetch_count: number;
831
+ error_rate: number;
832
+ slo_breach_rate: number;
833
+ }
834
+ /** `GET /v1/status/market-latency` (snake_case). */
835
+ interface MarketLatencyResponse {
836
+ markets: MarketLatency[];
837
+ window_hours: number;
838
+ measured_at: IsoDateString;
839
+ }
840
+
841
+ /** Pipeline health and latency metrics. */
842
+ declare class StatusResource extends BaseResource {
843
+ /** `GET /v1/status/freshness` — per-market data freshness and overall health. */
844
+ freshness(options?: RequestOptions): Promise<FreshnessResponse>;
845
+ /** `GET /v1/status/market-latency` — fetch-to-ingest latency metrics per market. */
846
+ marketLatency(options?: RequestOptions): Promise<MarketLatencyResponse>;
847
+ }
848
+
849
+ declare class SkinpricerClient {
850
+ readonly pricing: PricingResource;
851
+ readonly history: HistoryResource;
852
+ readonly nbbo: NbboResource;
853
+ readonly aggregations: AggregationsResource;
854
+ readonly items: ItemsResource;
855
+ readonly status: StatusResource;
856
+ readonly arbitrage: ArbitrageResource;
857
+ readonly recommendations: RecommendationsResource;
858
+ readonly marketAnalytics: MarketAnalyticsResource;
859
+ readonly attributePrices: AttributePricesResource;
860
+ readonly buff163: Buff163Resource;
861
+ private readonly httpClient;
862
+ constructor(config: ClientConfig);
863
+ }
864
+
865
+ /** Base class for any error that originates from an HTTP response. */
866
+ declare class APIError extends SkinpricerError {
867
+ }
868
+ interface ValidationErrorOptions extends SkinpricerErrorOptions {
869
+ /** Individual validation messages (NestJS returns `message` as an array on 400). */
870
+ messages?: string[];
871
+ }
872
+ /** 400 Bad Request — request validation failed. */
873
+ declare class ValidationError extends APIError {
874
+ readonly messages: string[];
875
+ constructor(message: string, options?: ValidationErrorOptions);
876
+ }
877
+ /** 401 Unauthorized — missing, malformed, invalid, expired, or revoked API key. */
878
+ declare class AuthenticationError extends APIError {
879
+ }
880
+ /** 403 Forbidden — authenticated but not permitted (e.g. inactive subscription). */
881
+ declare class PermissionError extends APIError {
882
+ }
883
+ /** 403 Forbidden — the current plan does not include the requested feature. */
884
+ declare class FeatureNotAvailableError extends PermissionError {
885
+ }
886
+ /** 404 Not Found — the requested item/resource is not tracked. */
887
+ declare class NotFoundError extends APIError {
888
+ }
889
+ interface RateLimitErrorOptions extends SkinpricerErrorOptions {
890
+ retryAfterSeconds?: number | null;
891
+ limit?: number | null;
892
+ remaining?: number | null;
893
+ resetSeconds?: number | null;
894
+ }
895
+ /** 429 Too Many Requests — minute or monthly quota exceeded. */
896
+ declare class RateLimitError extends APIError {
897
+ /** Seconds to wait before retrying (`Retry-After`). */
898
+ readonly retryAfterSeconds: number | null;
899
+ readonly limit: number | null;
900
+ readonly remaining: number | null;
901
+ readonly resetSeconds: number | null;
902
+ constructor(message: string, options?: RateLimitErrorOptions);
903
+ }
904
+ /** 5xx — the server failed to process the request. */
905
+ declare class ServerError extends APIError {
906
+ }
907
+
908
+ /** The request never produced an HTTP response (DNS, connection, fetch threw). */
909
+ declare class NetworkError extends SkinpricerError {
910
+ }
911
+ /** The request exceeded the configured timeout. */
912
+ declare class TimeoutError extends NetworkError {
913
+ }
914
+ /** The client was constructed or invoked with invalid configuration. */
915
+ declare class ConfigurationError extends SkinpricerError {
916
+ }
917
+ /** A successful (2xx) response body could not be parsed as JSON. */
918
+ declare class ParseError extends SkinpricerError {
919
+ }
920
+
921
+ interface ErrorResponseInput {
922
+ status: number;
923
+ body: unknown;
924
+ meta: ResponseMeta;
925
+ }
926
+ declare function errorFromResponse(input: ErrorResponseInput): SkinpricerError;
927
+
928
+ /** Converts integer USD cents to a USD float. */
929
+ declare function centsToUsd(cents: Cents): number;
930
+ interface FormatUsdOptions {
931
+ currency?: string;
932
+ locale?: string;
933
+ }
934
+ /** Formats integer USD cents as a localized currency string, e.g. `1550` → `$15.50`. */
935
+ declare function formatUsd(cents: Cents, options?: FormatUsdOptions): string;
936
+
937
+ /** Parses an ISO-8601 timestamp string into a `Date`. */
938
+ declare function parseIsoDate(value: IsoDateString): Date;
939
+
940
+ /** Splits items into chunks of at most `size`. */
941
+ declare function chunk<T>(items: readonly T[], size: number): T[][];
942
+ /** Runs `fn` over `items` with at most `limit` concurrent executions, keeping order. */
943
+ declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
944
+
945
+ declare const VERSION = "0.1.0";
946
+
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 };