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.
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.