A type-safe TypeScript SDK for the Steam Web API with automatic API key management, built with OpenAPI and Zod validation.
- đź”’ Type-safe - Full TypeScript support with generated types
- âś… Validated - Request and response validation with Zod schemas
- 🔑 Auto API Key - Automatically reads
STEAM_API_KEYfrom.env - 🚀 Modern - ESM-first, built on native
fetch - 📦 Zero config - Works out of the box
npm install steam-typescript zod
# or
yarn add steam-typescript zod
# or
bun add steam-typescript zodGet your API key from Steam Web API Key
Create a .env file in your project root:
STEAM_API_KEY=your_api_key_hereimport { createSteamClient, getISteamUserGetPlayerSummariesV0002 } from 'steam-typescript';
// Create client - automatically uses STEAM_API_KEY from .env
const client = createSteamClient();
// Fetch player summaries
const result = await getISteamUserGetPlayerSummariesV0002({
client,
query: {
steamids: '76561197960435530'
}
});
if (result.data) {
console.log(result.data);
}The SDK automatically reads STEAM_API_KEY from your .env file:
import { createSteamClient, getISteamUserGetPlayerSummariesV0002 } from 'steam-typescript';
const client = createSteamClient();
const result = await getISteamUserGetPlayerSummariesV0002({
client,
query: {
steamids: '76561197960435530'
}
});You can also set the API key programmatically:
import { createSteamClient, setApiKey } from 'steam-typescript';
// Set API key before creating client
setApiKey('YOUR_STEAM_API_KEY');
const client = createSteamClient();For simple use cases, you can use the SDK functions without creating a client:
import { getISteamNewsGetNewsForAppV0002 } from 'steam-typescript';
import { setApiKey } from 'steam-typescript';
// Set your API key
setApiKey('YOUR_STEAM_API_KEY');
// Use SDK functions directly
const news = await getISteamNewsGetNewsForAppV0002({
query: {
appid: 440, // Team Fortress 2
count: 5
}
});getISteamNewsGetNewsForAppV0002- Get latest news for a game
getISteamUserGetPlayerSummariesV0002- Get public Steam profile datagetISteamUserGetFriendListV0001- Get friend list for a Steam user
getISteamUserStatsGetGlobalAchievementPercentagesForAppV0002- Get global achievement percentagesgetISteamUserStatsGetPlayerAchievementsV0001- Get achievements for a user in a gamegetISteamUserStatsGetUserStatsForGameV0002- Get user stats + achievements
getIPlayerServiceGetOwnedGamesV0001- Get owned games (public profiles only)getIPlayerServiceGetRecentlyPlayedGamesV0001- Get recently played games
import { createSteamClient, getISteamUserGetPlayerSummariesV0002 } from 'steam-typescript';
const client = createSteamClient();
const result = await getISteamUserGetPlayerSummariesV0002({
client,
query: {
steamids: '76561197960435530'
}
});
if (result.data) {
const player = result.data.response?.players?.[0];
console.log(`Player: ${player?.personaname}`);
}import { createSteamClient, getIPlayerServiceGetOwnedGamesV0001 } from 'steam-typescript';
const client = createSteamClient();
const result = await getIPlayerServiceGetOwnedGamesV0001({
client,
query: {
steamid: '76561197960435530',
include_appinfo: true
}
});
if (result.data) {
const games = result.data.response?.games ?? [];
console.log(`Found ${games.length} games`);
}import { createSteamClient, getISteamNewsGetNewsForAppV0002 } from 'steam-typescript';
const client = createSteamClient();
const result = await getISteamNewsGetNewsForAppV0002({
client,
query: {
appid: 440, // Team Fortress 2
count: 5,
maxlength: 300
}
});
if (result.data) {
const news = result.data.appnews?.newsitems ?? [];
for (const item of news) {
console.log(`${item.title}: ${item.url}`);
}
}The SDK returns both data and error, following the throwOnError pattern:
const result = await getISteamUserGetPlayerSummariesV0002({
client,
query: {
steamids: 'invalid'
}
});
if (result.error) {
console.error('API Error:', result.error);
} else {
console.log('Success:', result.data);
}To throw errors instead:
const result = await getISteamUserGetPlayerSummariesV0002({
client,
throwOnError: true, // Will throw on error
query: {
steamids: '76561197960435530'
}
});
// result.data is guaranteed to exist here
console.log(result.data);All API responses are fully typed:
import type { GetISteamUserGetPlayerSummariesV0002Responses } from 'steam-typescript';
const result = await getISteamUserGetPlayerSummariesV0002({
client,
query: {
steamids: '76561197960435530'
}
});
// TypeScript knows the structure
const players = result.data?.response?.players;| Variable | Required | Description |
|---|---|---|
STEAM_API_KEY |
Yes | Your Steam Web API key from steamcommunity.com/dev/apikey |
MIT
Contributions are welcome! This SDK is generated from an OpenAPI specification. To modify or extend:
- Update
steam-web-api-openapi.yaml - Run
bun openapi-tsto regenerate the SDK - Test your changes