forked from syntaxerrors/Steam
-
Notifications
You must be signed in to change notification settings - Fork 0
Practical Examples
TeemoCell edited this page Jul 20, 2026
·
3 revisions
All examples assume a configured root client:
use TeemoCell\SteamWebApi\Client;
$steam = new Client(apiKey: $_ENV['STEAM_API_KEY']);$players = $steam->user($steamId)->GetPlayerSummaries();
$player = $players[0] ?? null;
if ($player !== null) {
echo $player->personaName;
}$games = $steam->player($steamId)->GetOwnedGames(
includeAppInfo: true,
);
$mostPlayed = $games->sortByDesc('playtimeForever')->first();$achievements = $steam
->userStats($steamId)
->GetPlayerAchievements($appId);
$unlocked = array_filter(
$achievements ?? [],
static fn ($achievement) => $achievement->achieved,
);$currentPlayers = $steam
->userStats()
->GetNumberOfCurrentPlayers(620);$response = $steam->workshop()->QueryFiles([
'query_type' => 1,
'appid' => 620,
'numperpage' => 20,
'return_details' => true,
'return_tags' => true,
]);$inventory = $steam->communityInventory()->GetInventory(
steamId: $steamId,
appId: 730,
contextId: 2,
language: 'english',
);
foreach ($inventory->items as $item) {
echo $item->name.PHP_EOL;
echo $item->iconUrl.PHP_EOL;
}The Community inventory client follows all pages automatically. It exposes
marketHashName for market-aware applications but does not query or calculate
Community Market resale prices.
$result = $steam
->user(76561197960287930)
->ResolveVanityURL('example-name');
$resolvedSteamId = $result->response->steamid ?? null;use Illuminate\Support\Facades\Cache;
$player = Cache::remember(
"steam:player:{$steamId}",
now()->addMinutes(5),
fn () => $steam->user($steamId)->GetPlayerSummaries()[0] ?? null,
);See Rate limits and caching and Error handling before using live calls in request-critical paths.
Documentation for teemocell/steam-web-api · Licensed under the MIT License