The WebAPI class in steam.webapi is a wrapper around the Steam Web API. It automatically fetches available interfaces and populates the namespace upon initialization.
Setup
- Obtain an API Key from http://steamcommunity.com/dev/apikey (requires a verified email).
- Initialize the
WebAPI instance with your key.
Calling Endpoints
Endpoints are accessed via the pattern api.<interface>.<method>() or api.call('<interface>.<method>', **params).
- Versioned methods: You can call specific versions of a method using the suffix
_v1, _v2, etc. (e.g., api.ISteamUser.ResolveVanityURL_v1(...)). - Parameters: You can pass parameters directly to the method or via
api.call(). Some methods require parameters to be passed as a list. - Global configuration: You can set
key, format, raw, and http_timeout on the WebAPI instance to affect all calls. - Formats: Supported formats are
json (default), vdf, and xml. If raw=True, the response is not deserialized.
Documentation
You can inspect available interfaces and methods using the .doc() method:
api.ISteamUser.ResolveVanityURL.__doc__: Method documentation.api.ISteamUser.ResolveVanityURL.doc(): Prints method documentation.api.ISteamUser.doc(): Prints interface and all its methods.api.doc(): Prints all available interfaces.
from steam.webapi import WebAPI
api = WebAPI(key="<your api key>")
# Call via namespace
api.ISteamWebAPIUtil.GetServerInfo()
# Call via .call()
api.call('ISteamWebAPIUtil.GetServerInfo')
# Call with parameters
api.ISteamUser.ResolveVanityURL(vanityurl="valve", url_type=2)
api.call('ISteamUser.ResolveVanityURL', vanityurl="valve", url_type=2)
# Call a specific version
api.ISteamUser.ResolveVanityURL_v1(vanityurl="valve", url_type=2)
# Inspect documentation
api.ISteamUser.ResolveVanityURL.doc()
api.ISteamUser.doc()
api.doc()