Skip to main content

Module for interacting with various Steam features

Project description

Latest version released on PyPi MIT License Test coverage Scrutinizer score Build status of master branch

Module for interacting with various Steam features. Install with pip install steam.

WebAPI

Wrapper around Steam Web API. Requires API Key. Upon initialization the instance will fetch all available interfaces from the API and populate the namespace. What interfaces are availability depends on the key.

>>> from steam import WebAPI
>>> api = WebAPI(key="<your api key>")

# instance.<interface>.<method>
>>> api.ISteamWebAPIUtil.GetServerInfo()
>>> api.call('ISteamWebAPIUtil.GetServerInfo')
{u'servertimestring': u'Sun Jul 05 22:37:25 2015', u'servertime': 1436161045}

>>> api.ISteamUser.ResolveVanityURL(vanityurl="valve", url_type=2)
>>> api.call('ISteamUser.ResolveVanityURL', vanityurl="valve", url_type=2)
{u'response': {u'steamid': u'103582791429521412', u'success': 1}}

# call a specific version of the method
>>> api.ISteamUser.ResolveVanityURL_v1(vanityurl="valve", url_type=2)
>>> api.call('ISteamUser.ResolveVanityURL_v1', vanityurl="valve", url_type=2)

It’s not necessary to provide the key when calling any interface method. key, format, raw, http_timeout parameters can be specified on WebAPI to affect all method calls, or when calling a specific method. Some methods have parameters which need to be a list. Trying to call nonexistent method will raise an AttributeError.

Supported formats by web api are: json (default), vdf, xml The response will be deserialized using the appropriate module unless raw is True.

>>> api.ISteamUser.ResolveVanityURL.__doc__  # method doc
"""
ResolveVanityURL (v0001)

  Parameters:
    key                       string   required
      - access key
    url_type                  int32    optional
      - The type of vanity URL. 1 (default): Individual profile, 2: Group, 3: Official game group
    vanityurl                 string   required
      - The vanity URL to get a SteamID for

"""

# or calling doc() will print it
>>> api.ISteamUser.ResolveVanityURL.doc()  # method doc
>>> api.ISteamUser.doc()  # interface and all methods
>>> api.doc()  # all available interfaces

Checkout the wiki for a list of the currently available API interfaces.

SteamID

>>> from steam
>>> from steam import SteamID

>>> SteamID()
SteamID(id=0, type='Invalid', universe='Invalid', instance=0)

>>> SteamID(12345)  # accountid
>>> SteamID('12345')
>>> SteamID('STEAM_1:1:6172')  # steam2
SteamID(id=12345, type='Individual', universe='Public', instance=1)

>>> SteamID(103582791429521412)  # steam64
>>> SteamID('103582791429521412')
>>> SteamID('[g:1:4]')  # steam3
SteamID(id=4, type='Clan', universe='Public', instance=0)

# A Steam community url can be resolved using steamid module
>>> steam.steamid.from_url('https://steamcommunity.com/id/drunkenf00l')
>>> steam.steamid.from_url('http://steamcommunity.com/profiles/76561197968459473')
SteamID(id=8193745, type='Individual', universe='Public', instance=1)
>>> steam.steamid.steam64_from_url('http://steamcommunity.com/profiles/76561197968459473')
'76561197968459473'

>>> group = SteamID('[g:1:4]')
>>> group.id  # accountid
4
>>> group.as_32  # accountid
4
>>> group.as_64
103582791429521412
>>> str(group)
'103582791429521412'
>>> group.as_steam2 # only works for 'Individual' accounts
'STEAM_1:0:2'
>>> group.as_steam3
'[g:1:4]'
>>> group.community_url
'https://steamcommunity.com/gid/103582791429521412'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

steam-0.5.4.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file steam-0.5.4.tar.gz.

File metadata

  • Download URL: steam-0.5.4.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for steam-0.5.4.tar.gz
Algorithm Hash digest
SHA256 cba7ea2245a2de885dc5d99db420bd469c9ea433752582f9abd39d8dee0028b0
MD5 4fae891bc3f9a52987d1ebcba6fd50e2
BLAKE2b-256 a7331726328c09e28c56a1e8097a6ab97293690b1e2a647d8c03dbf2d5b3e417

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page