@skinpricer/sdk 0.4.0 → 0.6.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 +47 -0
- package/README.md +230 -21
- package/dist/index.cjs +600 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +805 -105
- package/dist/index.d.ts +805 -105
- package/dist/index.js +599 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @skinpricer/sdk
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
- The snake_case response fields are gone from the aggregations, market analytics, recommendations, freshness and latency status, and bulk liquidity map types, because the API no longer sends them. Read the camelCase names instead, for example `marketHashName` for `market_hash_name`.
|
|
8
|
+
- `isSourceStale` is gone from `MarketPricePoint` and `LatestPriceBidPoint`, because the API never sent it. Use `sourceAgeSeconds` to judge how old a source's data is.
|
|
9
|
+
- `priceKind` is required on `PriceHistoryResponse` and `PriceHistoryByMarketResponse`, and `MarketSeries` adds the required `fxBasis`: `native` when the market quotes USD, `historical` when each value was converted to USD at the rate when it was observed. The API always sends both, so only typed fixtures need them.
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 98fbdb1: `LiquidityResponse`, from `liquidity.get()` and each `liquidity.batch()` result, adds the optional `buyOrderEstimates`: for CS2, how likely a buy order one cent above each market's best bid is to fill within 1 and 24 hours, from sale history alone. DMarket gives an `estimate`; Steam Community Market gives an `upper_bound`. Each entry is a union on `available`: an available estimate carries `fillProbability`, `evidence`, `confidence` and its cohort's `calibration`, and an unavailable one carries `reason`. The field is absent when the API has no estimates to serve, and always absent for Rust. New exported types: `BuyOrderEstimate`, `AvailableBuyOrderEstimate`, `UnavailableBuyOrderEstimate`, `BuyOrderEstimateMarket`, `BuyOrderEstimateKind`, `BuyOrderEstimateUnavailableReason`, `BuyOrderCohort`, `BuyOrderCalibration`, `BuyOrderEvidence` and `BuyOrderFillProbability`.
|
|
14
|
+
- 778bc4d: Game-scoped `pricing.get()` and `nbbo.get()`, and `prices.latestAll()`, take an optional `currency` (ISO 4217). Absent or `USD`, the response is unchanged. Another currency converts every price from USD at one rate, as an integer in that currency's minor unit, and the response states the rate in `fx`. `LatestPricesResponse.currency` widens from `"USD"` to `Currency`, and the snapshot's `ETag` differs per currency, so keep one `ifNoneMatch` value per currency. The v1 routes of the default client do not convert, so its `pricing.get()` and `nbbo.get()` params do not accept `currency`. New exported types: `PriceFx`, `GameCurrentPriceParams` and `GameNbboParams`. `HistoryFx` extends `PriceFx`.
|
|
15
|
+
- 63693a7: Add `history.batch()` to game-scoped clients for `POST /v2/pricing/history/batch`. It reads the aggregate history of up to 100 items (market hash names, slugs or canonical item ids) in one request and takes the single read's `from`, `to`, `interval`, `listingType`, `salesWindow`, `basis` and `currency`. The response keys `items` and `errors` by the entry as sent; an entry that matches no item (404) or several (409) is listed in `errors` and the others are still served. With a `currency` other than USD, `fx` gives the one rate used. The batch shares the 10,000-point budget of a single read (twice the buckets for `SALE_HISTORY`), takes at most 25 items in 10m buckets, and costs 5 rate-limit units per distinct item.
|
|
16
|
+
- efa63e9: `PriceHistoryPoint` adds the fields the API sends: `netBestBidCents` and `netSpreadBps`, `contributingMarkets` and `observations` on combined `SALE_HISTORY`, and `originalPriceCents` and `originalCurrency` on per-market `SELL_OFFER`. New exported type: `SaleHistoryObservation`.
|
|
17
|
+
|
|
18
|
+
`priceKind` is now required on `PriceHistoryResponse` and `PriceHistoryByMarketResponse`, and `MarketSeries` adds the required `fxBasis`: `native` when the market quotes USD, `historical` when each value was converted to USD at the rate when it was observed, so the series also moves with FX. The API always sends both; typed fixtures need them.
|
|
19
|
+
|
|
20
|
+
- 54e57bb: Add the change feed of `GET /v2/prices/latest`. `prices.changes({ game, since })` reads `GET /v2/prices/latest/changes`, `prices.stream()` opens the WebSocket at `/v2/prices/stream`, and `prices.mirror({ game })` returns a `LatestPricesMirror`: a local copy of the snapshot that `sync()` brings up to date over HTTP and `stream()` keeps current over the WebSocket. The mirror resumes from the last applied link after a disconnect, loads a new snapshot after a reset, skips links it already applied, and takes the `markets`, `items`, `sides` and `best` filters. The client config takes `webSocket` for runtimes without a global `WebSocket`, such as Node.js before 22.
|
|
21
|
+
- 643e2bb: `prices.latestAll()` takes `include: "priceLevels"`, which adds the optional `priceSince`, `previousPrice` and `previousPriceSince` to every `markets[]` and `buyOrders[]` quote of the all-item snapshot. `LatestPriceAskPoint` and `LatestPriceBidPoint` extend `PriceLevel`. Each field is absent when unknown, and always absent without `include`. The body with price levels has its own `ETag`, so keep one `ifNoneMatch` value per currency and `include`. The snapshot's `bestAsk` and `bestBid` do not carry these fields.
|
|
22
|
+
- 5b7d50a: Current price `markets[]`, `buyOrders[]`, `bestAsk` and `bestBid`, and NBBO `bestAsk` and `bestBid`, add the optional `priceSince`, `previousPrice` and `previousPriceSince`: when the current price was first observed on that market and side, and the price level before it. Current price `markets[]` are typed as `MarketAskPricePoint`, which adds the optional `secondBestPrice` and `listingsWithin2Percent` the API sends for CS2 `swapgg` and `itrade` asks. Each field is absent when unknown. The all-item snapshot's `bestAsk` and `bestBid` are typed as `LatestBestPrice`, which does not have these fields. New exported types: `PriceLevel`, `MarketAskPricePoint` and `LatestBestPrice`.
|
|
23
|
+
- 3fa126a: Add `prices.rolling({ game, ifNoneMatch })` for `GET /v2/prices/rolling` (Pro and Enterprise). It downloads one game's rolling statistics file, decompresses the gzip NDJSON and returns `{ etag, windowEnd, receivedThrough, rows }`. Each `PricesRollingRow` is an ask, sales or points row for one item and market, with `windows` keyed `7d` to `90d` (asks) or `7d` to `365d` (sales). Every window has `count`, the native `median` as decimal text, `usdCentsMedian` and `completeness`; a null median is unknown, never `0`. With a matching `ifNoneMatch` the method returns `null` for HTTP 304. Before the first build the API answers 503, which arrives as a `ServerError` with `Retry-After`.
|
|
24
|
+
- 8e06cfe: Remove `isSourceStale` from `MarketPricePoint` and `LatestPriceBidPoint`. The API never sent it, so a read type-checked but always returned `undefined`. Use `sourceAgeSeconds` to judge how old a source's data is.
|
|
25
|
+
- 2423995: Remove the snake_case response fields from the aggregations, market analytics, recommendations, freshness and latency status, and bulk liquidity map types, including `BestPrice.updated_at` and `is_stale`. The API no longer sends them, so a read such as `item.market_hash_name` type-checked but returned `undefined`. Read the camelCase names instead (`marketHashName`, `updatedAt`, `isStale`). Typed fixtures for these responses no longer need the snake_case fields.
|
|
26
|
+
- 8c5a8a8: Add `sales.daily({ game, date, ifNoneMatch })` for `GET /v2/sales/daily` (Pro and Enterprise). It downloads one closed UTC day's sales file, decompresses the gzip NDJSON and returns `{ etag, final, receivedThrough, rows }`, where each row is a `SalesDailyRow`. Counts, medians, means and USD amounts are `null` when unknown, never `0`. With a matching `ifNoneMatch` the method returns `null` for HTTP 304. A non-final file is replaced once by a final build that adds late sales, so keep the ETag and ask again.
|
|
27
|
+
- e41b6f1: `history.get()` takes `basis` for combined `SALE_HISTORY`. On game-scoped clients, `history.get()` and `history.byMarket()` also take `currency`, which converts every price at the one rate given in `fx`. The v1 history routes reject `currency`, so the default client's params do not accept it. `PriceHistoryResponse` adds the fields the API sends: `basis`, `statistic`, `volumeBasis` and `steamWallet` on combined `SALE_HISTORY`, `corrections` when stored history known to be wrong was left out, and `fx`. `PriceHistoryByMarketResponse` adds `corrections` and `fx`. Batch items share `PriceHistoryResponse`, so they carry the same fields. New exported types: `GamePriceHistoryParams`, `HistoryCorrection` and `SteamWalletHistory`.
|
|
28
|
+
|
|
29
|
+
## 0.5.0
|
|
30
|
+
|
|
31
|
+
### Breaking changes
|
|
32
|
+
|
|
33
|
+
- `ExecutionAdjustedBestPrice.appliedFeeBps` and `withdrawalFlatUsdCents` can be `null`.
|
|
34
|
+
- Typed fixtures for aggregations, market analytics, recommendations, freshness and latency status, and the bulk liquidity map need the new camelCase fields.
|
|
35
|
+
- Earlier SDK versions stop working for NBBO lookups by name on 2027-01-15, when the API rejects `market_hash_name`. Upgrade before then.
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 8364e62: - Add the camelCase name beside every snake_case response field on aggregations, market analytics, recommendations, freshness and latency status, and the bulk liquidity map, for example `marketHashName` beside `market_hash_name` and `updatedAt` beside `updated_at`. The snake_case fields are marked `@deprecated`. The API stops sending them on 2027-01-15, so switch reads to the camelCase names before then. Typed fixtures for these responses need the camelCase fields.
|
|
40
|
+
- `nbbo.get()` and `nbbo.depth()` send `marketHashName` instead of the deprecated `market_hash_name` query parameter, which the API rejects with a 400 error from 2027-01-15. Earlier SDK versions stop working for NBBO lookups by name on that date.
|
|
41
|
+
- `ValidationError.messages` lists the rejected fields and parameters from the error body's `details`, and the error message includes them. Errors take `requestId` from the response body when the `X-Request-Id` header is missing.
|
|
42
|
+
- Add the price-meaning fields: `priceKind` and `purchasable` on quotes and best prices, `valueKind` on bids, `sellBasis` on market analytics and sell-offer history series, `priceKind` on history responses and aggregates, `suggestedPriceKind` on recommendations, and `feeStatus` and `feeModelVersion` on execution-adjusted NBBO quotes. New exported types: `QuotePriceKind`, `ValueKind`, `SellBasis`, `FeeStatus` and `HistoryPriceKind`.
|
|
43
|
+
- `ExecutionAdjustedBestPrice.appliedFeeBps` and `withdrawalFlatUsdCents` can be `null` when the fees are unknown. Handle null before calculating with them.
|
|
44
|
+
- 038b323: Add `bestMarketToListPayout` to `LiquidityResponse`, `LiquiditySummaryResponse` and `LiquidityBulkItem`, plus the `LiquidityPayout` type. It says what `bestMarketToList` pays the seller: `cash`, `wallet`, `bot_rate` or `unknown`, and is null exactly when `bestMarketToList` is null. `wallet` means Steam Community Market, which pays Steam Wallet funds that cannot be withdrawn. Check it before treating the best market as a cash exit.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 9253aff: Document the `candidateLimit` range of `arbitrage.opportunities()` as 50–1000. The API rejects values above 1000 with a 400 error.
|
|
49
|
+
|
|
3
50
|
## 0.4.0
|
|
4
51
|
|
|
5
52
|
### Breaking changes
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ does not change other clients or the default CS2 calls.
|
|
|
64
64
|
| Resource | Game-scoped methods for CS2 and Rust |
|
|
65
65
|
| ----------- | ------------------------------------------- |
|
|
66
66
|
| `pricing` | `get`, `listings` |
|
|
67
|
-
| `history` | `get`, `byMarket`
|
|
67
|
+
| `history` | `get`, `byMarket`, `batch` |
|
|
68
68
|
| `items` | `search`, `searchEach` |
|
|
69
69
|
| `nbbo` | `get`, `depth` |
|
|
70
70
|
| `liquidity` | `get`, `summary`, `batch` |
|
|
@@ -76,6 +76,26 @@ BUFF163 attribute endpoints, freshness/latency status, and bulk item/liquidity
|
|
|
76
76
|
exports remain on the default CS2 client. They are absent from game-scoped clients.
|
|
77
77
|
Plan permissions apply to each endpoint. A game scope does not add features to a plan.
|
|
78
78
|
|
|
79
|
+
### Prices in another currency
|
|
80
|
+
|
|
81
|
+
Game-scoped `pricing.get`, `nbbo.get`, `history.get`, `history.byMarket` and
|
|
82
|
+
`history.batch`, and `prices.latestAll`, take an optional `currency` (ISO 4217,
|
|
83
|
+
such as `"EUR"`). Without it, or with `"USD"`, prices are USD cents and the response
|
|
84
|
+
has no `fx`. With another currency, every price is an integer in that currency's
|
|
85
|
+
minor unit, converted from USD at the one rate the response gives in `fx`:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const price = await cs2.pricing.get("AK-47 | Redline (Field-Tested)", {
|
|
89
|
+
currency: "EUR",
|
|
90
|
+
});
|
|
91
|
+
price.fx; // { base: "USD", quote: "EUR", rate: 0.9127, minorUnitDigits: 2, ... }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`minorUnitDigits` is 2 for most currencies, 0 for JPY, KRW, VND and CLP, and 3 for
|
|
95
|
+
KWD. Fields named in USD, such as `withdrawalFlatUsdCents`, stay USD cents, and
|
|
96
|
+
`originalPriceCents` keeps the venue's own amount. The SDK does not convert prices
|
|
97
|
+
itself. The default client's v1 routes do not take `currency`.
|
|
98
|
+
|
|
79
99
|
Pricing `buyOrders[]` entries can report `quoteSize: null` and `totalQuantity: null`
|
|
80
100
|
when a source publishes a best bid without its size. Null means the quantity is
|
|
81
101
|
unknown, while zero is a reported count. The price is still useful for comparison
|
|
@@ -85,9 +105,19 @@ A price point's `fetchedAt` is when the price was last read or confirmed still
|
|
|
85
105
|
current, so it can be recent while the source's data is older. Where a source
|
|
86
106
|
states when it produced its data, price points add `sourceUpdatedAt`,
|
|
87
107
|
`sourceTimeKind` (`payload`, `last_modified`, `cdn_age` or `none`),
|
|
88
|
-
`sourceAgeSeconds` (the data's age when it was read)
|
|
89
|
-
|
|
90
|
-
absent. Treat an absent value as unknown, not as fresh.
|
|
108
|
+
and `sourceAgeSeconds` (the data's age when it was read). Use `sourceAgeSeconds`
|
|
109
|
+
to judge how old the source's data is. Most sources state no such time, so these
|
|
110
|
+
fields are usually absent. Treat an absent value as unknown, not as fresh.
|
|
111
|
+
|
|
112
|
+
Current price `markets[]`, `buyOrders[]`, `bestAsk` and `bestBid`, and NBBO
|
|
113
|
+
`bestAsk` and `bestBid`, can add `priceSince`, when the price was first observed
|
|
114
|
+
on that market and side, with `previousPrice` and `previousPriceSince` for the
|
|
115
|
+
level before it. `priceSince` is the start of the current price level, not the
|
|
116
|
+
listing time, and its resolution is the observation cadence. CS2 `swapgg` and
|
|
117
|
+
`itrade` asks also add `secondBestPrice` and `listingsWithin2Percent`, the next
|
|
118
|
+
listing and the listings priced at most 2% above the ask. Each field is absent
|
|
119
|
+
when unknown. `prices.latestAll` returns the first three on `markets[]` and
|
|
120
|
+
`buyOrders[]` only with `include: "priceLevels"`.
|
|
91
121
|
|
|
92
122
|
CS2 arbitrage `spreadBps` and `spreadCents` describe gross price differences.
|
|
93
123
|
`netSpreadBps` and `estimatedNetCents` account for estimated seller commission;
|
|
@@ -103,17 +133,50 @@ Handle those values before calculations or display. `minNotionalCents` defaults
|
|
|
103
133
|
to `1000`; positive values require verified capacity. Set it to `0` to also
|
|
104
134
|
include indicative price pairs with unknown capacity.
|
|
105
135
|
|
|
136
|
+
`history.batch` reads the aggregate history of up to 100 items in one request:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const batch = await cs2.history.batch({
|
|
140
|
+
items: ["AK-47 | Redline (Field-Tested)", "awp-asiimov-field-tested"],
|
|
141
|
+
from: "2026-10-29T00:00:00Z",
|
|
142
|
+
to: "2026-11-28T00:00:00Z",
|
|
143
|
+
interval: "DAY_1",
|
|
144
|
+
});
|
|
145
|
+
batch.items["awp-asiimov-field-tested"]?.history; // same body as history.get
|
|
146
|
+
batch.errors; // entries that matched no item (404) or several (409)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Each entry is a market hash name, a slug or a canonical item id, and the response
|
|
150
|
+
keys `items` and `errors` by the entry as sent. The batch shares the single read's
|
|
151
|
+
10,000-point budget: items x buckets, counting both ends, and twice that for
|
|
152
|
+
`SALE_HISTORY`. 100 items fit 30 days of `DAY_1`, or 4 days of `HOUR_1` for asks or
|
|
153
|
+
bids. A batch in
|
|
154
|
+
10m buckets takes at most 25 items. The API rejects a larger batch with a 400
|
|
155
|
+
error. Each distinct item costs 5 rate-limit units, as a single history read does.
|
|
156
|
+
With `currency`, every item is converted at the one rate given in `fx`.
|
|
157
|
+
|
|
106
158
|
History responses include `effectiveInterval`, the actual bucket width of the
|
|
107
159
|
returned data: `10m`, `1h`, or `1d`. It can differ from the requested interval.
|
|
108
160
|
Sell-offer history describes observed asks. Its maximum can include extreme
|
|
109
161
|
listings and is not a fair-value estimate. Sales-history volume describes the
|
|
110
162
|
selected rolling window; summing adjacent points would count overlapping sales.
|
|
163
|
+
Combined `SALE_HISTORY` covers cash venues only and says so in `basis`,
|
|
164
|
+
`statistic` and `volumeBasis`. Steam Community Market wallet sales, gross of Steam
|
|
165
|
+
fees, are in `steamWallet` instead. When a response leaves out stored history known
|
|
166
|
+
to be wrong, `corrections` lists each market and range it left out. Game-scoped
|
|
167
|
+
`history.get` and `history.byMarket` take `currency` and return the rate in `fx`.
|
|
111
168
|
|
|
112
169
|
Liquidity may report `INSUFFICIENT_DATA`, with a null score and no numeric sale-time estimate.
|
|
113
170
|
This means there is not enough evidence for an estimate, not that no trades occur.
|
|
114
171
|
Rust market health can also return null counts or null history bars when the source
|
|
115
172
|
does not establish those values. Preserve those nulls instead of displaying zero.
|
|
116
173
|
|
|
174
|
+
CS2 liquidity results can include `buyOrderEstimates`, one entry per market, with the
|
|
175
|
+
chance that a buy order one cent above the best bid fills within 1 and 24 hours.
|
|
176
|
+
Check `available` first. Steam entries are upper bounds (`kind: "upper_bound"`),
|
|
177
|
+
because Steam fills the oldest eligible buy order first. The field is absent when no
|
|
178
|
+
estimates are being served.
|
|
179
|
+
|
|
117
180
|
## Item schemas
|
|
118
181
|
|
|
119
182
|
Use item lookups and deltas for small updates. A full snapshot contains the entire
|
|
@@ -175,6 +238,142 @@ is large; runtimes with a built-in `fetch` request and decode gzip themselves, s
|
|
|
175
238
|
the SDK sets no `Accept-Encoding` header. While no current snapshot exists, the API
|
|
176
239
|
answers 503 with `Retry-After`. GET retries wait for it, up to `retry.maxDelayMs`,
|
|
177
240
|
and the final `ServerError` reports it as `rateLimit.retryAfterSeconds`.
|
|
241
|
+
`latestAll({ game, currency })` serves the snapshot in another currency, with its
|
|
242
|
+
own `ETag` for each currency, so keep one `ifNoneMatch` value per currency.
|
|
243
|
+
`latestAll({ game, include: "priceLevels" })` adds `priceSince`, `previousPrice`
|
|
244
|
+
and `previousPriceSince` to every `markets[]` and `buyOrders[]` quote, but not to
|
|
245
|
+
`bestAsk` or `bestBid`. That body is up to twice as large gzipped and has its own
|
|
246
|
+
`ETag`, so keep one `ifNoneMatch` value per currency and `include`. The first such
|
|
247
|
+
request after a quiet period can take up to 30 seconds.
|
|
248
|
+
|
|
249
|
+
### Keeping a copy current
|
|
250
|
+
|
|
251
|
+
A mirror holds one game's snapshot and applies the change feed to it, so you
|
|
252
|
+
download the full snapshot once and then only what changed.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
const mirror = client.prices.mirror({ game: "cs2" });
|
|
256
|
+
|
|
257
|
+
// Over HTTP: the first call loads a snapshot, later calls apply the new links.
|
|
258
|
+
await mirror.sync();
|
|
259
|
+
mirror.item("<canonicalItemId>")?.markets;
|
|
260
|
+
|
|
261
|
+
// Or pushed over a WebSocket until the signal aborts.
|
|
262
|
+
const controller = new AbortController();
|
|
263
|
+
await mirror.stream({
|
|
264
|
+
signal: controller.signal,
|
|
265
|
+
onLink: (link) => {
|
|
266
|
+
// link.changes lists the fields replaced since the previous snapshot.
|
|
267
|
+
},
|
|
268
|
+
onSnapshot: (reason) => {
|
|
269
|
+
// A new snapshot replaced the copy, after a reset when reason is set.
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
After each link the copy equals the published snapshot on every field except
|
|
275
|
+
`fetchedAt`, `updatedAt`, `sourceUpdatedAt` and `sourceAgeSeconds`, which keep
|
|
276
|
+
their value as of the point's last change. The feed does not keep the order of
|
|
277
|
+
`markets` and `buyOrders`: a replaced point keeps its place and a new one is
|
|
278
|
+
appended. `toSnapshot()` returns the copy with items ordered by `canonicalItemId`.
|
|
279
|
+
|
|
280
|
+
The feed keeps 15 minutes of links. When the cursor is older, or the chain broke
|
|
281
|
+
after it, the feed answers with a reset and the mirror loads a new snapshot.
|
|
282
|
+
`stream()` reconnects from the last applied link after a disconnect and rejects
|
|
283
|
+
with a `PermissionError` when the key is no longer admitted.
|
|
284
|
+
|
|
285
|
+
Pass `markets`, `items` (canonicalItemIds, at most 1,000), `sides` (`ask`, `bid`)
|
|
286
|
+
or `best` to `mirror()` to follow part of the snapshot. The copy then holds only
|
|
287
|
+
what the filter selects, and `bestAsk` and `bestBid` are null when the filter does
|
|
288
|
+
not send their changes; `best` is off by default with `markets`. To widen a filter,
|
|
289
|
+
create a new mirror.
|
|
290
|
+
|
|
291
|
+
`prices.changes()` and `prices.stream()` are the endpoints underneath, for your
|
|
292
|
+
own transport: apply their links with `mirror.load(snapshot, etag)` and
|
|
293
|
+
`mirror.apply(link)`. The feed follows the default snapshot, read without
|
|
294
|
+
`currency` or `include`. `stream()` uses the global `WebSocket`, which Node.js 22 and
|
|
295
|
+
later provide. On older runtimes pass a factory, for example with the
|
|
296
|
+
[ws](https://github.com/websockets/ws) package:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
import WebSocket from "ws";
|
|
300
|
+
|
|
301
|
+
const client = new SkinpricerClient({
|
|
302
|
+
apiKey: "sk_live_...",
|
|
303
|
+
webSocket: (url, headers) => new WebSocket(url, { headers }),
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Browsers cannot send the key on a WebSocket, so stream from a server.
|
|
308
|
+
|
|
309
|
+
## Daily sales file
|
|
310
|
+
|
|
311
|
+
Pro and Enterprise plans can download every item's observed sales for one closed
|
|
312
|
+
UTC day. `sales.daily()` decompresses the gzip NDJSON file and returns its rows.
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
const day = await client.sales.daily({ game: "cs2", date: "2026-11-26" });
|
|
316
|
+
|
|
317
|
+
for (const row of day.rows) {
|
|
318
|
+
// row.count is null when the market did not state one. That is not zero.
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (!day.final && day.etag) {
|
|
322
|
+
const update = await client.sales.daily({
|
|
323
|
+
game: "cs2",
|
|
324
|
+
date: "2026-11-26",
|
|
325
|
+
ifNoneMatch: day.etag,
|
|
326
|
+
});
|
|
327
|
+
if (update !== null) {
|
|
328
|
+
// The final build replaced the provisional file.
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
A day is first built provisional at about 06:10 UTC the next day (`final: false`)
|
|
334
|
+
and rebuilt once as final at about 18:10 UTC the day after, with the sales that
|
|
335
|
+
arrived late.
|
|
336
|
+
`receivedThrough` is the archive receipt time the file covers. Sales rows
|
|
337
|
+
(`evidence: "sales"`) count observed sales; points rows (`evidence: "points"`) carry
|
|
338
|
+
a market's own statistics. Rows from different markets are never added together,
|
|
339
|
+
and an item or market without a row is unknown for the day. Files are kept for 31
|
|
340
|
+
days; an older or future date is a `NotFoundError` or `ValidationError`.
|
|
341
|
+
|
|
342
|
+
## Rolling statistics file
|
|
343
|
+
|
|
344
|
+
Pro and Enterprise plans can download one file per game with every item's 7, 30
|
|
345
|
+
and 90-day ask medians and 7, 30, 90, 180 and 365-day sale medians, per market.
|
|
346
|
+
`prices.rolling()` decompresses the gzip NDJSON file and returns its rows.
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
const file = await client.prices.rolling({ game: "cs2" });
|
|
350
|
+
|
|
351
|
+
for (const row of file.rows) {
|
|
352
|
+
const week = row.windows["7d"];
|
|
353
|
+
// week.median is null when the window has no value. That is not zero.
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const update = await client.prices.rolling({
|
|
357
|
+
game: "cs2",
|
|
358
|
+
ifNoneMatch: file.etag ?? undefined,
|
|
359
|
+
});
|
|
360
|
+
if (update !== null) {
|
|
361
|
+
// A newer build replaced the file.
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Every window ends with `windowEnd`, the last closed UTC day; the file is rebuilt
|
|
366
|
+
at about 06:40 UTC daily. Ask rows (`kind: "ask"`) take the median of each day's
|
|
367
|
+
lowest ask on the market, and `count` is the days that had one. Sales rows
|
|
368
|
+
(`evidence: "sales"`) take the exact median of the market's sales in its
|
|
369
|
+
`currency`; points rows (`evidence: "points"`) take the unit-weighted median of the
|
|
370
|
+
market's own price history, and `count` is units. `median` is decimal text in the
|
|
371
|
+
row's `currency`, and `usdCentsMedian` converts it at the rate of `fxDate`, or is
|
|
372
|
+
null without one. `completeness` says whether a window is `complete`, a
|
|
373
|
+
`lower_bound` because markets do not report every sale, or a `partial_window` that
|
|
374
|
+
starts before the market was captured. Rows from different markets or evidence are
|
|
375
|
+
never combined, and an item or market without a row is unknown. Before the first
|
|
376
|
+
build the API answers 503 with `Retry-After`, which arrives as a `ServerError`.
|
|
178
377
|
|
|
179
378
|
## Configuration
|
|
180
379
|
|
|
@@ -187,28 +386,34 @@ const client = new SkinpricerClient({
|
|
|
187
386
|
retry: { maxRetries: 2 }, // or `false` to disable
|
|
188
387
|
headers: { "X-Tenant": "acme" }, // extra headers (Authorization is not overridable)
|
|
189
388
|
// fetch: customFetch, // bring your own fetch
|
|
389
|
+
// webSocket: (url, headers) => new WebSocket(url, { headers }), // for prices.stream()
|
|
190
390
|
});
|
|
191
391
|
```
|
|
192
392
|
|
|
193
393
|
## Resources
|
|
194
394
|
|
|
195
|
-
| Namespace | Methods
|
|
196
|
-
| ------------------------ |
|
|
197
|
-
| `client.pricing` | `get`, `listings`
|
|
198
|
-
| `client.history` | `get`, `byMarket`
|
|
199
|
-
| `client.nbbo` | `get`, `depth`
|
|
200
|
-
| `client.aggregations` | `minPrices`, `maxOrders`
|
|
201
|
-
| `client.items` | `search`, `all`
|
|
202
|
-
| `client.status` | `freshness`, `marketLatency`
|
|
203
|
-
| `client.arbitrage` | `opportunities`
|
|
204
|
-
| `client.recommendations` | `get`
|
|
205
|
-
| `client.marketAnalytics` | `get`
|
|
206
|
-
| `client.attributePrices` | `latest`, `history`
|
|
207
|
-
| `client.buff163` | `latest`, `history`
|
|
208
|
-
| `client.liquidity` | `get`, `summary`, `batch`, `bulk`, `manifest`
|
|
209
|
-
| `client.markets` | `health`
|
|
210
|
-
| `client.schema` | `snapshot`, `get`, `changes`, `changesEach`
|
|
211
|
-
| `client.prices` | `latestAll`
|
|
395
|
+
| Namespace | Methods |
|
|
396
|
+
| ------------------------ | ----------------------------------------------------- |
|
|
397
|
+
| `client.pricing` | `get`, `listings` |
|
|
398
|
+
| `client.history` | `get`, `byMarket` |
|
|
399
|
+
| `client.nbbo` | `get`, `depth` |
|
|
400
|
+
| `client.aggregations` | `minPrices`, `maxOrders` |
|
|
401
|
+
| `client.items` | `search`, `all` |
|
|
402
|
+
| `client.status` | `freshness`, `marketLatency` |
|
|
403
|
+
| `client.arbitrage` | `opportunities` |
|
|
404
|
+
| `client.recommendations` | `get` |
|
|
405
|
+
| `client.marketAnalytics` | `get` |
|
|
406
|
+
| `client.attributePrices` | `latest`, `history` |
|
|
407
|
+
| `client.buff163` | `latest`, `history` |
|
|
408
|
+
| `client.liquidity` | `get`, `summary`, `batch`, `bulk`, `manifest` |
|
|
409
|
+
| `client.markets` | `health` |
|
|
410
|
+
| `client.schema` | `snapshot`, `get`, `changes`, `changesEach` |
|
|
411
|
+
| `client.prices` | `latestAll`, `rolling`, `changes`, `stream`, `mirror` |
|
|
412
|
+
| `client.sales` | `daily` |
|
|
413
|
+
|
|
414
|
+
Response fields are camelCase (`marketHashName`, `updatedAt`). The API no longer
|
|
415
|
+
sends the snake_case aliases (`market_hash_name`, `updated_at`) that SDK 0.5.0
|
|
416
|
+
still typed.
|
|
212
417
|
|
|
213
418
|
Every method accepts an optional trailing `RequestOptions` (`{ signal, timeoutMs, retry }`).
|
|
214
419
|
|
|
@@ -240,6 +445,10 @@ try {
|
|
|
240
445
|
}
|
|
241
446
|
```
|
|
242
447
|
|
|
448
|
+
A `ValidationError` (400) lists each rejected field or parameter in `messages`.
|
|
449
|
+
Errors from an API response carry its `requestId`; include it when you report a
|
|
450
|
+
problem.
|
|
451
|
+
|
|
243
452
|
## Rate-limit metadata
|
|
244
453
|
|
|
245
454
|
Methods return the response data directly. Rate-limit headers and status are attached as
|