@skinpricer/sdk 0.3.0 → 0.5.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 CHANGED
@@ -1,5 +1,56 @@
1
1
  # @skinpricer/sdk
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Breaking changes
6
+
7
+ - `ExecutionAdjustedBestPrice.appliedFeeBps` and `withdrawalFlatUsdCents` can be `null`.
8
+ - Typed fixtures for aggregations, market analytics, recommendations, freshness and latency status, and the bulk liquidity map need the new camelCase fields.
9
+ - Earlier SDK versions stop working for NBBO lookups by name on 2027-01-15, when the API rejects `market_hash_name`. Upgrade before then.
10
+
11
+ ### Minor Changes
12
+
13
+ - 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.
14
+ - `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.
15
+ - `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.
16
+ - 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`.
17
+ - `ExecutionAdjustedBestPrice.appliedFeeBps` and `withdrawalFlatUsdCents` can be `null` when the fees are unknown. Handle null before calculating with them.
18
+ - 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.
19
+
20
+ ### Patch Changes
21
+
22
+ - 9253aff: Document the `candidateLimit` range of `arbitrage.opportunities()` as 50–1000. The API rejects values above 1000 with a 400 error.
23
+
24
+ ## 0.4.0
25
+
26
+ ### Breaking changes
27
+
28
+ - `liquidity.bulk()` and `liquidity.manifest()` take request options as their second argument: `bulk({ signal })` becomes `bulk(undefined, { signal })`.
29
+ - `MarketPricePoint.quoteSize` and `totalQuantity` can be `null`.
30
+ - `MarketHealthRow.healthBars` and `freshnessCoveragePct` are required, and history types require `effectiveInterval`.
31
+ - The CS2 liquidity market list replaces `csdeals` with `steamcommunity`.
32
+ - The CS2 client's `liquidity.get("items")` rejects with a `ConfigurationError`; use `liquidity.bulk()` for the whole-catalog map.
33
+
34
+ ### Minor Changes
35
+
36
+ - edb9ed7: - `MarketPricePoint.quoteSize` and `totalQuantity` can be `null` when a source publishes a best bid without its size. Null means unknown, not zero. Handle it before calculating a trade size.
37
+ - Add `sourceUpdatedAt`, `sourceTimeKind`, `sourceAgeSeconds` and `isSourceStale` to `MarketPricePoint`, plus the `SourceTimeKind` type. They describe when the source produced its data and are absent when that is unknown. `fetchedAt` is when a price was last read or confirmed still current, not the age of the data.
38
+ - `MarketHealthRow.healthBars` and `freshnessCoveragePct` are now required, as every response includes them. Both games return 48 half-hour bars covering the trailing 24 hours. CS2 rows can include `catalogCompleteness`.
39
+ - `liquidity.bulk()` and `liquidity.manifest()` accept `{ ifNoneMatch }` and return `null` when the snapshot is unchanged (HTTP 304), like `schema.snapshot()`. Request options are now their second argument: replace `bulk({ signal })` with `bulk(undefined, { signal })`.
40
+ - Add `client.prices.latestAll({ game })` for `GET /v2/prices/latest`, the Enterprise snapshot of every item of one game with each market's ask and bid. It accepts `ifNoneMatch` and returns `null` when the snapshot is unchanged. New exports: `PricesResource`, `LatestPricesParams`, `LatestPricesResponse`, `LatestPriceItem`, `LatestPricePoint`, `LatestPriceAskPoint` and `LatestPriceBidPoint`.
41
+ - Add `originalPriceCents`, `originalCurrency`, `totalOrdersCount`, `orderBookComplete` and `outlier` to `MarketPricePoint`, and `basis` to `AggregatePriceData`. `KNOWN_MARKETS` adds `rapidskins` and `youpin`.
42
+ - 109fced: Add game-scoped CS2 and Rust clients, item schema snapshots and deltas, and updated history, liquidity, and market-health types. Preserve the existing CS2 API methods. Keep public market-health requests keyless and enforce request timeouts while reading response bodies.
43
+
44
+ History types now require effectiveInterval. Market health counts and bars can be null, and the CS2 liquidity market list replaces csdeals with steamcommunity. Consumers with strict fixtures or exhaustive switches should update them to match these response contracts.
45
+
46
+ Arbitrage types now include each quote's priceLevelQuantity, seller-net spread, and fee metadata. Capacity and estimated notional can be null when capacity at the displayed prices is unverified. Handle nullable fields before calculations and update typed fixtures to include the added response fields. The minimum notional still defaults to 1000 cents; positive values require verified capacity, while an explicit zero also includes indicative price pairs.
47
+
48
+ ### Patch Changes
49
+
50
+ - 0f3eff4: Reject empty, `.` and `..` path segments with a `ConfigurationError` before any request is sent. URL parsing resolves those segments, so a call such as `schema.get("..")` previously reached a different endpoint.
51
+
52
+ The CS2 client's `liquidity.get("items")` now rejects with a `ConfigurationError` instead of requesting the whole-catalog map. Use `liquidity.bulk()` for that map.
53
+
3
54
  ## 0.3.0
4
55
 
5
56
  ### Minor Changes
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @skinpricer/sdk
2
2
 
3
3
  Official, fully-typed TypeScript SDK for the [Skinpricer](https://skinpricer.com) pricing API —
4
- real-time and historical CS2 skin market pricing, NBBO, order-book depth, arbitrage,
5
- recommendations, and attribute (float/fade/tag) pricing.
4
+ current and historical CS2 and Rust market pricing, NBBO, order-book depth,
5
+ liquidity, and item schemas. CS2 also supports arbitrage, recommendations, and attribute pricing.
6
6
 
7
7
  - **Fully typed** — every request param and response is typed; responses mirror the API exactly.
8
8
  - **Zero runtime dependencies** — built on the platform `fetch` (Node 18+, Bun, Deno, edge, browsers).
@@ -39,6 +39,143 @@ console.log(centsToUsd(price.aggregate?.minPrice ?? 0)); // 15.5
39
39
  > **Prices are integer USD cents.** Timestamps are ISO-8601 strings. Use the opt-in helpers
40
40
  > `centsToUsd` / `formatUsd` and `parseIsoDate` when you want dollars or `Date`s.
41
41
 
42
+ ## CS2 and Rust
43
+
44
+ Existing calls use the CS2 v1 API. Select a game for the v2 API:
45
+
46
+ ```ts
47
+ const rust = client.forGame("rust");
48
+ const cs2 = client.forGame("cs2");
49
+
50
+ const price = await rust.pricing.get("Tempered AK47");
51
+ const history = await rust.history.byMarket("Tempered AK47", {
52
+ interval: "HOUR_1",
53
+ listingType: "SELL_OFFER",
54
+ });
55
+ const liquidity = await rust.liquidity.get("Tempered AK47", {
56
+ market: "skinport",
57
+ });
58
+ ```
59
+
60
+ Game-scoped clients share authentication, retries, and rate-limit throttling with
61
+ their parent. Every request includes the selected game. Creating a scoped client
62
+ does not change other clients or the default CS2 calls.
63
+
64
+ | Resource | Game-scoped methods for CS2 and Rust |
65
+ | ----------- | ------------------------------------------- |
66
+ | `pricing` | `get`, `listings` |
67
+ | `history` | `get`, `byMarket` |
68
+ | `items` | `search`, `searchEach` |
69
+ | `nbbo` | `get`, `depth` |
70
+ | `liquidity` | `get`, `summary`, `batch` |
71
+ | `schema` | `snapshot`, `get`, `changes`, `changesEach` |
72
+ | `markets` | `health` |
73
+
74
+ Aggregations, arbitrage, recommendations, market analytics, attribute prices,
75
+ BUFF163 attribute endpoints, freshness/latency status, and bulk item/liquidity
76
+ exports remain on the default CS2 client. They are absent from game-scoped clients.
77
+ Plan permissions apply to each endpoint. A game scope does not add features to a plan.
78
+
79
+ Pricing `buyOrders[]` entries can report `quoteSize: null` and `totalQuantity: null`
80
+ when a source publishes a best bid without its size. Null means the quantity is
81
+ unknown, while zero is a reported count. The price is still useful for comparison
82
+ but does not establish executable depth or a trade size.
83
+
84
+ A price point's `fetchedAt` is when the price was last read or confirmed still
85
+ current, so it can be recent while the source's data is older. Where a source
86
+ states when it produced its data, price points add `sourceUpdatedAt`,
87
+ `sourceTimeKind` (`payload`, `last_modified`, `cdn_age` or `none`),
88
+ `sourceAgeSeconds` (the data's age when it was read) and `isSourceStale` (older
89
+ than 30 minutes). Most sources state no such time, so these fields are usually
90
+ absent. Treat an absent value as unknown, not as fresh.
91
+
92
+ CS2 arbitrage `spreadBps` and `spreadCents` describe gross price differences.
93
+ `netSpreadBps` and `estimatedNetCents` account for estimated seller commission;
94
+ withdrawal and transfer costs are excluded. Both `minSpreadBps` and
95
+ `sort: "spreadBps"` use the spread after seller commission. Fee metadata is
96
+ available as `sellerFeeBps`, `feeModelVersion`, and optional `assumedFees`.
97
+
98
+ Each quote's `priceLevelQuantity` describes verified quantity at its displayed
99
+ price, or `null` when unknown. `quoteSize` is the market's reported aggregate
100
+ quantity. Arbitrage results can return `null` for `maxTradableQuantity` and
101
+ `estimatedNotionalCents` when capacity at the displayed prices is unverified.
102
+ Handle those values before calculations or display. `minNotionalCents` defaults
103
+ to `1000`; positive values require verified capacity. Set it to `0` to also
104
+ include indicative price pairs with unknown capacity.
105
+
106
+ History responses include `effectiveInterval`, the actual bucket width of the
107
+ returned data: `10m`, `1h`, or `1d`. It can differ from the requested interval.
108
+ Sell-offer history describes observed asks. Its maximum can include extreme
109
+ listings and is not a fair-value estimate. Sales-history volume describes the
110
+ selected rolling window; summing adjacent points would count overlapping sales.
111
+
112
+ Liquidity may report `INSUFFICIENT_DATA`, with a null score and no numeric sale-time estimate.
113
+ This means there is not enough evidence for an estimate, not that no trades occur.
114
+ Rust market health can also return null counts or null history bars when the source
115
+ does not establish those values. Preserve those nulls instead of displaying zero.
116
+
117
+ ## Item schemas
118
+
119
+ Use item lookups and deltas for small updates. A full snapshot contains the entire
120
+ catalog and can be large.
121
+
122
+ ```ts
123
+ import { getMeta } from "@skinpricer/sdk";
124
+
125
+ const schema = client.forGame("rust").schema;
126
+ const { item } = await schema.get("Tempered AK47");
127
+ const snapshot = await schema.snapshot();
128
+ const etag = getMeta(snapshot)?.headers.get("etag");
129
+
130
+ if (etag) {
131
+ const next = await schema.snapshot({ ifNoneMatch: etag });
132
+ if (next !== null) {
133
+ // Replace your cached snapshot with next.
134
+ }
135
+ }
136
+
137
+ for await (const changed of schema.changesEach({
138
+ since: snapshot.schemaVersion,
139
+ })) {
140
+ // Apply changed to your local catalog.
141
+ }
142
+ ```
143
+
144
+ `schema.snapshot({ ifNoneMatch })` returns `null` for HTTP 304. Delta cursors belong
145
+ to the selected game. Keep the original `since` value while paging, and save the
146
+ returned catalog version only after processing every page.
147
+
148
+ The CS2 client's `liquidity.bulk()` and `liquidity.manifest()` accept the same
149
+ `{ ifNoneMatch }` first argument and also return `null` for HTTP 304. Pass
150
+ request options to them as the second argument.
151
+
152
+ ## All-item prices
153
+
154
+ Enterprise plans can read every item of one game in one call. The method is on the
155
+ default client and takes the game as a parameter.
156
+
157
+ ```ts
158
+ const latest = await client.prices.latestAll({ game: "cs2" });
159
+ const etag = getMeta(latest)?.headers.get("etag");
160
+
161
+ if (etag) {
162
+ const next = await client.prices.latestAll({
163
+ game: "cs2",
164
+ ifNoneMatch: etag,
165
+ });
166
+ if (next !== null) {
167
+ // Replace your cached snapshot with next.
168
+ }
169
+ }
170
+ ```
171
+
172
+ Each item lists every market's ask in `markets` and bid in `buyOrders`, with
173
+ `bestAsk` and `bestBid`. Items without a servable quote are left out. The response
174
+ is large; runtimes with a built-in `fetch` request and decode gzip themselves, so
175
+ the SDK sets no `Accept-Encoding` header. While no current snapshot exists, the API
176
+ answers 503 with `Retry-After`. GET retries wait for it, up to `retry.maxDelayMs`,
177
+ and the final `ServerError` reports it as `rateLimit.retryAfterSeconds`.
178
+
42
179
  ## Configuration
43
180
 
44
181
  ```ts
@@ -55,21 +192,29 @@ const client = new SkinpricerClient({
55
192
 
56
193
  ## Resources
57
194
 
58
- | Namespace | Methods |
59
- | ------------------------ | ---------------------------- |
60
- | `client.pricing` | `get`, `listings` |
61
- | `client.history` | `get`, `byMarket` |
62
- | `client.nbbo` | `get`, `depth` |
63
- | `client.aggregations` | `minPrices`, `maxOrders` |
64
- | `client.items` | `search`, `all` |
65
- | `client.status` | `freshness`, `marketLatency` |
66
- | `client.arbitrage` | `opportunities` |
67
- | `client.recommendations` | `get` |
68
- | `client.marketAnalytics` | `get` |
69
- | `client.attributePrices` | `latest`, `history` |
70
- | `client.buff163` | `latest`, `history` |
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` |
71
208
  | `client.liquidity` | `get`, `summary`, `batch`, `bulk`, `manifest` |
72
- | `client.markets` | `health` |
209
+ | `client.markets` | `health` |
210
+ | `client.schema` | `snapshot`, `get`, `changes`, `changesEach` |
211
+ | `client.prices` | `latestAll` |
212
+
213
+ Aggregations, market analytics, recommendations, freshness/latency status and the
214
+ bulk liquidity map return each field in camelCase (`marketHashName`, `updatedAt`)
215
+ beside a snake_case alias (`market_hash_name`, `updated_at`). The aliases are
216
+ marked `@deprecated`; the API stops sending them on 2027-01-15, so read the
217
+ camelCase names.
73
218
 
74
219
  Every method accepts an optional trailing `RequestOptions` (`{ signal, timeoutMs, retry }`).
75
220
 
@@ -101,6 +246,10 @@ try {
101
246
  }
102
247
  ```
103
248
 
249
+ A `ValidationError` (400) lists each rejected field or parameter in `messages`.
250
+ Errors from an API response carry its `requestId`; include it when you report a
251
+ problem.
252
+
104
253
  ## Rate-limit metadata
105
254
 
106
255
  Methods return the response data directly. Rate-limit headers and status are attached as
@@ -184,6 +333,20 @@ const client = new SkinpricerClient({
184
333
  });
185
334
  ```
186
335
 
336
+ ## Local verification
337
+
338
+ Run the same checks before opening a pull request. Tests use one worker to keep
339
+ memory use bounded. The GitHub workflow runs only when started manually.
340
+
341
+ ```bash
342
+ pnpm install --frozen-lockfile
343
+ pnpm lint
344
+ pnpm typecheck
345
+ pnpm exec vitest run --coverage --maxWorkers=1 --minWorkers=1 --no-file-parallelism
346
+ pnpm build
347
+ pnpm check:package
348
+ ```
349
+
187
350
  ## License
188
351
 
189
352
  MIT