-
Notifications
You must be signed in to change notification settings - Fork 0
First script
Two short examples to get you moving. The first hits the CM protocol via SteamClient. The second stays on HTTP and only uses WebAPI — no gevent, no client extra.
The shortest complete flow — connect anonymously, request public product info, log out.
from steam.client import SteamClient
client = SteamClient()
assert client.anonymous_login()
resp = client.get_product_info(apps=[553850], timeout=15) # Helldivers 2
print(resp['apps'][553850]['common']['name'])
client.logout()
client.disconnect()Expected output:
HELLDIVERS 2
Walking through it line by line:
-
SteamClient()— instantiates the client. No network yet; this just wires up the event emitter and mixin state. -
client.anonymous_login()— resolves a CM (connection manager) server, opens a TCP connection, performs the handshake, and issues an anonymousClientLogonmessage. Returns anEResult. Anonymous is enough for public metadata like PICS. See SteamClient for the credential login flavours. -
client.get_product_info(apps=[553850], timeout=15)— issuesClientPICSProductInfoRequestand blocks until all response chunks arrive.553850is the appid for Helldivers 2 — swap in whatever appid you care about. The return value is a dict keyed by appid; the parsed VDF payload lives under['apps'][appid].Signature:
get_product_info(apps=[], packages=[], meta_data_only=False, raw=False, auto_access_tokens=True, timeout=15) -
resp['apps'][553850]['common']['name']— reads the game's display name from Steam's canonicalcommonblock. There's a lot more in the response (extended,depots,config,ufs, …); printresp['apps'][553850].keys()to explore. -
client.logout()followed byclient.disconnect()— Steam's CM drops the connection as soon asClientLogOffis acknowledged, but callingdisconnect()afterwards guarantees the local socket + gevent loop are torn down cleanly.
Some endpoints don't need a key or an authenticated session. ISteamWebAPIUtil.GetServerInfo is one of them — a great "is the connection working" ping:
from steam.webapi import get
resp = get('ISteamWebAPIUtil', 'GetServerInfo', 1)
print(resp)Expected output:
{'servertime': 1721406000, 'servertimestring': 'Fri Jul 19 15:00:00 2026'}
Or via the class-based interface, which auto-discovers every method Steam exposes:
from steam.webapi import WebAPI
api = WebAPI(key=None) # None is fine — GetServerInfo is unauthenticated
print(api.ISteamWebAPIUtil.GetServerInfo())If you have a key, resolve a vanity URL:
api = WebAPI(key='YOUR_KEY_HERE')
resp = api.ISteamUser.ResolveVanityURL(vanityurl='valve', url_type=2)
print(resp) # -> {'response': {'steamid': '103582791429521412', 'success': 1}}Get a key from steamcommunity.com/dev/apikey. Full details on WebAPI.
- Real login (credentials + 2FA): SteamClient → the "Login" section.
- Session cookies for the storefront: WebAuth.
- Downloading depot files: CDNClient — needs a logged-in client with a game license.
- Anything id-related: SteamID — pass any format in, get any format out.
H47R15/steam — maintained fork of ValvePython/steam. MIT licensed.