Skip to main content

Price change feed

Keep a copy of /v2/prices/latest current without downloading it again. Take one snapshot, then follow every change the next snapshots make, pushed over a WebSocket or paged over HTTP. Reconnect from where you stopped and miss nothing. Every plan, CS2 and Rust.

wss://pricing.skinpricer.com/v2/prices/streamWebSocket. Sends hello, then replays every link after your cursor, then pushes each new link as its snapshot is published.
GET /v2/prices/latest/changesThe same links over HTTP, at most 20 a call. Call again with head while complete is false.

Both take game (cs2 or rust) and since (your cursor), plus the optional filters below. Send your key in Authorization: ApiKey … or x-api-key, as for any other route. Both need feature:bulk_prices, which every plan includes. A browser WebSocket cannot send either header, so connect from a server.

Snapshot and cursor

  1. Download /v2/prices/latest in its default form, without currency or include, and keep its ETag. That ETag is your cursor. It names the exact body you hold, so a snapshot served from a cache carries its own cursor.
  2. Open the stream with since=<ETag>. The value can be the header as served (W/"…"), quoted, or the bare 32 hex characters.
  3. Apply each link in order, then make its to your cursor. A link's from is the version it applies to, which is your cursor before you apply it.
  4. After a disconnect, reconnect with the cursor you hold. The server replays what you missed, then carries on.

A new snapshot is published about every 30 seconds per game, and each publication is one link. A link that changes nothing you filter for is still sent, because its to is your next cursor.

Applying a link

nameSet the item's name. A name for an item you do not hold adds the item, with no quotes yet. A null name removes the item and everything in it.
bestAsk, bestBidReplace the whole point with value. null means the item has none now.
markets, buyOrdersReplace that market's point with value, or remove it when value is null. These are keyed by market, so their order is not part of the feed.
envelopePresent on a link only when it changed. Replace the snapshot's top-level fields with it: currency, and on CS2 buyerCostModelVersion and buyerTerms.

Each value is the whole point as the snapshot serves it, never a partial update. After the last link of a replay, your copy equals the latest snapshot on every field except four time fields: fetchedAt, updatedAt, sourceUpdatedAt and sourceAgeSeconds. Those keep their value from the point's last change, because a feed that carried them would send about 26 times as many changes. generatedAt and itemCount are not maintained either: take generatedAt from the link, and count itemCount yourself.

Change ids (<chain>:<seq>:<index>) are the same in every replay and under every filter. If you receive a change twice, for example while merging a replay with a live connection, skip it by id. Within one connection, skipping a link whose seq you already applied does the same.

Messages

hellogame, since, head (the cursor after the replay), filter as the server read it, retentionSeconds (900)
linkgame, seq, from, to, generatedAt, changes[], and envelope when it changed
resetgame, reason: cursor_unknown, chain_break or gap

Every message is one JSON text frame. Send nothing: client messages are not read, and one over 4 KB closes the connection. The server pings every 30 seconds, and WebSocket libraries answer the ping for you.

Resets

Links are kept for 15 minutes. A replay is never partial: when your cursor is older than that, unknown, or the chain broke after it, you get a reset instead (reset then close 4009 here, 410 FEED_RESET on /changes). Take a new snapshot and start again from its ETag. On Developer, a new full snapshot inside 60 seconds of the last one answers 429 with Retry-After, so wait that long.

Close codes

4009Reset (after a reset message).
4008Slow consumer: more than 8 MB waited unsent. The server closes instead of skipping a link.
1012The server is restarting.
4003The key is no longer admitted. It is checked again every 5 minutes.
OtherThe network dropped.

A refused handshake answers with an HTTP status instead: 400 for bad parameters, 401 or 403 for the key, 426 without a WebSocket upgrade, 429 when the subscription already holds its open connections or the rate limit is spent, and 503 when the server is full.

Filters

marketsComma-separated market ids, at most 100: markets[] and buyOrders[] changes for those markets only. Turns bestAsk and bestBid off unless best=true.
itemsComma-separated canonicalItemIds, at most 1,000: changes to those items only.
sidesask (markets and bestAsk), bid (buyOrders and bestBid), or ask,bid, the default.
besttrue or false: whether bestAsk and bestBid changes are sent. Default true without markets, false with it.

name changes ignore markets, sides and best, so the items you follow always arrive and leave. When you resume from the same cursor you may narrow a filter, after dropping what it no longer selects from your copy. Widening it needs a new snapshot, since your copy has nothing for what the old filter left out.

Limits

Developer2
Pro5
Enterprise20

Connections count across all keys of a subscription. Opening a connection and each /changes call count as one request toward your per-minute limit; pushed links do not.

Example: a copy that resumes

This client keeps a full CS2 copy in memory, reconnects from its cursor after a drop or a restart, and takes a new snapshot after a reset. Run against production for 10 minutes, with a 60-second outage in the middle, it matched every /v2/prices/latest body published at its cursor.

Node (ws)
// A copy of GET /v2/prices/latest that the change feed keeps current, and
// that resumes after a disconnect. Node 22 or newer, plus `npm i ws`.
import WebSocket from "ws";

const BASE = "https://pricing.skinpricer.com";
const GAME = "cs2";
const headers = { Authorization: `ApiKey ${process.env.SKINPRICER_API_KEY}` };
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const items = new Map(); // canonicalItemId -> item; markets and buyOrders keyed by market
let envelope = {}; // currency, and on CS2 buyerCostModelVersion and buyerTerms
let cursor = null; // the version the copy is at: a snapshot's ETag, then each link's `to`
let seq = -1; // the last link applied
let socket = null;

async function snapshot() {
  for (;;) {
    // The default body: no currency, no include. fetch sends gzip and unpacks it.
    const res = await fetch(`${BASE}/v2/prices/latest?game=${GAME}`, { headers }).catch(() => null);
    if (!res) {
      await sleep(5_000); // the network is down: try again
      continue;
    }
    if (res.status === 429 || res.status === 503) {
      await sleep(Number(res.headers.get("retry-after") ?? 60) * 1000);
      continue;
    }
    if (!res.ok) throw new Error(`snapshot ${res.status}`);
    const { items: rows, itemCount, generatedAt, game, ...rest } = await res.json();
    items.clear();
    for (const item of rows) {
      items.set(item.canonicalItemId, {
        ...item,
        markets: new Map(item.markets.map((point) => [point.market, point])),
        buyOrders: new Map(item.buyOrders.map((point) => [point.market, point])),
      });
    }
    envelope = rest;
    cursor = /[0-9a-f]{32}/.exec(res.headers.get("etag"))[0];
    seq = -1;
    return;
  }
}

function apply(link) {
  if (link.seq <= seq) return; // already applied: a replay can repeat links
  if (link.from !== cursor) throw new Error(`link from ${link.from}, copy at ${cursor}`);
  if (link.envelope) envelope = link.envelope;
  for (const { item: id, field, market, value } of link.changes) {
    const item = items.get(id);
    if (field === "name") {
      if (value === null) items.delete(id); // the item left the snapshot
      else if (item) item.name = value;
      else items.set(id, { name: value, canonicalItemId: id, bestAsk: null, bestBid: null, markets: new Map(), buyOrders: new Map() });
    } else if (field === "bestAsk" || field === "bestBid") item[field] = value;
    else if (value === null) item[field].delete(market);
    else item[field].set(market, value);
  }
  cursor = link.to;
  seq = link.seq;
}

/** Follows the stream from `cursor` until it closes; says why it closed. */
function follow() {
  return new Promise((resolve) => {
    const url = `${BASE.replace(/^http/, "ws")}/v2/prices/stream?game=${GAME}&since=${cursor}`;
    let reset = false;
    socket = new WebSocket(url, { headers });
    socket.on("unexpected-response", (req, res) => {
      req.destroy();
      resolve({ status: res.statusCode });
    });
    socket.on("message", (data) => {
      const message = JSON.parse(data);
      try {
        if (message.type === "link") apply(message);
        if (message.type === "reset") reset = true; // close 4009 follows
      } catch {
        reset = true;
        socket.close();
      }
    });
    socket.on("error", () => {}); // the close that follows says what to do
    socket.on("close", (code) => resolve({ code, reset: reset || code === 4009 }));
  });
}

async function run() {
  await snapshot();
  for (;;) {
    const end = await follow();
    if (end.reset) await snapshot(); // retention passed or the chain broke
    else if (end.code === 4003 || end.status === 401 || end.status === 403) {
      throw new Error("the key is no longer admitted");
    } else await sleep(end.status === 429 ? 30_000 : 1_000); // 4008, 1012, network: resume
  }
}

run();

Usage & licensing

Access to the API and its data is governed by our Terms of Service. You may not resell or redistribute the data, use it to build a competing service, or exceed your plan’s rate limits, and you must attribute SkinPricer as the source wherever the Terms permit you to display it. Abuse may be throttled or suspended.