SteamIDs¶
SteamID are used in many places within Valve services to identify entities
such as users, groups and game servers. SteamIDs have many different
representations which all need to be handled so the valve.steam.id
module exists to provide an mechanism for representing these IDs in a usable
fashion.
The SteamID Class¶
Rarely will you ever want to instantiate a SteamID directly. Instead
it is best to use the SteamID.from_community_url() and
SteamID.from_text() class methods for creating new instances.
-
class
valve.steam.id.SteamID(account_number, instance, type, universe)¶ Represents a SteamID
A SteamID is broken up into four components: a 32 bit account number, a 20 bit “instance” identifier, a 4 bit account type and an 8 bit “universe” identifier.
There are 10 known accounts types as listed below. Generally you won’t encounter types other than “individual” and “group”.
Type Numeric value Can be mapped to URL Constant Invalid 0 No TYPE_INVALIDIndividual 1 Yes TYPE_INDIVIDUALMultiseat 2 No TYPE_MULTISEATGame server 3 No TYPE_GAME_SERVERAnonymous game server 4 No TYPE_ANON_GAME_SERVERPending 5 No TYPE_PENDINGContent server 6 No TYPE_CONTENT_SERVERGroup 7 Yes TYPE_CLANChat 8 No TYPE_CHAT“P2P Super Seeder” 9 No TYPE_P2P_SUPER_SEEDERAnonymous user 10 No TYPE_ANON_USERTYPE_-prefixed constants are provided by thevalve.steam.idmodule for the numerical values of each type.All SteamIDs can be represented textually as well as by their numerical components. This is typically in the STEAM_X:Y:Z form where X, Y, Z are the “universe”, “instance” and the account number respectively. There are two special cases however. If the account type if invalid then “UNKNOWN” is the textual representation. Similarly “STEAM_ID_PENDING” is used when the type is pending.
As well as the the textual representation of SteamIDs there are also the 64 and 32 bit versions which contain the SteamID components encoded into integers of corresponding width. However the 32-bit representation also includes a letter to indicate account type.
-
__int__()¶ The 64 bit representation of the SteamID
64 bit SteamIDs are only valid for those with the type
TYPE_INDIVIDUALorTYPE_CLAN. For all other typesSteamIDErrorwill be raised.The 64 bit representation is calculated by multiplying the account number by two then adding the “instance” and then adding another constant which varies based on the account type.
For
TYPE_INDIVIDUALthe constant is0x0110000100000000, whereas forTYPE_CLANit’s0x0170000000000000.
-
__str__()¶ The textual representation of the SteamID
This is in the STEAM_X:Y:Z form and can be parsed by
from_text()to produce an equivalentinstance. AlternatelySTEAM_ID_PENDINGorUNKNOWNmay be returned if the account type isTYPE_PENDINGorTYPE_INVALIDrespectively.Note
from_text()will still handle theSTEAM_ID_PENDINGandUNKNOWNcases.
-
__weakref__¶ list of weak references to the object (if defined)
-
as_32()¶ Returns the 32 bit community ID as a string
This is only applicable for
TYPE_INDIVIDUAL,TYPE_CLANandTYPE_CHATtypes. For any other types, attempting to generate the 32-bit representation will result in aSteamIDErrorbeing raised.
-
as_64()¶ Returns the 64 bit representation as a string
This is only possible if the ID type is
TYPE_INDIVIDUALorTYPE_CLAN, otherwiseSteamIDErroris raised.
-
community_url(id64=True)¶ Returns the full URL to the Steam Community page for the SteamID
This can either be generate a URL from the 64 bit representation (the default) or the 32 bit one. Generating community URLs is only supported for IDs of type
TYPE_INDIVIDUALandTYPE_CLAN. Attempting to generate a URL for any other type will result in aSteamIDErrorbeing raised.
-
classmethod
from_community_url(id, universe=0)¶ Parse a Steam community URL into a
SteamIDinstanceThis takes a Steam community URL for a profile or group and converts it to a SteamID. The type of the ID is infered from the type character in 32-bit community urls (
[U:1:1]for example) or from the URL path (/profileor/groups) for 64-bit URLs.As there is no way to determine the universe directly from URL it must be expliticly set, defaulting to
UNIVERSE_INDIVIDUAL.Raises
SteamIDErrorif the URL cannot be parsed.
-
classmethod
from_text(id, type=1)¶ Parse a SteamID in the STEAM_X:Y:Z form
Takes a teaxtual SteamID in the form STEAM_X:Y:Z and returns a corresponding
SteamIDinstance. The X represents the account’s ‘universe,’ Z is the account number and Y is either 1 or 0.As the account type cannot be directly inferred from the SteamID it must be explicitly specified, defaulting to
TYPE_INDIVIDUAL.The two special IDs
STEAM_ID_PENDINGandUNKNOWNare also handled returning SteamID instances with the appropriate types set (TYPE_PENDINGandTYPE_INVALIDrespectively) and with all other components of the ID set to zero.
-
type_name¶ The account type as a string
-
Exceptions¶
-
exception
valve.steam.id.SteamIDError¶ Bases:
ValueErrorRaised when parsing or building invalid SteamIDs
Useful Constants¶
As well as providing the SteamID class, the valve.steam.id
module also contains numerous constants which relate to the contituent parts
of a SteamID. These constants map to their numeric equivalent.
Account Types¶
The following are the various account types that can be encoded into a
SteamID. Many of them are seemingly no longer in use – at least not in
public facing services – and you’re only likely to come across
TYPE_INDIVIDUAL, TYPE_CLAN and possibly
TYPE_GAME_SERVER.
-
valve.steam.id.TYPE_INVALID= 0¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_INDIVIDUAL= 1¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_MULTISEAT= 2¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_GAME_SERVER= 3¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_ANON_GAME_SERVER= 4¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_PENDING= 5¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_CONTENT_SERVER= 6¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_CLAN= 7¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_CHAT= 8¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_P2P_SUPER_SEEDER= 9¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.TYPE_ANON_USER= 10¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
Universes¶
A SteamID “universe” provides a way of grouping IDs. Typically you’ll only
ever come across the UNIVERSE_INDIVIDUAL universe.
-
valve.steam.id.UNIVERSE_INDIVIDUAL= 0¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.UNIVERSE_PUBLIC= 1¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.UNIVERSE_BETA= 2¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.UNIVERSE_INTERNAL= 3¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.UNIVERSE_DEV= 4¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
-
valve.steam.id.UNIVERSE_RC= 5¶ int(x=0) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-‘ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4