AgentSkillsCN

steam-api

此技能为向Steam Web API发起请求提供指导。当用户需要通过官方Steam Web API查询Steam用户数据、游戏信息、玩家统计数据、比赛历史、库存物品,或任何其他与Steam相关数据时,可使用此技能。

SKILL.md
--- frontmatter
name: steam-api
description: This skill provides guidance for making requests to the Steam Web API. It should be used when users need to query Steam user data, game information, player statistics, match history, inventory items, or any other Steam-related data through the official Steam Web API.

Steam Web API Skill

This skill helps you interact with the Steam Web API to retrieve user data, game information, player statistics, and more.

Getting Started

To use the Steam Web API, you need an API key. Users can obtain one at: https://steamcommunity.com/dev/apikey

Important: The API key should be kept secret and never shared or committed to version control.

API Request Format

The Steam Web API follows this URL structure:

code
https://api.steampowered.com/{interface}/{method}/{version}?{parameters}
  • Base URL: https://api.steampowered.com
  • Interface: The method group (e.g., ISteamUser, ISteamApps)
  • Method: The specific endpoint (e.g., GetPlayerSummaries, GetAppList)
  • Version: API version (usually v1 or v2)
  • Parameters: Query parameters including the API key

Response Format

Responses are returned in JSON format by default. Other formats (vdf, xml) are available but JSON is preferred.

Common Interfaces and Methods

ISteamUser - User Information

MethodDescriptionKey Parameters
GetPlayerSummariesGet user profile datasteamids (comma-separated)
GetFriendListGet user's friendssteamid, relationship
GetPlayerBansGet ban statussteamids
GetUserGroupListGet user's groupssteamid
ResolveVanityURLConvert vanity URL to SteamIDvanityurl

ISteamApps - Application Data

MethodDescriptionKey Parameters
GetAppListList all apps/gamesNone
GetAppInfoGet app detailsappids
UpToDateCheckCheck version statusappid, version
GetServersAtAddressGet servers at IPaddr

IPlayerService - Player Services

MethodDescriptionKey Parameters
GetOwnedGamesGet user's game librarysteamid, include_appinfo
GetRecentlyPlayedGamesRecently played gamessteamid, count
GetSteamLevelGet user's Steam levelsteamid
GetBadgesGet user's badgessteamid

ISteamNews - Game News

MethodDescriptionKey Parameters
GetNewsForAppGet news for a gameappid, count, maxlength

ISteamUserStats - Game Statistics

MethodDescriptionKey Parameters
GetGlobalAchievementPercentagesForAppAchievement statsgameid
GetPlayerAchievementsUser's achievementssteamid, appid
GetUserStatsForGameUser's game statssteamid, appid
GetSchemaForGameGame schemaappid

IDOTA2Match_570 - Dota 2 Match Data

MethodDescriptionKey Parameters
GetMatchHistoryGet match historyaccount_id, matches_requested
GetMatchDetailsGet match detailsmatch_id
GetLiveLeagueGamesLive league gamesleague_id
GetTeamInfoByTeamIDTeam informationstart_at_team_id

IEconDOTA2_570 - Dota 2 Economy

MethodDescriptionKey Parameters
GetHeroesGet hero listlanguage
GetTournamentPrizePoolPrize pool infoleagueid
GetRaritiesItem raritieslanguage

ICSGOServers_730 - CS:GO Data

MethodDescriptionKey Parameters
GetGameServersStatusServer statusNone

API Key Handling

When making API requests:

  1. Request the key from the user if not provided
  2. Never hardcode the API key in scripts
  3. Use environment variables or secure storage for the key
  4. Validate the key is present before making requests

Example Python pattern:

python
import os
import requests

STEAM_API_KEY = os.environ.get('STEAM_API_KEY')
if not STEAM_API_KEY:
    raise ValueError("STEAM_API_KEY environment variable not set")

url = f"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key={STEAM_API_KEY}&steamids={steamid}"
response = requests.get(url)
data = response.json()

Common Use Cases

1. Get User Profile Information

code
GET https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key={key}&steamids={steamid}

2. Get User's Game Library

code
GET https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?key={key}&steamid={steamid}&include_appinfo=true

3. Get Recently Played Games

code
GET https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/?key={key}&steamid={steamid}&count=5

4. Resolve Vanity URL

code
GET https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1/?key={key}&vanityurl={username}

5. Get Game News

code
GET https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/?appid={appid}&count=5

6. Get Dota 2 Match History

code
GET https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key={key}&account_id={account_id}&matches_requested=10

Error Handling

Common HTTP status codes:

  • 200 - Success
  • 400 - Bad Request (invalid parameters)
  • 401 - Unauthorized (invalid API key)
  • 403 - Forbidden (rate limit or access denied)
  • 404 - Not Found
  • 429 - Too Many Requests (rate limited)
  • 500 - Internal Server Error

Rate Limiting

Steam Web API has rate limits. Best practices:

  • Cache responses when possible
  • Implement exponential backoff for retries
  • Respect Retry-After headers
  • Consider using Steam Web API key with higher limits for production

References

For detailed API documentation, see references/steam_api_reference.md which contains the complete list of all available endpoints.

References