GUIDE · NODE.JS

Fetch a Steam inventory safely with Node.js.

This server-side example uses the built-in fetch API, keeps the ItemData key in an environment variable, and applies a bounded timeout.

Last reviewed 3 August 2026

Request the first page

Run this code on Node.js 20 or newer. Never place ITEMDATA_API_KEY in frontend JavaScript or commit it to source control.

Node.js
const url = new URL("https://itemdata.net/v1/inventory");
url.searchParams.set("steam_id", "76561198000000000");
url.searchParams.set("game", "cs2");

const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.ITEMDATA_API_KEY}`,
  },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  const error = await response.json().catch(() => null);
  throw new Error(error?.message ?? `ItemData returned ${response.status}`);
}

const inventory = await response.json();
console.log(inventory.items);

Continue only when another page exists

When more_items is true, repeat the same request with start_assetid set to the exact last_assetid value. Preserve game, language, and include_non_tradable across every page.

Bound the total pages and elapsed time in your application so a large inventory cannot create unlimited work.

Handle failures by contract

Treat validation and authentication failures as permanent for that request. Honor Retry-After for rate limits and temporary coordination failures. Do not retry every error blindly.

NEXT STEP

Check the full response contract.

The API reference documents every parameter, header, billing rule, and error code.