Skip to content

SteamID

cbyte edited this page Jul 19, 2026 · 1 revision

SteamID

steam.steamid.SteamID converts between every representation of a Steam identifier:

  • 32-bit account id76580 (just the account number).
  • 64-bit "steam64"76561197960342308 (universe + type + instance + account).
  • Steam2STEAM_1:0:38290 (with the GoldSrc STEAM_0:... variant).
  • Steam3[U:1:76580] (also [G:...], [g:...], [T:...], etc for other entity types).
  • Community URLhttps://steamcommunity.com/profiles/76561197960342308 or .../id/vanityurl.
  • s.team invite codecv-dgb.
  • CS:GO friend codeAEBJA-ABDC.

SteamID is a subclass of int — anywhere Steam wants a 64-bit id, you can pass a SteamID directly.

Construction

from steam.steamid import SteamID

SteamID()                                                # invalid (universe=Invalid, type=Invalid)
SteamID(76580)                                           # bare 32-bit account id
SteamID('76580')                                         # same, as string
SteamID(76561197960342308)                               # 64-bit steam64
SteamID('76561197960342308')                             # same, as string
SteamID('STEAM_1:0:38290')                               # steam2
SteamID('STEAM_0:0:38290')                               # steam2 GoldSrc (universe defaults to Public)
SteamID('[U:1:76580]')                                   # steam3
SteamID('[g:1:4]')                                       # steam3 clan
SteamID(id=76580, type='Individual', universe='Public', instance=1)   # keyword form
SteamID(id=76580, type=EType.Individual, universe=EUniverse.Public)   # enum form

Any format goes in, int(...) comes out as steam64.

Constructor signature

SteamID(*args, **kwargs)

Handles all of the forms above via make_steam64(). Positional args after the first (id) are (type), (type, universe), or (type, universe, instance). Kwargs override positional: type=, universe=, instance=.

Properties

Every conversion lives as a read-only property on the instance:

  • .id / .account_id — 32-bit account id (int).
  • .as_32 — same as .id, semantic name for the 32-bit representation.
  • .as_64 — 64-bit int form (also just int(sid)).
  • .as_steam2"STEAM_1:0:38290".
  • .as_steam2_zero"STEAM_0:0:38290" (GoldSrc / Orange Box).
  • .as_steam3"[U:1:76580]". Handles clan (g), chat (T, c, L), and anon-gameserver instance-included variants.
  • .as_invite_code"cv-dgb". Only defined for Individual type + valid ids.
  • .as_csgo_friend_code"AEBJA-ABDC". Only defined for Individual type + valid ids.
  • .invite_url"https://s.team/p/cv-dgb" for the invite code.
  • .community_url"https://steamcommunity.com/profiles/76561197960342308" for individuals, .../gid/... for clans.
  • .typeEType enum member.
  • .universeEUniverse enum member.
  • .instance — 20-bit int.

Type / Universe / Instance enums

The relevant enums are re-exported off SteamID:

SteamID.EType         # Individual, Multiseat, GameServer, AnonGameServer, Pending,
                      # ContentServer, Clan, Chat, ConsoleUser, AnonUser
SteamID.EUniverse     # Invalid, Public, Beta, Internal, Dev, Max
SteamID.EInstanceFlag # Clan, Lobby, MMSLobby

Factory methods

.from_invite_code(code, universe=EUniverse.Public)

Parse a cv-dgb / https://s.team/p/cv-dgb string back into a SteamID.

sid = SteamID.from_invite_code('cv-dgb')

Returns None if the code is malformed. Also exposed as the module-level from_invite_code().

.from_csgo_friend_code(code, universe=EUniverse.Public)

Parse a CS:GO friend code back into a SteamID.

sid = SteamID.from_csgo_friend_code('AEBJA-ABDC')

.from_url(url, http_timeout=30)

Given a Steam community URL, resolve it to a SteamID. Handles:

  • https://steamcommunity.com/profiles/{steam64}
  • https://steamcommunity.com/profiles/{steam3}
  • https://steamcommunity.com/id/{vanityurl}
  • https://steamcommunity.com/gid/{steam64_or_steam3}
  • https://steamcommunity.com/groups/{groupname}
  • https://steamcommunity.com/user/{invitecode}
sid = SteamID.from_url('https://steamcommunity.com/id/valve')

Warning: each call is an HTTP fetch to steamcommunity.com. For reliable production use, prefer WebAPI.ISteamUser.ResolveVanityURL(vanityurl='...') — see WebAPI.

Returns None if the URL can't be resolved.

Validation

sid.is_valid()

Returns True if the id parses into a plausible Steam identity — universe not Invalid, type not Invalid, instance ≤ 4, account id > 0, etc. Full logic in steam/steamid.py.

Example

from steam.steamid import SteamID

# Someone gave you STEAM_1:0:38290 in a chat log.
sid = SteamID('STEAM_1:0:38290')

# Turn it into every other form.
sid.as_64            # 76561197960342308
sid.as_steam3        # '[U:1:76580]'
sid.community_url    # 'https://steamcommunity.com/profiles/76561197960342308'
sid.as_invite_code   # 'cv-dgb'

# Pass it anywhere Steam wants a 64-bit int.
resp = api.ISteamUser.GetPlayerSummaries(steamids=str(sid))

Where to go next

  • Resolving a vanity URL reliably? Use WebAPI's ISteamUser.ResolveVanityURL instead of SteamID.from_url — no scraping, no rate-limit surprises.
  • Working with community group ids (Clan type)? .community_url gives you .../gid/...; instantiate via SteamID('[g:1:4]') or the numeric form.

Clone this wiki locally