Catalog stream
Receive changes to the authenticated account's catalog and resume from an opaque cursor.
/v1/catalog/streamKeep your server-side catalog up to date with Server-Sent Events (SSE). Updates use the same account visibility and prices as the catalog snapshot.
Sync and resume
- Read GET /v1/catalog. Store the complete item set and its
cursor(also returned inX-Catalog-Cursor). - Open the stream with
?cursor=<snapshot-cursor>. Omitting the cursor starts at the current head. - Apply updates and removals by item
id. Make those writes idempotent and persist the eventidonly after the change is applied. - Reconnect with that ID in
Last-Event-ID, which takes precedence over the query. Treat cursors as opaque strings. - On
resync, close the stream and fetchGET /v1/catalog?minCursor=<minCursor>. Replace your local snapshot, then reconnect using its cursor.
Events
| Event | JSON data |
|---|---|
items.updated | { items: [...] } contains catalog item objects with your current prices. Insert or replace each item by ID. |
items.removed | { ids: [...] } contains IDs that are unavailable to your account. Delete them from your local catalog. |
resync | { reason, minCursor } asks you to reload the snapshot after an inventory or account change, an expired cursor, or a full connection buffer. |
The server sends heartbeat comments at least every 20 seconds. Ignore them when applying updates. Each item event contains at most 500 items or IDs.
: heartbeat
id: <event-cursor>
event: items.removed
data: {"ids":["8d15e82b-21fe-4ec1-a37f-1e2e5edeb1fd"]}
id: <next-event-cursor>
event: resync
data: {"reason":"retention_gap","minCursor":"<next-event-cursor>"}
Limits and retries
The default limits are two simultaneous streams per client and 30 handshakes per minute. A slow connection can close after an overflow. Close an existing stream before opening another, and honor Retry-After on HTTP 429 or 503. A snapshot request with minCursor may also return 503 while it is rebuilding.
Keep sending expectedPrice on withdrawals. The API checks the price again and can return price_changed after a stream update.
Connection examples
curl --no-buffer --get "https://api.skinsnode.com/v1/catalog/stream" \
--data-urlencode "cursor=$CATALOG_CURSOR" \
-H "Accept: text/event-stream" \
-H "x-client-id: $SKINSNODE_CLIENT_ID" \
-H "x-client-secret: $SKINSNODE_CLIENT_SECRET"// Set CATALOG_CURSOR from GET /v1/catalog.
const headers = {
"Accept": "text/event-stream",
"x-client-id": process.env.SKINSNODE_CLIENT_ID,
"x-client-secret": process.env.SKINSNODE_CLIENT_SECRET,
};
const url = new URL("https://api.skinsnode.com/v1/catalog/stream");
if (process.env.LAST_EVENT_ID) {
headers["Last-Event-ID"] = process.env.LAST_EVENT_ID;
} else {
url.searchParams.set("cursor", process.env.CATALOG_CURSOR);
}
const response = await fetch(url, { headers });
if (!response.ok || !response.body) {
throw new Error("Catalog stream HTTP " + response.status);
}
let pending = "";
for await (const text of response.body.pipeThrough(new TextDecoderStream())) {
pending += text;
let end;
while ((end = pending.indexOf("\n\n")) !== -1) {
const frame = pending.slice(0, end).split("\n");
pending = pending.slice(end + 2);
const event = frame.find(line => line.startsWith("event: "))?.slice(7);
if (!event) continue; // Heartbeat comment
const id = frame.find(line => line.startsWith("id: "))?.slice(4);
const data = JSON.parse(frame.find(line => line.startsWith("data: ")).slice(6));
console.log(event, id, data);
// Apply the event durably before saving id. On resync, load
// GET /v1/catalog?minCursor=<data.minCursor> and reconnect.
}
}
import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen
url = "https://api.skinsnode.com/v1/catalog/stream"
headers = {
"Accept": "text/event-stream",
"x-client-id": os.environ["SKINSNODE_CLIENT_ID"],
"x-client-secret": os.environ["SKINSNODE_CLIENT_SECRET"],
}
last_id = os.getenv("LAST_EVENT_ID")
if last_id:
headers["Last-Event-ID"] = last_id
else:
# Save CATALOG_CURSOR from GET /v1/catalog.
url += "?" + urlencode({"cursor": os.environ["CATALOG_CURSOR"]})
with urlopen(Request(url, headers=headers), timeout=30) as response:
frame = {}
for raw in response:
line = raw.decode("utf-8").rstrip("\r\n")
if line.startswith(":"):
continue # Heartbeat comment
if line:
key, _, value = line.partition(":")
frame[key] = value.lstrip(" ")
elif "event" in frame:
print(frame["event"], frame["id"], json.loads(frame["data"]))
# Apply before saving id. On resync, recover the snapshot first.
frame = {}