@skinpricer/sdk 0.2.0 → 0.4.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 +41 -0
- package/README.md +178 -15
- package/dist/index.cjs +504 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +837 -365
- package/dist/index.d.ts +837 -365
- package/dist/index.js +494 -227
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @skinpricer/sdk
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
- `liquidity.bulk()` and `liquidity.manifest()` take request options as their second argument: `bulk({ signal })` becomes `bulk(undefined, { signal })`.
|
|
8
|
+
- `MarketPricePoint.quoteSize` and `totalQuantity` can be `null`.
|
|
9
|
+
- `MarketHealthRow.healthBars` and `freshnessCoveragePct` are required, and history types require `effectiveInterval`.
|
|
10
|
+
- The CS2 liquidity market list replaces `csdeals` with `steamcommunity`.
|
|
11
|
+
- The CS2 client's `liquidity.get("items")` rejects with a `ConfigurationError`; use `liquidity.bulk()` for the whole-catalog map.
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
- 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.
|
|
17
|
+
- `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`.
|
|
18
|
+
- `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 })`.
|
|
19
|
+
- 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`.
|
|
20
|
+
- Add `originalPriceCents`, `originalCurrency`, `totalOrdersCount`, `orderBookComplete` and `outlier` to `MarketPricePoint`, and `basis` to `AggregatePriceData`. `KNOWN_MARKETS` adds `rapidskins` and `youpin`.
|
|
21
|
+
- 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.
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 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.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
## 0.3.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- e114c14: Add liquidity and market-health resources, market-hash-name aggregation lookups, and sync the integrated-market list.
|
|
38
|
+
|
|
39
|
+
- New `liquidity` resource: `client.liquidity.get()`, `.summary()`, `.batch()`, `.bulk()`, and `.manifest()` for cross-market liquidity and expected time-to-sell. Exports `LiquidityResponse`, `LiquiditySummaryResponse`, `LiquidityBatchResponse`, `LiquidityBulkResponse`, `LiquidityBulkManifest`, `LiquidityBulkItem`, `LiquidityMarketMetric`, `LiquidityParams`, `LiquidityBatchBody`, plus the `LIQUIDITY_BADGES`, `LIQUIDITY_CONFIDENCE`, `LIQUIDITY_LABELS`, and `SUPPORTED_LIQUIDITY_MARKETS` constants.
|
|
40
|
+
- New `markets` resource: `client.markets.health()` returns per-market integration status as `MarketHealthRow[]`. It targets the public API host via the new `publicBaseUrl` config (derived from `baseUrl` by default), exported as `DEFAULT_PUBLIC_BASE_URL`.
|
|
41
|
+
- `aggregations.minPrices()` and `aggregations.maxOrders()` now accept `marketHashNames` as an alternative to `ids`.
|
|
42
|
+
- `KNOWN_MARKETS` now lists all 18 integrated markets (adds `avanmarket` and `csdeals`).
|
|
43
|
+
|
|
3
44
|
## 0.2.0
|
|
4
45
|
|
|
5
46
|
### 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
|
-
|
|
5
|
-
recommendations, and attribute
|
|
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,19 +192,23 @@ 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` |
|
|
208
|
+
| `client.liquidity` | `get`, `summary`, `batch`, `bulk`, `manifest` |
|
|
209
|
+
| `client.markets` | `health` |
|
|
210
|
+
| `client.schema` | `snapshot`, `get`, `changes`, `changesEach` |
|
|
211
|
+
| `client.prices` | `latestAll` |
|
|
71
212
|
|
|
72
213
|
Every method accepts an optional trailing `RequestOptions` (`{ signal, timeoutMs, retry }`).
|
|
73
214
|
|
|
@@ -152,6 +293,14 @@ const { items } = await client.aggregations.minPricesAll(thousandsOfIds, {
|
|
|
152
293
|
});
|
|
153
294
|
```
|
|
154
295
|
|
|
296
|
+
`minPrices` / `maxOrders` also accept `marketHashNames` instead of `ids` (provide either one):
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
await client.aggregations.minPrices({
|
|
300
|
+
marketHashNames: ["AK-47 | Redline (Field-Tested)"],
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
155
304
|
**Proactive rate-limit throttling** (opt-in) — when a response reports `X-RateLimit-Remaining: 0`, the client waits for the window to reset instead of firing a request that is guaranteed to 429:
|
|
156
305
|
|
|
157
306
|
```ts
|
|
@@ -174,6 +323,20 @@ const client = new SkinpricerClient({
|
|
|
174
323
|
});
|
|
175
324
|
```
|
|
176
325
|
|
|
326
|
+
## Local verification
|
|
327
|
+
|
|
328
|
+
Run the same checks before opening a pull request. Tests use one worker to keep
|
|
329
|
+
memory use bounded. The GitHub workflow runs only when started manually.
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
pnpm install --frozen-lockfile
|
|
333
|
+
pnpm lint
|
|
334
|
+
pnpm typecheck
|
|
335
|
+
pnpm exec vitest run --coverage --maxWorkers=1 --minWorkers=1 --no-file-parallelism
|
|
336
|
+
pnpm build
|
|
337
|
+
pnpm check:package
|
|
338
|
+
```
|
|
339
|
+
|
|
177
340
|
## License
|
|
178
341
|
|
|
179
342
|
MIT
|