Loading documentation…
Loading documentation…
Call SteamCall from a server-side TypeScript runtime.
Run this example in a server-side Node.js TypeScript project with built-in fetch
and AbortSignal.timeout support. It does not require a SteamCall SDK.
Set STEAMCALL_API_KEY to your Credential secret
in your server environment; never put it in a browser-exposed environment variable.
Replace the example Steam ID with the inventory you need. Current reads a saved revision; if none exists, complete a Refresh first. A returned page costs one credit.
const apiKey = process.env.STEAMCALL_API_KEY;
if (!apiKey)
throw new Error("Set STEAMCALL_API_KEY before running this example");
const url = new URL(
"https://api.steamcall.com/v2/steam/users/76561198000000000/inventory/440/2/current",
);
url.searchParams.set("language", "english");
const response = await fetch(url, {
headers: { "X-API-Key": apiKey },
signal: AbortSignal.timeout(15_000),
});
if (!response.ok)
throw new Error(`SteamCall request failed: ${response.status}`);
const data = await response.json();Run this code server-side so the key never enters the browser bundle.
Read response.headers.get("x-request-id") before handling the body, and parse the documented error envelope when response.ok is false. Avoid placing full response bodies in thrown error messages or observability breadcrumbs.
AbortSignal.timeout bounds one request. A retrying caller still needs one overall deadline and a maximum attempt count. Keep this module out of client components, service workers, and code that can be bundled for a browser.
This example reads stored Current state. See Build an inventory integration for a complete server-side synchronization flow.