API reference¶
The following document outlines the front facing aspects of steam.py.
Note
This module uses Python’s logging module to debug, give information and diagnose errors, it is recommended to configure this if necessary as errors or warnings will not be propagated properly.
Client¶
- asyncchange_presence
- defclear
- asyncclose
- asynccode
- asyncconnect
- @event
- asyncfetch_clan
- asyncfetch_clan_named
- asyncfetch_game
- asyncfetch_price
- asyncfetch_server
- asyncfetch_servers
- asyncfetch_trade
- asyncfetch_user
- asyncfetch_user_named
- asyncfetch_users
- defget_clan
- defget_game
- defget_group
- defget_trade
- defget_user
- defis_closed
- defis_ready
- asynclogin
- asyncon_announcement_create
- asyncon_clan_invite
- asyncon_clan_invite_accept
- asyncon_clan_invite_decline
- asyncon_clan_join
- asyncon_clan_leave
- asyncon_clan_update
- asyncon_comment
- asyncon_connect
- asyncon_disconnect
- asyncon_error
- asyncon_event_create
- asyncon_group_join
- asyncon_group_leave
- asyncon_group_update
- asyncon_login
- asyncon_message
- asyncon_ready
- asyncon_socket_receive
- asyncon_socket_send
- asyncon_trade_accept
- asyncon_trade_cancel
- asyncon_trade_counter
- asyncon_trade_decline
- asyncon_trade_expire
- asyncon_trade_receive
- asyncon_trade_send
- asyncon_typing
- asyncon_user_invite
- asyncon_user_invite_accept
- asyncon_user_invite_decline
- asyncon_user_remove
- defrun
- asyncstart
- async fortrade_history
- asynctrade_url
- asyncwait_for
- asyncwait_until_ready
- class steam.Client(*, proxy: str | None = '...', proxy_auth: aiohttp.BasicAuth | None = '...', connector: aiohttp.BaseConnector | None = '...', max_messages: int | None = '...', game: Game | None = '...', games: list[steam.game.Game] = '...', state: PersonaState | None = '...', ui_mode: UIMode | None = '...', flags: PersonaStateFlag | None = '...', force_kick: bool = '...')¶
Represents a client connection that connects to Steam. This class is used to interact with the Steam API and CMs.
- Parameters
proxy – A proxy URL to use for requests.
proxy_auth – The proxy authentication to use with requests.
connector – The connector to use with the
aiohttp.ClientSession
.max_messages – The maximum number of messages to store in the internal cache, default is 1000.
game – A games to set your status as on connect.
games – A list of games to set your status to on connect.
state –
The state to show your account as on connect.
Note
Setting your status to
Offline
, will stop you receiving persona state updates and by extensionon_user_update()
will stop being dispatched.ui_mode – The UI mode to set your status to on connect.
flags – Flags to set your persona state to.
force_kick – Whether or not to forcefully kick any other playing sessions on connect. Defaults to
False
.
- property user: ClientUser¶
Represents the connected client.
None
if not logged in.
- property trades: list[TradeOffer]¶
A list of all the trades the connected client can see.
- property latency: float¶
Measures latency between a heartbeat send and the heartbeat interval in seconds.
- await code()¶
Get the current steam guard code.
Warning
This function will wait for a Steam guard code using
input()
in an executor if no shared_secret is passed torun()
orstart()
, which blocks exiting until one is entered.- Return type
- @event(coro: None = None) collections.abc.Callable[steam.client.E, steam.client.E] ¶
- @event(coro: steam.client.E) steam.client.E
A decorator that could be called. Register an event to listen to.
The events must be a coroutine, if not,
TypeError
is raised.Usage:
@client.event async def on_ready(): print("Ready!")
- Raises
TypeError – The function passed is not a coroutine.
- Return type
Union
[collections.abc.Callable
[steam.client.E
, (~E,)],steam.client.E
]
- run(*args, **kwargs)¶
A blocking call that abstracts away the event loop initialisation from you.
It is not recommended to subclass this method, it is normally favourable to subclass
start()
as it is a coroutine.Note
This takes the same arguments as
start()
.
- await login(username, password, *, shared_secret=None)¶
Login a Steam account and the Steam API with the specified credentials.
- Parameters
username (str) – The username of the user’s account.
password (str) – The password of the user’s account.
shared_secret (str | None) – The shared_secret of the desired Steam account, used to generate the 2FA code for login. If
None
is passed, the code will need to be inputted by the user viacode()
.
- Raises
InvalidCredentials – Invalid credentials were passed.
LoginError – An unknown login related error occurred.
NoCMsFound – No community managers could be found to connect to.
- await close()¶
Close the connection to Steam.
- clear()¶
Clears the internal state of the bot. After this, the bot can be considered “re-opened”, i.e.
is_closed()
andis_ready()
both returnFalse
. This also clears the internal cache.
- await start(username, password, *, shared_secret=None, identity_secret=None)¶
A shorthand coroutine for
login()
andconnect()
.If no
shared_secret
is passed, you will have to manually enter a Steam guard code usingcode()
.
- await connect()¶
Initialize a connection to a Steam CM after logging in.
- get_user(id)¶
Returns a user from cache with a matching ID or
None
if the user was not found.- Parameters
id (utils.Intable) – The ID of the user, can be an
SteamID.id64
,SteamID.id
,SteamID.id2
or anSteamID.id3
.- Return type
- await fetch_user(id)¶
Fetches a user with a matching ID or
None
if the user was not found.- Parameters
id (utils.Intable) – The ID of the user, can be an
SteamID.id64
,SteamID.id
,SteamID.id2
or anSteamID.id3
.- Return type
- await fetch_users(*ids)¶
Fetches a list of
User
orNone
if the user was not found, from their IDs.Note
The
User
objects returned are unlikely to retain the order they were originally in.- Parameters
ids (utils.Intable) – The user’s IDs.
- Return type
- await fetch_user_named(name)¶
Fetches a user from https://steamcommunity.com from their community URL name.
- Parameters
name (str) – The name of the user after https://steamcommunity.com/id
- Return type
- get_trade(id)¶
Get a trade from cache with a matching ID or
None
if the trade was not found.- Parameters
id (int) – The id of the trade to search for from the cache.
- Return type
- await fetch_trade(id)¶
Fetches a trade with a matching ID or
None
if the trade was not found.- Parameters
id (int) – The ID of the trade to search for from the API.
- Return type
- get_group(id)¶
Get a group from cache with a matching ID or
None
if the group was not found.- Parameters
id (utils.Intable) – The ID of the group, can be an
SteamID.id64
,SteamID.id
,SteamID.id2
or anSteamID.id3
.- Return type
- get_clan(id)¶
Get a clan from cache with a matching ID or
None
if the group was not found.- Parameters
id (utils.Intable) – The ID of the clan, can be an
SteamID.id64
,SteamID.id
,SteamID.id2
or anSteamID.id3
.- Return type
- await fetch_clan(id)¶
Fetches a clan from the websocket with a matching ID or
None
if the clan was not found.- Parameters
id (utils.Intable) – The ID of the clan, can be an
SteamID.id64
,SteamID.id
,SteamID.id2
or anSteamID.id3
.- Return type
- await fetch_clan_named(name)¶
Fetches a clan from https://steamcommunity.com with a matching name or
None
if the clan was not found.- Parameters
name (str) – The name of the Steam clan.
- Return type
- get_game(id)¶
Creates a stateful game from its ID.
- await fetch_game(id)¶
Fetch a game from its ID or
None
if the game was not found.
- await fetch_server(*, id: utils.Intable) GameServer | None ¶
- await fetch_server(*, ip: str, port: int | None = None) GameServer | None
Fetch a
GameServer
from its ip and port or its SteamID orNone
if fetching the server failed.- Parameters
ip – The ip of the server.
port – The port of the server.
id – The ID of the game server, can be an
SteamID.id64
,SteamID.id2
or anSteamID.id3
. If this is passed, it makes a call to the master server to fetch its ip and port.
Note
Passing an
ip
,port
andid
to this function will raise anTypeError
.- Return type
- await fetch_servers(query, limit=100)¶
Query game servers.
- Parameters
query (steam.game_server.Query[Any]) – The query to match servers with.
limit (int) – The maximum amount of servers to return.
- Return type
- trade_history(limit=100, before=None, after=None)¶
An
AsyncIterator
for accessing asteam.ClientUser
’ssteam.TradeOffer
objects.Examples
Usage:
async for trade in client.trade_history(limit=10): items = [getattr(item, "name", str(item.asset_id)) for item in trade.items_to_receive] items = ", ".join(items) or "Nothing" print("Partner:", trade.partner) print("Sent:", items)
Flattening into a list:
trades = await client.trade_history(limit=50).flatten() # trades is now a list of TradeOffer
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of trades to search through. Default is
100
. Setting this toNone
will fetch all of the user’s trades, but this will be a very slow operation.before (datetime.datetime | None) – A time to search for trades before.
after (datetime.datetime | None) – A time to search for trades after.
- Yields
- await change_presence(*, game=None, games=None, state=None, ui_mode=None, flags=None, force_kick=False)¶
Set your status.
- Parameters
games (list[Game] | None) – A list of games to set your status to.
state (PersonaState | None) –
The state to show your account as.
Warning
Setting your status to
Offline
, will stop you receiving persona state updates and by extensionon_user_update()
will stop being dispatched.ui_mode (UIMode | None) – The UI mode to set your status to.
flags (PersonaStateFlag | None) – The flags to update your account with.
force_kick (bool) – Whether or not to forcefully kick any other playing sessions.
- await trade_url(generate_new=False)¶
Fetches this account’s trade url.
- await wait_until_ready()¶
Waits until the client’s internal cache is all ready.
- await fetch_price(name, game, currency=None)¶
Fetch the
PriceOverview
for an item.- Parameters
- Return type
- await wait_for(event: Literal['connect', 'disconnect', 'ready', 'login', 'logout'], *, check: collections.abc.Callable[bool] = <return_true>, timeout: float | None = None) None ¶
- await wait_for(event: Literal['error'], *, check: collections.abc.Callable[str, Exception, tuple[typing.Any, ...], dict[str, typing.Any], bool] = <return_true>, timeout: float | None = None) tuple[str, Exception, tuple[typing.Any], dict[str, typing.Any]]
- await wait_for(event: Literal['message'], *, check: Callable[[Message], bool] = <return_true>, timeout: float | None = None) Message
- await wait_for(event: Literal['comment'], *, check: Callable[[Comment], bool] = <return_true>, timeout: float | None = None) Comment
- await wait_for(event: Literal['user_update'], *, check: Callable[[User, User], bool] = <return_true>, timeout: float | None = None) tuple[User, User]
- await wait_for(event: Literal['clan_update'], *, check: Callable[[Clan, Clan], bool] = <return_true>, timeout: float | None = None) tuple[Clan, Clan]
- await wait_for(event: Literal['group_update'], *, check: Callable[[Group, Group], bool] = <return_true>, timeout: float | None = None) tuple[Group, Group]
- await wait_for(event: Literal['typing'], *, check: Callable[[User, datetime.datetime], bool] = <return_true>, timeout: float | None = None) tuple[User, datetime.datetime]
- await wait_for(event: Literal['trade_receive', 'trade_send', 'trade_accept', 'trade_decline', 'trade_cancel', 'trade_expire', 'trade_counter'], *, check: Callable[[TradeOffer], bool] = <return_true>, timeout: float | None = None) TradeOffer
- await wait_for(event: Literal['user_invite', 'user_invite_accept', 'user_invite_decline'], *, check: Callable[[UserInvite], bool] = <return_true>, timeout: float | None = None) UserInvite
- await wait_for(event: Literal['user_remove'], *, check: Callable[[User], bool] = <return_true>, timeout: float | None = None) User
- await wait_for(event: Literal['clan_invite', 'clan_invite_accept', 'clan_invite_decline'], *, check: Callable[[ClanInvite], bool] = <return_true>, timeout: float | None = None) ClanInvite
- await wait_for(event: Literal['clan_join', 'clan_leave'], *, check: Callable[[Clan], bool] = <return_true>, timeout: float | None = None) Clan
- await wait_for(event: Literal['group_join', 'group_leave'], *, check: Callable[[Group], bool] = <return_true>, timeout: float | None = None) Group
- await wait_for(event: Literal['event_create'], *, check: Callable[[Event], bool] = <return_true>, timeout: float | None = None) Event
- await wait_for(event: Literal['announcement_create'], *, check: Callable[[Announcement], bool] = <return_true>, timeout: float | None = None) Announcement
- await wait_for(event: Literal['socket_receive', 'socket_send'], *, check: collections.abc.Callable[MsgProto[Any] | Msg[Any] | GCMsgProto[Any] | GCMsg[Any], bool] = <return_true>, timeout: float | None = None) Msgs
Wait for the first event to be dispatched that meets the requirements, this by default is the first event with a matching event name.
- Parameters
event – The event name from the event reference, but without the
on_
prefix, to wait for.check – A callable predicate that checks the received event. The arguments must match the parameters of the
event
being waited for and must return abool
.timeout – By default,
wait_for()
function does not timeout, however, in the case atimeout
parameter is passed after the amount of seconds passasyncio.TimeoutError
is raised.
- Raises
asyncio.TimeoutError – If the provided timeout was reached.
- Returns
Returns
None
, a single argument or atuple
of multiple arguments that mirrors the parameters for theevent
parameter from the event reference.- Return type
Event Reference¶
This page outlines the different types of events listened for by the Client
.
There are two ways to register an event, the first way is through the use of Client.event()
. The second way is
through subclassing Client
and overriding the specific events. For example:
import steam
class MyClient(steam.Client):
async def on_trade_receive(self, trade: steam.TradeOffer) -> None:
await trade.partner.send('Thank you for your trade')
print(f'Received trade: #{trade.id}')
print('Trade partner is:', trade.partner)
print('We would send:', len(trade.items_to_send), 'items')
print('We would receive:', len(trade.items_to_receive), 'items')
if trade.is_gift():
print('Accepting the trade as it is a gift')
await trade.accept()
If an event handler raises an exception, Client.on_error()
will be called to handle it, which by default prints a
traceback and ignoring the exception.
Warning
All the events must be a coroutine function. If they aren’t, a TypeError
will be raised.
- await Client.on_connect()¶
Called when the client has successfully connected to Steam. This is not the same as the client being fully prepared, see
on_ready()
for that.The warnings on
on_ready()
also apply.
- await Client.on_disconnect()¶
Called when the client has disconnected from Steam. This could happen either through the internet disconnecting, an explicit call to logout, or Steam terminating the connection.
This function can be called multiple times.
- await Client.on_ready()¶
Called after a successful login and the client has handled setting up everything.
Warning
This function is not guaranteed to be the first event called. Likewise, this function is not guaranteed to only be called once. This library implements reconnection logic and will therefore end up calling this event whenever a CM disconnects.
- await Client.on_login()¶
Called when the client has logged into https://steamcommunity.com.
- await Client.on_error(event, error, *args, **kwargs)¶
The default error handler provided by the client.
Usually when an event raises an uncaught exception, a traceback is printed to
sys.stderr
and the exception is ignored. If you want to change this behaviour and handle the exception yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.If you want exception to propagate out of the
Client
class you can define anon_error
handler consisting of a single empty The raise statement. Exceptions raised byon_error
will not be handled in any way byClient
.
- await Client.on_message(message)¶
Called when a message is created.
- Parameters
message (steam.Message) – The message that was received.
- await Client.on_typing(user, when)¶
Called when typing is started.
- Parameters
user (steam.User) – The user that started typing.
when (datetime.datetime) – The time the user started typing at.
- await Client.on_trade_receive(trade)¶
Called when the client receives a trade offer.
- Parameters
trade (steam.TradeOffer) – The trade offer that was received.
- await Client.on_trade_send(trade)¶
Called when the client sends a trade offer.
- Parameters
trade (steam.TradeOffer) – The trade offer that was sent.
- await Client.on_trade_accept(trade)¶
Called when the client or the trade partner accepts a trade offer.
- Parameters
trade (steam.TradeOffer) – The trade offer that was accepted.
- await Client.on_trade_decline(trade)¶
Called when the client or the trade partner declines a trade offer.
- Parameters
trade (steam.TradeOffer) – The trade offer that was declined.
- await Client.on_trade_cancel(trade)¶
Called when the client or the trade partner cancels a trade offer.
Note
This is called when the trade state becomes
Canceled
andCanceledBySecondaryFactor
.- Parameters
trade (steam.TradeOffer) – The trade offer that was cancelled.
- await Client.on_trade_expire(trade)¶
Called when a trade offer expires due to being active for too long.
- Parameters
trade (steam.TradeOffer) – The trade offer that expired.
- await Client.on_trade_counter(trade)¶
Called when the client or the trade partner counters a trade offer.
- Parameters
trade (steam.TradeOffer) – The trade offer that was countered.
- await Client.on_comment(comment)¶
Called when the client receives a comment notification.
- Parameters
comment (steam.Comment) – The comment received.
- await Client.on_user_invite(invite)¶
Called when the client receives/sends an invite from/to a
User
to become a friend.- Parameters
invite (steam.UserInvite) – The invite received.
- await Client.on_user_invite_accept(invite)¶
Called when the client/invitee accepts an invite from/to a
User
to become a friend.- Parameters
invite (steam.UserInvite) – The invite that was accepted.
- await Client.on_user_invite_decline(invite)¶
Called when the client/invitee declines an invite from/to a
User
to become a friend.- Parameters
invite (steam.UserInvite) – The invite that was declined.
- await Client.on_user_remove(user)¶
Called when you or the
user
remove each other from your friends lists.- Parameters
user (steam.User) – The user who was removed.
- await Client.on_clan_invite(invite)¶
Called when the client receives/sends an invite from/to a
User
to join aClan
.- Parameters
invite (steam.ClanInvite) – The invite received.
- await Client.on_clan_invite_accept(invite)¶
Called when the client/invitee accepts an invite to join a
Clan
.- Parameters
invite (steam.ClanInvite) – The invite that was accepted.
- await Client.on_clan_invite_decline(invite)¶
Called when the client/invitee declines an invite to join a
Clan
.- Parameters
invite (steam.ClanInvite) – The invite that was declined.
- await Client.on_clan_join(clan)¶
Called when the client joins a new clan.
- Parameters
clan (steam.Clan) – The joined clan.
- await Client.on_clan_update(before, after)¶
Called when a clan is updated, due to one or more of the following attributes changing:
- Parameters
before (steam.Clan) – The clan’s state before it was updated.
after (steam.Clan) – The clan’s state now.
- await Client.on_clan_leave(clan)¶
Called when the client leaves a clan.
- Parameters
clan (steam.Clan) – The left clan.
- await Client.on_group_join(group)¶
Called when the client joins a new group.
- Parameters
group (steam.Group) – The joined group.
- await Client.on_group_update(before, after)¶
Called when a group is updated.
- Parameters
before (steam.Group) – The group’s state before it was updated.
after (steam.Group) – The group’s state now.
- await Client.on_group_leave(group)¶
Called when the client leaves a group.
- Parameters
group (steam.Group) – The left group.
- await Client.on_event_create(event)¶
Called when an event in a clan is created.
- Parameters
event (steam.Event) – The event that was created.
- await Client.on_announcement_create(announcement)¶
Called when an announcement in a clan is created.
- Parameters
announcement (steam.Announcement) – The announcement that was created.
- await Client.on_socket_receive(msg)¶
Called when the connected CM parses a received
Msg
/MsgProto
- Parameters
msg (Msg | MsgProto) – The received message.
- await Client.on_socket_send(msg)¶
Called when the client sends a
Msg
/MsgProto
to the connected CM.- Parameters
msg (Msg | MsgProto) – The sent message.
Utilities¶
steam.py provides some utility functions.
- steam.utils.make_id64(id=0, type=None, universe=None, instance=None)¶
Convert various representations of Steam IDs to its Steam 64 bit ID.
- Parameters
id (Intable) – The ID to convert.
type (TypeType | None) – The type of the ID. Can be the name, the integer value of the type or the recommended way is to use
steam.Type
.universe (UniverseType | None) – The universe of the ID. Can be the name, the integer value of the universe or the recommended way is to use
steam.Universe
.instance (InstanceType | None) – The instance of the ID.
Examples
make_id64() # invalid make_id64(12345) make_id64("12345") # account ids make_id64(12345, type=steam.Type.Clan) # makes the clan id into a clan id64 make_id64(103582791429521412) make_id64("103582791429521412") # id64s make_id64("STEAM_1:0:2") # id2 make_id64("[g:1:4]") # id3
- Raises
InvalidSteamID – The created 64 bit Steam ID would be invalid.
- Returns
The 64 bit Steam ID.
- Return type
- steam.utils.parse_trade_url(url)¶
Parses a trade URL for useful information.
- Parameters
url (StrOrURL) – The trade URL to search.
- Returns
A
re.Match
object withtoken
anduser_id
re.Match.group()
objects orNone
.- Return type
Then some functions from discord.py
- steam.utils.get(iterable, **attrs)¶
A helper that returns the first element in the iterable that meets all the traits passed in
attrs
. This is an alternative forfind()
.Examples
bff = steam.utils.get(client.users, name="Gobot1234") trade = steam.utils.get(client.trades, state=TradeOfferState.Active, partner=message.author) # multiple attributes are also accepted
- Parameters
iterable (Iterable[_T]) – An iterable to search through.
attrs (Any) – Keyword arguments that denote attributes to match.
- Returns
The first element from the
iterable
which matches all the traits passed inattrs
orNone
if no matchingelement was found.
- Return type
_T | None
- steam.utils.find(predicate, iterable)¶
A helper to return the first element found in the sequence.
Examples
first_active_offer = steam.utils.find( lambda trade: trade.state == TradeOfferState.Active, client.trades, ) # how to get an object using a conditional
- Parameters
predicate (Callable[[_T], bool]) – A function that returns a boolean and takes an element from the
iterable
as its first argument.iterable (Iterable[_T]) – The iterable to search through.
- Returns
The first element from the
iterable
for which thepredicate
returnsTrue
or if no matching element was found returnsNone
.- Return type
Optional
[steam.utils._T
]
Enumerations¶
- class steam.Result¶
An enumeration.
- Invalid = 0¶
Invalid Result.
- OK = 1¶
Success.
- Fail = 2¶
Generic failure.
- NoConnection = 3¶
Your Steam client doesn’t have a connection to the back-end.
- InvalidPassword = 5¶
Password/ticket is invalid.
- LoggedInElsewhere = 6¶
Same user logged in elsewhere.
- InvalidProtocolVersion = 7¶
Protocol version is incorrect.
- InvalidParameter = 8¶
A parameter is incorrect.
- FileNotFound = 9¶
File was not found.
- Busy = 10¶
Called method busy - action not taken.
- InvalidState = 11¶
Called object was in an invalid state.
- InvalidName = 12¶
The name was invalid.
- InvalidEmail = 13¶
The email was invalid.
- DuplicateName = 14¶
The name is not unique.
- AccessDenied = 15¶
Access is denied.
- Timeout = 16¶
Operation timed out.
- Banned = 17¶
VAC2 banned.
- AccountNotFound = 18¶
Account not found.
- InvalidSteamID = 19¶
The Steam ID was invalid.
The requested service is currently unavailable.
- NotLoggedOn = 21¶
The user is not logged on.
- Pending = 22¶
Request is pending (may be in process, or waiting on third party).
- EncryptionFailure = 23¶
Encryption or decryption failed.
- InsufficientPrivilege = 24¶
Insufficient privilege.
- LimitExceeded = 25¶
Too much of a good thing.
- Revoked = 26¶
Access has been revoked (used for revoked guest passes).
- Expired = 27¶
License/Guest pass the user is trying to access is expired.
- AlreadyRedeemed = 28¶
Guest pass has already been redeemed by account, cannot be acknowledged again.
- DuplicateRequest = 29¶
The request is a duplicate, ignored this time.
- AlreadyOwned = 30¶
All the games in guest pass redemption request are already owned by the user.
- IPNotFound = 31¶
IP address not found.
- PersistFailed = 32¶
Failed to write change to the data store.
- LockingFailed = 33¶
Failed to acquire access lock for this operation.
- LogonSessionReplaced = 34¶
The logon session has been replaced.
- ConnectFailed = 35¶
Failed to connect.
- HandshakeFailed = 36¶
The authentication handshake has failed.
- IOFailure = 37¶
Generic IO failure.
- RemoteDisconnect = 38¶
The remote server has disconnected.
- ShoppingCartNotFound = 39¶
Failed to find the shopping cart requested.
- Blocked = 40¶
A user blocked the action.
- Ignored = 41¶
The target is ignoring sender.
- NoMatch = 42¶
Nothing matching the request found.
- AccountDisabled = 43¶
The account is disabled.
- ServiceReadOnly = 44¶
This service is not accepting content changes right now.
- AccountNotFeatured = 45¶
Account doesn’t have value, so this feature isn’t available.
- AdministratorOK = 46¶
Allowed to take this action, but only because requester is admin.
- ContentVersion = 47¶
A Version mismatch in content transmitted within the Steam protocol.
- TryAnotherCM = 48¶
The current CM can’t service the user making a request, should try another.
- PasswordRequiredToKickSession = 49¶
You are already logged in elsewhere, this cached credential login has failed.
- AlreadyLoggedInElsewhere = 50¶
You are already logged in elsewhere, you must wait.
- Suspended = 51¶
Long running operation (content download) suspended/paused.
- Cancelled = 52¶
Operation canceled (typically by user content download).
- DataCorruption = 53¶
Operation canceled because data is malformed or unrecoverable.
- DiskFull = 54¶
Operation canceled - not enough disk space.
- RemoteCallFailed = 55¶
An remote call or IPC call failed.
- ExternalAccountUnlinked = 57¶
External account is not linked to a Steam account.
- PSNTicketInvalid = 58¶
PSN ticket was invalid.
- ExternalAccountAlreadyLinked = 59¶
External account is already linked to some other account.
- RemoteFileConflict = 60¶
The sync cannot resume due to a conflict between the local and remote files.
- IllegalPassword = 61¶
The requested new password is not legal.
- SameAsPreviousValue = 62¶
New value is the same as the old one (secret question and answer).
- AccountLogonDenied = 63¶
Account login denied due to 2nd factor authentication failure.
- CannotUseOldPassword = 64¶
The requested new password is not legal.
- InvalidLoginAuthCode = 65¶
Account login denied due to auth code invalid.
- AccountLogonDeniedNoMail = 66¶
Account login denied due to 2nd factor authentication failure.
- HardwareNotCapableOfIPT = 67¶
The users hardware does not support Intel’s identity protection technology.
- IPTInitError = 68¶
Intel’s Identity Protection Technology has failed to initialize.
- ParentalControlRestricted = 69¶
Operation failed due to parental control restrictions for current user.
- FacebookQueryError = 70¶
Facebook query returned an error.
- ExpiredLoginAuthCode = 71¶
Account login denied due to auth code expired.
- IPLoginRestrictionFailed = 72¶
The login failed due to an IP restriction.
- AccountLockedDown = 73¶
The current users account is currently locked for use.
- VerifiedEmailRequired = 74¶
The logon failed because the accounts email is not verified.
- NoMatchingURL = 75¶
There is no url matching the provided values.
- BadResponse = 76¶
Parse failure, missing field, etc.
- RequirePasswordReEntry = 77¶
The user cannot complete the action until they re-enter their password.
- ValueOutOfRange = 78¶
The value entered is outside the acceptable range.
- UnexpectedError = 79¶
Something happened that we didn’t expect to ever happen.
- Disabled = 80¶
The requested service has been configured to be unavailable.
- InvalidCEGSubmission = 81¶
The set of files submitted to the CEG server are not valid.
- RestrictedDevice = 82¶
The device being used is not allowed to perform this action.
- RegionLocked = 83¶
The action could not be complete because it is region restricted.
- RateLimitExceeded = 84¶
Temporary rate limit exceeded. Different from
LimitExceeded
.
- LoginDeniedNeedTwoFactor = 85¶
Need two-factor code to login.
- ItemDeleted = 86¶
The thing we’re trying to access has been deleted.
- AccountLoginDeniedThrottle = 87¶
Login attempt failed, try to throttle response to possible attacker.
- TwoFactorCodeMismatch = 88¶
Two factor code mismatch.
- TwoFactorActivationCodeMismatch = 89¶
Activation code for two-factor didn’t match.
- NotModified = 91¶
Data not modified.
- TimeNotSynced = 93¶
The time presented is out of range or tolerance.
- SMSCodeFailed = 94¶
SMS code failure (no match, none pending, etc.).
- AccountActivityLimitExceeded = 96¶
Too many changes to this account.
- PhoneActivityLimitExceeded = 97¶
Too many changes to this phone.
- RefundToWallet = 98¶
Cannot refund to payment method, must use wallet.
- EmailSendFailure = 99¶
Cannot send an email.
- NotSettled = 100¶
Can’t perform operation till payment has settled.
- NeedCaptcha = 101¶
Needs to provide a valid captcha.
- GSLTDenied = 102¶
A game server login token owned by this token’s owner has been banned.
- GSOwnerDenied = 103¶
Game server owner is denied for other reason.
- InvalidItemType = 104¶
The type of thing we were requested to act on is invalid.
- IPBanned = 105¶
The IP address has been banned from taking this action.
- GSLTExpired = 106¶
This Game Server Login Token has expired from disuse; can be reset for use.
- InsufficientFunds = 107¶
User doesn’t have enough wallet funds to complete the action.
- TooManyPending = 108¶
There are too many of this thing pending already.
- NoSiteLicensesFound = 109¶
No site licenses found.
- WGNetworkSendExceeded = 110¶
The WG couldn’t send a response because we exceeded max network send size.
- AccountNotFriends = 111¶
Not friends with the relevant account.
- LimitedUserAccount = 112¶
The account is limited and cannot perform this action.
- CantRemoveItem = 113¶
Cannot remove the item.
- AccountHasBeenDeleted = 114¶
The relevant account has been deleted.
- AccountHasCancelledLicense = 115¶
The user has a user cancelled license.
- DeniedDueToCommunityCooldown = 116¶
The request was denied due to community cooldown.
- NoLauncherSpecified = 117¶
No launcher was specified.
- MustAgreeToSSA = 118¶
User must agree to china SSA or global SSA before login.
- ClientNoLongerSupported = 119¶
The specified launcher type is no longer supported.
- class steam.Universe¶
An enumeration.
- Invalid = 0¶
Invalid.
- Public = 1¶
The standard public universe.
- Beta = 2¶
Beta universe used inside Valve.
- Internal = 3¶
Internal universe used inside Valve.
- Dev = 4¶
Dev universe used inside Valve.
- Max = 6¶
Total number of universes, used for sanity checks.
- class steam.Type¶
An enumeration.
- Invalid = 0¶
Used for invalid Steam IDs.
- Individual = 1¶
Single user account.
- Multiseat = 2¶
Multiseat (e.g. cybercafe) account.
- GameServer = 3¶
Game server account.
- AnonGameServer = 4¶
Anonymous game server account.
- Pending = 5¶
Pending.
- ContentServer = 6¶
Valve internal content server account.
- Clan = 7¶
Steam clan.
- Chat = 8¶
Steam group chat or lobby.
- ConsoleUser = 9¶
Fake SteamID for local PSN account on PS3 or Live account on 360, etc.
- AnonUser = 10¶
Anonymous user account. (Used to create an account or reset a password)
- Max = 11¶
Max of 16 items in this field
- class steam.TypeChar¶
An enumeration.
- U = 1¶
The character used for
Individual
.
- G = 3¶
The character used for
GameServer
.
- A = 4¶
The character used for
AnonGameServer
.
- C = 6¶
The character used for
ContentServer
.
- class steam.InstanceFlag¶
An enumeration.
- MMSLobby = 131072¶
The Steam ID is for a MMS Lobby.
- Lobby = 262144¶
The Steam ID is for a Lobby.
- Clan = 524288¶
The Steam ID is for a Clan.
- class steam.FriendRelationship¶
An enumeration.
- NONE = 0¶
The user has no relationship to you.
- Blocked = 1¶
The user ignored the invite.
- RequestRecipient = 2¶
The user has requested to be you.
- Friend = 3¶
The user is friends with you.
- RequestInitiator = 4¶
You have requested to be friends with the user.
- Ignored = 5¶
You have explicitly blocked this other user from comments/chat/etc.
- IgnoredFriend = 6¶
The user has ignored the current user.
- Max = 8¶
The total number of friend relationships used for looping and verification.
- class steam.PersonaState¶
An enumeration.
- Offline = 0¶
The user is not currently logged on.
- Online = 1¶
The user is logged on.
- Busy = 2¶
The user is on, but busy.
- Away = 3¶
The user has been marked as AFK for a short period of time.
- Snooze = 4¶
The user has been marked as AFK for a long period of time.
- LookingToTrade = 5¶
The user is online and wanting to trade.
- LookingToPlay = 6¶
The user is online and wanting to play.
- Invisible = 7¶
The user is invisible.
- Max = 8¶
The total number of states. Only used for looping and validation.
- class steam.PersonaStateFlag¶
An enumeration.
- NONE = 0¶
- HasRichPresence = 1¶
- InJoinableGame = 2¶
- Golden = 4¶
- RemotePlayTogether = 8¶
- ClientTypeWeb = 256¶
- ClientTypeMobile = 512¶
- ClientTypeTenfoot = 1024¶
- ClientTypeVR = 2048¶
- LaunchTypeGamepad = 4096¶
- LaunchTypeCompatTool = 8192¶
- class steam.CommunityVisibilityState¶
An enumeration.
- NONE = 0¶
The user has no community state.
- Private = 1¶
The user has a private profile.
- FriendsOnly = 2¶
The user has a friends only profile.
- Public = 3¶
The user has a public profile.
- class steam.TradeOfferState¶
An enumeration.
- Invalid = 1¶
The trade offer’s state is invalid.
- Active = 2¶
The trade offer is active.
- Accepted = 3¶
The trade offer has been accepted.
- Countered = 4¶
The trade offer has been countered.
- Expired = 5¶
The trade offer has expired.
- Canceled = 6¶
The trade offer has been cancelled.
- Declined = 7¶
The trade offer has be declined by the partner.
- InvalidItems = 8¶
The trade offer has invalid items and has been cancelled.
- ConfirmationNeed = 9¶
The trade offer needs confirmation.
- CanceledBySecondaryFactor = 10¶
The trade offer was cancelled by second factor.
- StateInEscrow = 11¶
The trade offer is in escrow.
- class steam.ChatEntryType¶
An enumeration.
- Invalid = 0¶
An Invalid Chat entry.
- Text = 1¶
A Normal text message from another user.
- Typing = 2¶
Another user is typing (not used in multi-user chat).
- InviteGame = 3¶
An Invite from other user into that users current game.
- LeftConversation = 6¶
A user has left the conversation.
- Entered = 7¶
A user has entered the conversation (used in multi-user chat and group chat).
- WasKicked = 8¶
A user was kicked.
- WasBanned = 9¶
A user was banned.
- Disconnected = 10¶
A user disconnected.
- HistoricalChat = 11¶
A chat message from user’s chat history or offline message.
- LinkBlocked = 14¶
A link was removed by the chat filter.
- class steam.UIMode¶
An enumeration.
- Desktop = 0¶
The UI mode for the desktop client.
- BigPicture = 1¶
The UI mode for big picture mode.
- Mobile = 2¶
The UI mode for mobile.
- Web = 3¶
The UI mode for the web client.
- class steam.UserBadge¶
An enumeration.
- Invalid = 0¶
Invalid Badge.
- YearsOfService = 1¶
The years of service badge.
- Community = 2¶
The pillar of the community badge.
- Portal2PotatoARG = 3¶
The portal to potato badge.
- TreasureHunt = 4¶
The treasure hunter badge.
- SummerSale2011 = 5¶
The Summer sale badge for 2011.
- WinterSale2011 = 6¶
The Winter sale badge for 2011.
- SummerSale2012 = 7¶
The Summer sale badge for 2012.
- WinterSale2012 = 8¶
The Winter sale badge for 2012.
- CommunityTranslator = 9¶
The community translator badge.
- CommunityModerator = 10¶
The community moderator badge.
- ValveEmployee = 11¶
The Valve employee badge.
- GameDeveloper = 12¶
The game developer badge.
- GameCollector = 13¶
The game collector badge.
- TradingCardBetaParticipant = 14¶
The trading card beta participant badge.
- SteamBoxBeta = 15¶
The Steam box beta badge.
- Summer2014RedTeam = 16¶
The Summer sale badge for 2014 for the red team.
- Summer2014BlueTeam = 17¶
The Summer sale badge for 2014 for the blue team.
- Summer2014PinkTeam = 18¶
The Summer sale badge for 2014 for the pink team.
- Summer2014GreenTeam = 19¶
The Summer sale badge for 2014 for the green team.
- Summer2014PurpleTeam = 20¶
The Summer sale badge for 2014 for the purple team.
- Auction2014 = 21¶
The auction badge for 2014.
- GoldenProfile2014 = 22¶
The golden profile for 2014.
- TowerAttackMiniGame = 23¶
The tower attack mini-game badge.
- Winter2015ARGRedHerring = 24¶
The Winter ARG red herring badge for 2015.
- SteamAwards2016Nominations = 25¶
The Steam Awards Nominations badge for 2016.
- StickerCompletionist2017 = 26¶
The sticker completionist badge for 2017.
- SteamAwards2017Nominations = 27¶
The Steam Awards Nominations badge for 2017.
- SpringCleaning2018 = 28¶
The Spring cleaning badge for 2018.
- Salien = 29¶
The Salien badge.
- RetiredModerator = 30¶
The retired moderator badge.
- SteamAwards2018Nominations = 31¶
The Steam Awards Nominations badge for 2018.
- ValveModerator = 32¶
The Valve moderator badge.
- WinterSale2018 = 33¶
The Winter sale badge for 2018.
- LunarNewYearSale2019 = 34¶
The lunar new years sale badge for 2019.
- LunarNewYearSale2019GoldenProfile = 35¶
The lunar new year golden profile sale badge for 2019.
- SpringCleaning2019 = 36¶
The Spring cleaning badge for 2019.
- Summer2019 = 37¶
The Summer sale badge for 2019.
- Summer2019TeamHare = 38¶
The Summer sale badge for 2014 for team hare.
- Summer2019TeamTortoise = 39¶
The Summer sale badge for 2014 for team tortoise.
- Summer2019TeamCorgi = 40¶
The Summer sale badge for 2014 for team corgi.
- Summer2019TeamCockatiel = 41¶
The Summer sale badge for 2014 for team cockatiel.
- Summer2019TeamPig = 42¶
The Summer sale badge for 2014 for team pig.
- SteamAwards2019Nominations = 43¶
The Steam Awards Nominations badge for 2019.
- WinterSaleEvent2019 = 44¶
The Winter sale badge for 2019.
- WinterSale2019Steamville = 45¶
The Winter sale Steamville badge for 2019.
- LunarNewYearSale2020 = 46¶
The lunar new years sale badge for 2020.
- SpringCleaning2020 = 47¶
The Spring cleaning badge for 2020.
- AwardsCommunityContributor = 48¶
The Steam Awards Community Contributor badge.
- AwardsCommunityPatron = 49¶
The Steam Awards Community Patron badge.
- SteamAwards2020Nominations = 50¶
The Steam Awards Nominations badge for 2020.
- class steam.ReviewType¶
An enumeration.
- NONE = 0¶
No reviews.
- OverwhelminglyNegative = 1¶
0 - 19% positive reviews and few of them.
- VeryNegative = 2¶
0 - 19% positive reviews.
- Negative = 3¶
0 - 39% positive reviews.
- MostlyNegative = 4¶
20 - 39% positive reviews but few of them.
- Mixed = 5¶
40 - 69% positive reviews.
- MostlyPositive = 6¶
70 - 79% positive reviews.
- Positive = 7¶
80 - 100% positive reviews but few of them.
- VeryPositive = 8¶
94 - 80% positive reviews.
- OverwhelminglyPositive = 9¶
95 - 100% positive reviews.
- class steam.GameServerRegion¶
An enumeration.
- NONE = -1¶
No set game region.
- USEastCoast = 0¶
A server on the USA’s East Coast.
- USWestCoast = 1¶
A server on the USA’s West Coast.
- SouthAmerica = 2¶
A server in South America.
- Europe = 3¶
A server in Europe.
- Asia = 4¶
A server in Asia.
- Australia = 5¶
A server in Australia.
- MiddleEast = 6¶
A server in the Middle East.
- Africa = 7¶
A server in Africa.
- World = 255¶
A server somewhere in the world.
Guard¶
- steam.guard.generate_one_time_code(shared_secret, timestamp=None)¶
Generate a Steam Guard code for signing in or at a specific time.
- steam.guard.generate_confirmation_code(identity_secret, tag, timestamp=None)¶
Generate a trade confirmation code.
Async Iterators¶
An async iterator is a class that is capable of being used with the syntax async for.
They can be used as follows:
async for trade in client.trade_history():
... # do stuff with trade here
- class steam.iterators.AsyncIterator¶
A class from which async iterators (see PEP 525) can ben easily derived.
- async for y in x
Iterates over the contents of the async iterator.
- before¶
When to find objects before.
- Type
- after¶
When to find objects after.
- Type
- queue¶
The queue containing the elements of the iterator.
- Type
collections.deque[steam.iterators.T]
- await get(**attrs)¶
A helper function which is similar to
get()
except it runs over the async iterator.This is roughly equivalent to:
elements = await async_iterator.flatten() element = steam.utils.get(elements, name="Item")
Example
Getting the last comment from a user named ‘Dave’ or None:
comment = await user.comments().get(author__name="Dave")
- Parameters
attrs (Any) – Keyword arguments that denote attributes to match.
- Returns
The first element from the
iterable
which matches all the traits passed inattrs
orNone
if no matching element was found.- Return type
Optional
[steam.iterators.T
]
- await find(predicate)¶
A helper function which is similar to
find()
except it runs over the async iterator. However unlikefind()
, the predicate provided can be a coroutine.This is roughly equivalent to:
elements = await async_iterator.flatten() element = steam.utils.find(elements, lambda e: e.name == "Item")
Example
Getting the last trade with a message or None:
def predicate(trade: steam.TradeOffer) -> bool: return trade.message is not None trade = await client.trade_history().find(predicate)
- Parameters
predicate (MaybeCoro[T]) – A callable/coroutine that returns a boolean.
- Returns
The first element from the iterator for which the
predicate
returnsTrue
orNone
if no matching element was found.- Return type
Optional
[steam.iterators.T
]
- await flatten()¶
A helper function that iterates over the
AsyncIterator
returning a list of all the elements in the iterator.This is equivalent to:
elements = [element async for element in async_iterator]
- Return type
list
[steam.iterators.T
]
- filter(predicate)¶
Filter members of the async iterator according to a predicate. This function acts similarly to
filter()
.Examples
for dave in async_iterator.filter(lambda x: x.name == "Dave"): ... # the element now has to have a name of Dave.
- Parameters
predicate (collections.abc.Callable[steam.iterators.T, bool]) – The predicate to filter elements through.
- Return type
steam.iterators.FilteredIterator
[steam.iterators.T
]
- map(func)¶
Map the elements of the async iterator through a function. This function acts similarly to
map()
.Examples
for name in async_iterator.map(lambda x: x.name): ... # name is now the iterators element's name.
- Parameters
func (collections.abc.Callable[steam.iterators.TT, Any]) – The function to map the elements through.
- Return type
steam.iterators.MappedIterator
[steam.iterators.T
,steam.iterators.TT
]
- await next()¶
Advances the iterator by one, if possible.
- Raises
StopAsyncIteration – There are no more elements in the iterator.
- Return type
steam.iterators.T
Abstract Base Classes¶
An abstract base class (also known as an abc
) is a class that models can inherit their behaviour from.
- asyncbadges
- asyncbans
- asyncclans
- asynccomment
- defcomments
- asyncequipped_profile_items
- asyncfavourite_badge
- asyncfriends
- asyncgames
- defhas_setup_profile
- asyncinventory
- asyncis_banned
- defis_commentable
- defis_private
- defis_valid
- asynclevel
- asyncprofile
- asyncprofile_info
- asyncwishlist
- class steam.abc.BaseUser¶
An ABC that details the common operations on a Steam user. The following classes implement this ABC:
- x == y
Checks if two users are equal.
- str(x)
Returns the user’s name.
- state¶
The current persona state of the account (e.g. LookingToTrade).
- Type
Optional[steam.enums.PersonaState]
- game¶
The Game instance attached to the user. Is
None
if the user isn’t in a game or one that is recognised by the api.- Type
Optional[steam.game.StatefulGame]
- primary_clan¶
The primary clan the User displays on their profile.
Note
This can be lazily awaited to get more attributes of the clan.
- Type
Optional[steam.clan.Clan]
- created_at¶
The time at which the user’s account was created. Could be
None
.- Type
Optional[datetime.datetime]
- last_logoff¶
The last time the user logged into steam. Could be None (e.g. if they are currently online).
- Type
Optional[datetime.datetime]
- flags¶
The persona state flags of the account.
- Type
Optional[steam.enums.PersonaStateFlag]
- await inventory(game)¶
Fetch a user’s
Inventory
for trading.- Parameters
game (steam.game.Game) – The game to fetch the inventory for.
- Raises
Forbidden – The user’s inventory is private.
- Return type
- await friends()¶
Fetch the list of the users friends.
- Return type
- await badges()¶
Fetches the user’s
UserBadges
s.- Return type
- await level()¶
Fetches the user’s level if your account is premium, otherwise it’s cached.
- Return type
- await wishlist()¶
Get the
WishlistGame
s the user has on their wishlist.- Return type
- await favourite_badge()¶
The user’s favourite badge
- Return type
- await equipped_profile_items()¶
The user’s equipped profile items.
- Return type
- await profile_info()¶
The user’s profile info.
- Return type
- await profile()¶
Fetch a user’s entire profile information.
Note
This calls all the
profile_x
functions to return a Profile object which has all the info set.- Return type
- await is_banned()¶
Specifies if the user is banned from any part of Steam.
This is equivalent to:
bans = await user.bans() bans.is_banned()
- Return type
- await comment(content, *, subscribe=True)¶
Post a comment to a comments section.
- Parameters
- Returns
The created comment.
- Return type
- comments(oldest_first=False, limit=None, before=None, after=None)¶
An
AsyncIterator
for accessing a comment section’sComment
objects.Examples
Usage:
async for comment in commentable.comments(limit=10): print("Author:", comment.author, "Said:", comment.content)
Flattening into a list:
comments = await commentable.comments(limit=50).flatten() # comments is now a list of Comment
All parameters are optional.
- Parameters
oldest_first (bool) – Whether or not to request comments with the oldest comments first or last. Defaults to
False
.limit (int | None) – The maximum number of comments to search through. Default is
None
which will fetch the clan’s entire comments section.before (datetime | None) – A time to search for comments before.
after (datetime | None) – A time to search for comments after.
- Yields
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- class steam.abc.Channel¶
- abstractmethod history(limit=100, before=None, after=None)¶
An
AsyncIterator
for accessing a channel’ssteam.Message
s.Examples
Usage:
async for message in channel.history(limit=10): print("Author:", message.author, "Said:", message.content)
Flattening into a list:
messages = await channel.history(limit=50).flatten() # messages is now a list of Message
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of messages to search through. Setting this to
None
will fetch all of the channel’s messages, but this will be a very slow operation.before (datetime | None) – A time to search for messages before.
after (datetime | None) – A time to search for messages after.
- Yields
- await send(content=None, image=None)¶
Send a message to a certain destination.
- Parameters
Note
Anything as passed to
content
is implicitly cast to astr
.- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message, only applicable if
content
is passed.- Return type
Optional
[steam.abc.M_co
]
- asyncsend
- class steam.abc.Messageable¶
An ABC that details the common operations on a Steam message. The following classes implement this ABC:
- await send(content=None, image=None)¶
Send a message to a certain destination.
- Parameters
content (Optional[Any]) – The content of the message to send.
image (Optional[steam.image.Image]) – The image to send to the user.
Note
Anything as passed to
content
is implicitly cast to astr
.- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message, only applicable if
content
is passed.- Return type
Optional
[steam.abc.M_co
]
Steam Models¶
steam.py provides wrappers around common Steam API objects. These are not meant to be constructed by the user instead you receive them from methods/events.
Badge¶
- class steam.Badge¶
Represents a Steam badge.
- game¶
The game associated with the badge.
- Type
Optional[steam.game.StatefulGame]
- completion_time¶
The time the badge was completed at.
- Type
- class steam.UserBadges¶
Represents a Steam
User
’s badges/level.- xp_needed_for_current_level¶
The amount of XP the user’s current level requires to achieve.
- Type
- badges¶
A list of the user’s badges.
- Type
Sequence[steam.Badge]
- class steam.FavouriteBadge¶
Represents a User’s favourite badge.
- game¶
The game associated with the badge.
- Type
Optional[steam.game.StatefulGame]
Ban¶
- defis_banned
- defis_community_banned
- defis_market_banned
- defis_vac_banned
Channel¶
- async forhistory
- asyncsend
- asynctrigger_typing
- async withtyping
- class steam.DMChannel¶
Represents the channel a DM is sent in.
- participant¶
The recipient of any messages sent.
- Type
- async with typing()¶
Send a typing indicator continuously to the channel while in the context manager.
Note
This only works in DMs.
Usage:
async with ctx.channel.typing(): ... # do your expensive operations
- Return type
- await trigger_typing()¶
Send a typing indicator to the channel once.
Note
This only works in DMs.
- history(limit=100, before=None, after=None)¶
An
AsyncIterator
for accessing a channel’ssteam.Message
s.Examples
Usage:
async for message in channel.history(limit=10): print("Author:", message.author, "Said:", message.content)
Flattening into a list:
messages = await channel.history(limit=50).flatten() # messages is now a list of Message
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of messages to search through. Setting this to
None
will fetch all of the channel’s messages, but this will be a very slow operation.before (datetime | None) – A time to search for messages before.
after (datetime | None) – A time to search for messages after.
- Yields
- await send(content=None, image=None)¶
Send a message to a certain destination.
- Parameters
content (Optional[Any]) – The content of the message to send.
image (Optional[steam.image.Image]) – The image to send to the user.
Note
Anything as passed to
content
is implicitly cast to astr
.- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message, only applicable if
content
is passed.- Return type
Optional
[steam.abc.M_co
]
- class steam.GroupChannel¶
Represents a group channel.
- name¶
The name of the channel, this could be the same as the
name
if it’s the main channel.- Type
Optional[str]
- group¶
The group to which messages are sent.
- Type
Optional[steam.group.Group]
- joined_at¶
The time the client joined the chat.
- Type
Optional[datetime.datetime]
- last_message¶
The last message sent in the channel.
- Type
Optional[steam.abc.M_co]
- history(limit=100, before=None, after=None)¶
An
AsyncIterator
for accessing a channel’ssteam.Message
s.Examples
Usage:
async for message in channel.history(limit=10): print("Author:", message.author, "Said:", message.content)
Flattening into a list:
messages = await channel.history(limit=50).flatten() # messages is now a list of Message
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of messages to search through. Setting this to
None
will fetch all of the channel’s messages, but this will be a very slow operation.before (datetime | None) – A time to search for messages before.
after (datetime | None) – A time to search for messages after.
- Yields
- await send(content=None, image=None)¶
Send a message to a certain destination.
- Parameters
content (Optional[Any]) – The content of the message to send.
image (Optional[steam.image.Image]) – The image to send to the user.
Note
Anything as passed to
content
is implicitly cast to astr
.- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message, only applicable if
content
is passed.- Return type
Optional
[steam.abc.M_co
]
- class steam.ClanChannel¶
Represents a group channel.
- name¶
The name of the channel, this could be the same as the
name
if it’s the main channel.- Type
Optional[str]
- clan¶
The clan to which messages are sent.
- Type
Optional[steam.clan.Clan]
- joined_at¶
The time the client joined the chat.
- Type
Optional[datetime.datetime]
- last_message¶
The last message sent in the channel.
- Type
Optional[steam.abc.M_co]
- history(limit=100, before=None, after=None)¶
An
AsyncIterator
for accessing a channel’ssteam.Message
s.Examples
Usage:
async for message in channel.history(limit=10): print("Author:", message.author, "Said:", message.content)
Flattening into a list:
messages = await channel.history(limit=50).flatten() # messages is now a list of Message
All parameters are optional.
- Parameters
limit (Optional[int]) – The maximum number of messages to search through. Setting this to
None
will fetch all of the channel’s messages, but this will be a very slow operation.before (Optional[datetime.datetime]) – A time to search for messages before.
after (Optional[datetime.datetime]) – A time to search for messages after.
- Yields
- await send(content=None, image=None)¶
Send a message to a certain destination.
- Parameters
content (Optional[Any]) – The content of the message to send.
image (Optional[steam.image.Image]) – The image to send to the user.
Note
Anything as passed to
content
is implicitly cast to astr
.- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message, only applicable if
content
is passed.- Return type
Optional
[steam.abc.M_co
]
Clan¶
- active_member_count
- admins
- avatar_url
- channels
- chat_id
- content
- created_at
- default_channel
- default_role
- description
- from_url
- game
- icon_url
- id
- id2
- id2_zero
- id3
- id64
- in_game_count
- instance
- invite_code
- invite_url
- language
- location
- member_count
- mods
- name
- online_count
- owner
- roles
- tagline
- top_members
- type
- universe
- async forannouncements
- asynccomment
- defcomments
- asynccreate_announcement
- asynccreate_event
- async forevents
- asyncfetch_announcement
- asyncfetch_event
- asyncfetch_members
- defget_channel
- asyncinvite
- defis_valid
- asyncjoin
- asyncleave
- class steam.Clan¶
Represents a Steam clan.
- x == y
Checks if two clans are equal.
- str(x)
Returns the clan’s name.
- created_at¶
The time the clan was created_at.
- Type
Optional[datetime.datetime]
- game¶
The clan’s associated game.
- Type
Optional[steam.game.StatefulGame]
- owner¶
The clan’s owner.
- Type
Optional[steam.user.User]
- admins¶
A list of the clan’s administrators.
- Type
- mods¶
A list of the clan’s moderators.
- Type
- top_members¶
A list of the clan’s top_members.
- Type
list[typing.Optional[steam.user.User]]
- default_role¶
The clan’s default role.
- Type
Optional[steam.role.Role]
- property channels: list[steam.ClanChannel]¶
A list of the clan’s channels.
- property default_channel: ClanChannel | None¶
The clan’s default channel.
- await fetch_members()¶
Fetches a clan’s member list.
Note
This can be a very slow operation due to the rate limits on this endpoint.
- Return type
- property description: str¶
An alias to
content
.Deprecated since version 0.8.0: Use
content
instead.
- property icon_url: str¶
An alias to
avatar_url
.Deprecated since version 0.8.0: Use
avatar_url
instead.
- await join()¶
Joins the clan. This will also join the clan’s chat.
- await leave()¶
Leaves the clan.
- await invite(user)¶
Invites a
User
to the clan.- Parameters
user (User) – The user to invite to the clan.
- await fetch_event(id)¶
Fetch an event from its ID.
- Parameters
id (int) – The ID of the event.
- Return type
steam.event.Event
- await fetch_announcement(id)¶
Fetch an announcement from its ID.
- Parameters
id (int) – The ID of the announcement.
- Return type
steam.event.Announcement
- events(limit=100, before=None, after=None)¶
An
AsyncIterator
over a clan’ssteam.Event
s.Examples
Usage:
async for event in client.events(limit=10): print(event.author, "made an event", event.name, "starting at", event.starts_at)
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of events to search through. Default is
100
. Setting this toNone
will fetch all of the clan’s events, but this will be a very slow operation.before (datetime | None) – A time to search for events before.
after (datetime | None) – A time to search for events after.
- Yields
Event
- announcements(limit=100, before=None, after=None)¶
An
AsyncIterator
over a clan’ssteam.Announcement
s.Examples
Usage:
async for announcement in client.announcements(limit=10): print(announcement.author, "made an announcement", announcement.name, "at", announcement.created_at)
All parameters are optional.
- Parameters
limit (int | None) – The maximum number of announcements to search through. Default is
100
. Setting this toNone
will fetch all of the clan’s announcements, but this will be a very slow operation.before (datetime | None) – A time to search for announcements before.
after (datetime | None) – A time to search for announcements after.
- Yields
Announcement
- await comment(content, *, subscribe=True)¶
Post a comment to a comments section.
- Parameters
- Returns
The created comment.
- Return type
- comments(oldest_first=False, limit=None, before=None, after=None)¶
An
AsyncIterator
for accessing a comment section’sComment
objects.Examples
Usage:
async for comment in commentable.comments(limit=10): print("Author:", comment.author, "Said:", comment.content)
Flattening into a list:
comments = await commentable.comments(limit=50).flatten() # comments is now a list of Comment
All parameters are optional.
- Parameters
oldest_first (bool) – Whether or not to request comments with the oldest comments first or last. Defaults to
False
.limit (Optional[int]) – The maximum number of comments to search through. Default is
None
which will fetch the clan’s entire comments section.before (Optional[datetime.datetime]) – A time to search for comments before.
after (Optional[datetime.datetime]) – A time to search for comments after.
- Yields
- await create_event(name: str, content: str, *, type: Literal[<ClanEvent.Other: 1>, <ClanEvent.Chat: 9>, <ClanEvent.Party: 3>, <ClanEvent.Meeting: 4>, <ClanEvent.SpecialCause: 5>, <ClanEvent.MusicAndArts: 6>, <ClanEvent.Sports: 7>, <ClanEvent.Trip: 8>] = 'ClanEvent.Other', starts_at: datetime | None = 'None') steam.event.Event ¶
- await create_event(name: str, content: str, *, game: steam.game.Game, type: Literal[<ClanEvent.Game: 2>] = ClanEvent.Other, starts_at: datetime | None = None, server_address: str | None = None, server_password: str | None = None) steam.event.Event
Create an event.
- Parameters
name – The name of the event
content – The content for the event.
type – The type of the event, defaults to
ClanEvent.Other
.game – The game that will be played in the event. Required if type is
ClanEvent.Game
.starts_at – The time the event will start at.
server_address – The address of the server that the event will be played on. This is only allowed if
type
isClanEvent.Game
.server_password – The password for the server that the event will be played on. This is only allowed if
type
isClanEvent.Game
.
Note
It is recommended to use a timezone aware datetime for
start
.- Returns
The created event.
- Return type
steam.event.Event
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- await create_announcement(name, content, hidden=False)¶
Create an announcement.
Comment¶
- class steam.Comment¶
Represents a comment on a Steam profile.
- author¶
The author of the comment.
- Type
Union[steam.user.User, steam.user.ClientUser]
- created_at¶
The time the comment was posted at.
- Type
- owner¶
The comment sections owner.
- Type
steam.comment.C
- await report()¶
Reports the comment.
- await delete()¶
Deletes the comment.
Game Servers¶
- defis_dedicated
- defis_secure
- defis_valid
- asyncplayers
- asyncrules
- class steam.GameServer¶
Represents a game server.
- game¶
The game of the server.
- region¶
The region the server is in.
- Type
Any
- await players(*, challenge=0)¶
Fetch a server’s players or
None
if something went wrong getting the info.- Parameters
challenge (Literal[-1, 0]) – The challenge for the request default is 0 can also be -1. You may need to change if the server doesn’t seem to respond.
Note
It is recommended to use
asyncio.wait_for()
to allow this to return if the server doesn’t respond.Returns ServerPlayer is a
typing.NamedTuple
defined as:class ServerPlayer(NamedTuple): index: int name: str score: int play_time: timedelta
- await rules(*, challenge=0)¶
Fetch a console variables. e.g.
sv_gravity
orsv_voiceenable
.- Parameters
challenge (Literal[-1, 0]) – The challenge for the request default is 0 can also be -1. You may need to change if the server doesn’t seem to respond.
Note
It is recommended to use
asyncio.wait_for()
to allow this to return if the server doesn’t respond.
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- clsQuery.all
- clsQuery.dedicated
- clsQuery.empty
- clsQuery.ip
- clsQuery.linux
- clsQuery.match_any_hidden_tags
- clsQuery.match_hidden_tags
- clsQuery.match_tags
- clsQuery.name_match
- clsQuery.no_password
- clsQuery.not_empty
- clsQuery.not_full
- clsQuery.not_running
- clsQuery.proxy
- clsQuery.running
- clsQuery.running_map
- clsQuery.running_mod
- clsQuery.secure
- clsQuery.unique_addresses
- clsQuery.version_match
- clsQuery.whitelisted
- class steam.Query¶
A
pathlib.Path
like class for constructing Global Master Server queries.- x == y
Checks if two queries are equal, order is checked.
- x / y
Appends y’s query to x.
- x | y
Combines the two queries in
\nor\[x\y]
(not or).
- x & y
Combines the two queries in
\nand\[x\y]
(not and).
Examples
>>> Query.running / TF2 / Query.not_empty / Query.secure <Query query='\\appid\\440\\empty\\1\\secure\\1'> # matches games running TF2, that are not empty and are using VAC >>> Query.not_empty / Query.not_full | Query.secure <Query query='\\empty\\1\\nor\\[\\full\\1\\secure\\1]'> # matches games that are not empty, not full and are using VAC >>> Query.name_match / "A not cool server" | Query.match_tags / ["alltalk", "increased_maxplayers"] <Query query='\\nor\\[\\name_match\\A not cool server\\gametype\\[alltalk,increased_maxplayers]]'> # matches games where the server name is not "A cool Server" or the server doesn't support alltalk or increased # max players >>> Query.linux & Query.no_password # matches games where the server is not on linux and the server doesn't have no password (has a password)
- class property all: steam.game_server.QueryAll¶
Fetches any servers. Any operations on this will fail.
- class property dedicated: Q¶
Fetches servers that are running dedicated.
- class property empty: Q¶
Fetches servers that are empty.
- class property ip: Query[str]¶
Fetches servers on the specified IP address, port is optional.
See also
- class property linux: Q¶
Fetches servers running on a Linux platform.
Fetches servers with any of the given tag(s) in their ‘hidden’ tags only applies for
steam.LFD2
.
Fetches servers with all of the given tag(s) in their ‘hidden’ tags only applies for
steam.LFD2
.
- class property match_tags: Query[list[str]]¶
Fetches servers with all of the given tag(s) in
GameServer.tags
.
- class property name_match: Query[str]¶
Fetches servers with their hostname matching “x” (
"*"
is wildcard).
- class property no_password: Q¶
Fetches servers that are not password protected.
- class property not_empty: Q¶
Fetches servers that are not empty.
- class property not_full: Q¶
Fetches servers that are not full.
- class property proxy: Q¶
Fetches servers that are spectator proxies.
- class property running_mod: Query[str]¶
Fetches servers running the specified modification (e.g. cstrike).
- class property secure: Q¶
Fetches servers that are using anti-cheat technology (VAC, but potentially others as well).
- class property unique_addresses: Q¶
Fetches only one server for each unique IP address matched.
- class property whitelisted: Q¶
Fetches servers that are whitelisted.
Group¶
- class steam.Group¶
Represents a Steam group.
- owner¶
The owner of the group.
- Type
Union[steam.user.User, steam.abc.SteamID]
- members¶
A list of the group’s members.
- Type
- default_role¶
The group’s default role.
- Type
Optional[steam.role.Role]
- default_channel¶
The group’s default channel.
- Type
- property channels: list[steam.GroupChannel]¶
A list of the group’s channels.
- await leave()¶
Leaves the group.
- await invite(user)¶
Invites a
User
to the group.- Parameters
user (User) – The user to invite to the group.
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
Invite¶
- class steam.UserInvite¶
Represents a invite from a user to become their friend.
- invitee¶
The user who sent the invite.
- Type
Union[steam.user.User, steam.abc.SteamID]
- relationship¶
The relationship you have with the invitee. This
None
if the invite was sent while the bot is online.- Type
Optional[steam.enums.FriendRelationship]
- await accept()¶
Accept the invite request.
- await decline()¶
Decline the invite request.
- class steam.ClanInvite¶
Represents a invite to join a
Clan
from a user.- clan¶
The clan to join.
- Type
Union[steam.Clan, steam.abc.SteamID]
- invitee¶
The user who sent the invite.
- Type
Union[steam.user.User, steam.abc.SteamID]
- relationship¶
The relationship you have with the clan.
- Type
Optional[steam.enums.FriendRelationship]
- await accept()¶
Accept the invite request.
- await decline()¶
Decline the invite request.
Message¶
- class steam.Message¶
Represents a message from a
User
. This is a base class from which all messages inherit.The following classes implement this:
- channel¶
The channel the message was sent in.
- content¶
The message’s content.
Note
This is not what you will see in the steam client see
clean_content
for that.- Type
- author¶
The message’s author.
- Type
Authors
- created_at¶
The time the message was sent at.
- Type
- group¶
The group the message was sent in. Will be
None
if the message wasn’t sent in aGroup
.- Type
Optional[steam.Group]
- clan¶
The clan the message was sent in. Will be
None
if the message wasn’t sent in aClan
.- Type
Optional[steam.Clan]
- id¶
A unique identifier for every message sent in a channel.
- class steam.UserMessage¶
Represents a message from a user.
- id¶
A unique identifier for every message sent in a channel.
- class steam.GroupMessage¶
Represents a message in a group.
- id¶
A unique identifier for every message sent in a channel.
PriceOverview¶
- class steam.PriceOverview¶
Represents the data received from https://steamcommunity.com/market/priceoverview.
Profile¶
- class steam.ProfileInfo¶
Represents the user’s profile info.
- created_at¶
The time at which the user was created at.
- Type
- class steam.ProfileItem¶
Represents an item on/in a user’s profile.
- game¶
The game the item is from.
- type¶
The item’s type.
- Type
Any
- movie¶
The movie associated with the item.
- Type
steam.profile.ProfileMovie
- await equip()¶
Equip the profile item.
- class steam.OwnedProfileItems¶
Represents the
ClientUser
's owned items.- backgrounds¶
The backgrounds the client user owns.
- Type
- mini_profile_backgrounds¶
The mini profile backgrounds the client user owns.
- Type
- avatar_frames¶
The avatar frames the client user owns.
- Type
- animated_avatars¶
The animated avatars the client user owns.
- Type
- modifiers¶
The modifiers the client user owns.
- Type
- class steam.EquippedProfileItems¶
Represents the items the user has equipped.
- background¶
The equipped background.
- Type
Optional[steam.ProfileItem]
- mini_profile_background¶
The equipped mini profile background for the user.
- Type
Optional[steam.ProfileItem]
- avatar_frame¶
The equipped avatar frame for the user.
- Type
Optional[steam.ProfileItem]
- animated_avatar¶
The equipped animated avatar for the user.
- Type
Optional[steam.ProfileItem]
- modifier¶
The equipped modifier for the user.
- Type
Optional[steam.ProfileItem]
- class steam.Profile¶
Represents a user’s complete profile.
- background¶
The equipped background.
- Type
Optional[steam.ProfileItem]
- mini_profile_background¶
The equipped mini profile background for the user.
- Type
Optional[steam.ProfileItem]
- avatar_frame¶
The equipped avatar frame for the user.
- Type
Optional[steam.ProfileItem]
- animated_avatar¶
The equipped animated avatar for the user.
- Type
Optional[steam.ProfileItem]
- modifier¶
The equipped modifier for the user.
- Type
Optional[steam.ProfileItem]
- items¶
The account’s owned profile items.
Note
This is only available for the
ClientUser
's profile otherwise it isNone
.- Type
Optional[steam.OwnedProfileItems]
Trading¶
- class steam.Inventory¶
Represents a User’s inventory.
- len(x)
Returns how many items are in the inventory.
- iter(x)
Iterates over the inventory’s items.
- y in x
Determines if an item is in the inventory based off of its
class_id
andinstance_id
.
- items¶
A list of the inventory’s items.
- Type
Sequence[steam.trade.I]
- owner¶
The owner of the inventory.
- Type
- game¶
The game the inventory the game belongs to.
- filter_items(*names, limit=None)¶
A helper function that filters items by name from the inventory.
- Parameters
- Raises
ValueError – You passed a limit and multiple item names.
- Returns
The matching items.
- Return type
list
[steam.trade.I
]
- get_item(name)¶
A helper function that gets an item or
None
if no matching item is found by name from the inventory.
- await update()¶
Re-fetches the inventory.
- defis_marketable
- defis_tradable
- class steam.Item¶
Represents an item in an User’s inventory.
- x == y
Checks if two items are equal.
Users¶
- asyncbadges
- asyncbans
- asyncclans
- asyncclear_nicks
- asynccomment
- defcomments
- asyncedit
- asyncequipped_profile_items
- asyncfavourite_badge
- asyncgames
- defhas_setup_profile
- asyncinventory
- asyncis_banned
- defis_commentable
- defis_private
- defis_valid
- asynclevel
- asyncprofile
- asyncprofile_info
- asyncprofile_items
- asyncsetup_profile
- asyncwishlist
- class steam.ClientUser¶
Represents your account.
- x == y
Checks if two users are equal.
- str(x)
Returns the user’s name.
- friends¶
A list of the
ClientUser
’s friends.- Type
- state¶
The current persona state of the account (e.g. LookingToTrade).
- Type
Optional[steam.enums.PersonaState]
- game¶
The Game instance attached to the user. Is
None
if the user isn’t in a game or one that is recognised by the api.
- primary_clan¶
The user’s primary clan. Could be
None
- Type
Optional[steam.Clan]
- created_at¶
The time at which the user’s account was created. Could be
None
.- Type
Optional[datetime.datetime]
- last_logon¶
The last time the user logged into steam. This is only
None
if user hasn’t been updated from the websocket.- Type
Optional[datetime.datetime]
- last_logoff¶
The last time the user logged off from steam. Could be
None
(e.g. if they are currently online).- Type
Optional[datetime.datetime]
- last_seen_online¶
The last time the user could be seen online. This is only
None
if user hasn’t been updated from the websocket.- Type
Optional[datetime.datetime]
- flags¶
The persona state flags of the account.
- Type
Optional[steam.enums.PersonaStateFlag]
- await setup_profile()¶
Set up your profile if possible.
- await clear_nicks()¶
Clears the client user’s nickname/alias history.
- await profile_items()¶
Fetch all of the client user’s profile items.
- Return type
- await edit(*, name=None, real_name=None, url=None, summary=None, country=None, state=None, city=None, avatar=None)¶
Edit the client user’s profile. Any values that aren’t set will use their defaults.
- Parameters
- Raises
HTTPException – Editing your profile failed.
- await badges()¶
Fetches the user’s
UserBadges
s.- Return type
- await comment(content, *, subscribe=True)¶
Post a comment to a comments section.
- Parameters
- Returns
The created comment.
- Return type
- comments(oldest_first=False, limit=None, before=None, after=None)¶
An
AsyncIterator
for accessing a comment section’sComment
objects.Examples
Usage:
async for comment in commentable.comments(limit=10): print("Author:", comment.author, "Said:", comment.content)
Flattening into a list:
comments = await commentable.comments(limit=50).flatten() # comments is now a list of Comment
All parameters are optional.
- Parameters
oldest_first (bool) – Whether or not to request comments with the oldest comments first or last. Defaults to
False
.limit (Optional[int]) – The maximum number of comments to search through. Default is
None
which will fetch the clan’s entire comments section.before (Optional[datetime.datetime]) – A time to search for comments before.
after (Optional[datetime.datetime]) – A time to search for comments after.
- Yields
- await equipped_profile_items()¶
The user’s equipped profile items.
- Return type
- await favourite_badge()¶
The user’s favourite badge
- Return type
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- await inventory(game)¶
Fetch a user’s
Inventory
for trading.- Parameters
game (steam.game.Game) – The game to fetch the inventory for.
- Raises
Forbidden – The user’s inventory is private.
- Return type
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- await is_banned()¶
Specifies if the user is banned from any part of Steam.
This is equivalent to:
bans = await user.bans() bans.is_banned()
- Return type
- await level()¶
Fetches the user’s level if your account is premium, otherwise it’s cached.
- Return type
- await profile()¶
Fetch a user’s entire profile information.
Note
This calls all the
profile_x
functions to return a Profile object which has all the info set.- Return type
- await profile_info()¶
The user’s profile info.
- Return type
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- await wishlist()¶
Get the
WishlistGame
s the user has on their wishlist.- Return type
- asyncadd
- asyncbadges
- asyncbans
- asyncblock
- asynccancel_invite
- asyncclans
- asynccomment
- defcomments
- asyncequipped_profile_items
- asyncescrow
- asyncfavourite_badge
- asyncfriends
- asyncgames
- defhas_setup_profile
- asyncinventory
- asyncinvite_to_clan
- asyncinvite_to_group
- asyncis_banned
- defis_commentable
- defis_friend
- defis_private
- defis_valid
- asynclevel
- asyncowns
- asyncprofile
- asyncprofile_info
- asyncremove
- asyncsend
- asyncunblock
- asyncwishlist
- class steam.User¶
Represents a Steam user’s account.
- x == y
Checks if two users are equal.
- str(x)
Returns the user’s name.
- state¶
The current persona state of the account (e.g. LookingToTrade).
- Type
Optional[steam.enums.PersonaState]
- game¶
The Game instance attached to the user. Is
None
if the user isn’t in a game or one that is recognised by the api.
- primary_clan¶
The user’s primary clan.
- Type
Optional[steam.Clan]
- created_at¶
The time at which the user’s account was created. Could be
None
.- Type
Optional[datetime.datetime]
- last_logon¶
The last time the user logged into steam. This is only
None
if user hasn’t been updated from the websocket.- Type
Optional[datetime.datetime]
- last_logoff¶
The last time the user logged off from steam. Could be
None
(e.g. if they are currently online).- Type
Optional[datetime.datetime]
- last_seen_online¶
The last time the user could be seen online. This is only
None
if user hasn’t been updated from the websocket.- Type
Optional[datetime.datetime]
- flags¶
The persona state flags of the account.
- Type
Optional[steam.enums.PersonaStateFlag]
- await add()¶
Sends a friend invite to the user to your friends list.
- await remove()¶
Remove the user from your friends list.
- await cancel_invite()¶
Cancels an invite sent to the user. This effectively does the same thing as
remove()
.
- await block()¶
Blocks the user.
- await unblock()¶
Unblocks the user.
- await escrow(token=None)¶
Check how long any received items would take to arrive.
None
if the user has no escrow or has a private inventory.
- await send(content=None, *, trade=None, image=None)¶
Send a message, trade or image to an
User
.- Parameters
content (Any) – The message to send to the user.
trade (TradeOffer | None) –
The trade offer to send to the user.
Note
This will have its
id
attribute updated after being sent.
- Raises
HTTPException – Sending the message failed.
Forbidden – You do not have permission to send the message.
- Returns
The sent message only applicable if
content
is passed.- Return type
- await invite_to_group(group)¶
Invites the user to a
Group
.- Parameters
group (Group) – The group to invite the user to.
- await invite_to_clan(clan)¶
Invites the user to a
Clan
.- Parameters
clan (Clan) – The clan to invite the user to.
- await owns(game)¶
Whether or not the game is owned by this user.
- is_friend()¶
Whether or not the user is in the
ClientUser
’s friends.- Return type
- await badges()¶
Fetches the user’s
UserBadges
s.- Return type
- await comment(content, *, subscribe=True)¶
Post a comment to a comments section.
- Parameters
- Returns
The created comment.
- Return type
- comments(oldest_first=False, limit=None, before=None, after=None)¶
An
AsyncIterator
for accessing a comment section’sComment
objects.Examples
Usage:
async for comment in commentable.comments(limit=10): print("Author:", comment.author, "Said:", comment.content)
Flattening into a list:
comments = await commentable.comments(limit=50).flatten() # comments is now a list of Comment
All parameters are optional.
- Parameters
oldest_first (bool) – Whether or not to request comments with the oldest comments first or last. Defaults to
False
.limit (Optional[int]) – The maximum number of comments to search through. Default is
None
which will fetch the clan’s entire comments section.before (Optional[datetime.datetime]) – A time to search for comments before.
after (Optional[datetime.datetime]) – A time to search for comments after.
- Yields
- await equipped_profile_items()¶
The user’s equipped profile items.
- Return type
- await favourite_badge()¶
The user’s favourite badge
- Return type
- await friends()¶
Fetch the list of the users friends.
- Return type
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- await inventory(game)¶
Fetch a user’s
Inventory
for trading.- Parameters
game (steam.game.Game) – The game to fetch the inventory for.
- Raises
Forbidden – The user’s inventory is private.
- Return type
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- await is_banned()¶
Specifies if the user is banned from any part of Steam.
This is equivalent to:
bans = await user.bans() bans.is_banned()
- Return type
- await level()¶
Fetches the user’s level if your account is premium, otherwise it’s cached.
- Return type
- await profile()¶
Fetch a user’s entire profile information.
Note
This calls all the
profile_x
functions to return a Profile object which has all the info set.- Return type
- await profile_info()¶
The user’s profile info.
- Return type
- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- await wishlist()¶
Get the
WishlistGame
s the user has on their wishlist.- Return type
Data-Classes¶
There are a few classes that can be constructed by the user, these include.
Game¶
- class steam.Game(*, id: Intable, name: str | None = '...', context_id: int | None = '...')¶
-
class steam.Game(*, name: Literal[
'Team Fortress 2'], id: Intable = '...', context_id: int | None = '...') -
class steam.Game(*, name: Literal[
'Left 4 Dead 2'], id: Intable = '...', context_id: int | None = '...') -
class steam.Game(*, name: Literal[
'DOTA 2'], id: Intable = '...', context_id: int | None = '...') -
class steam.Game(*, name: Literal[
'Counter Strike Global-Offensive'], id: Intable = '...', context_id: int | None = '...') -
class steam.Game(*, name: Literal[
'Steam'], id: Intable = '...', context_id: int | None = '...') Represents a Steam game.
- name¶
The game’s name.
- id¶
The game’s app ID.
- context_id¶
The context id of the game normally
2
.
There are some predefined games which are:
Game Title |
Accessed via |
---|---|
Team Fortress 2 |
|
DOTA2 |
|
Counter Strike Global-Offensive |
|
Left for Dead 2 |
|
Steam |
|
Games can be manually constructed using there app id eg:
my_rust_instance = steam.Game(id=252490, title="Rust")
# this can then be used for trading a game title is not required for this
# but it is for setting in game statuses if the game isn't a Steam game.
- steam.CUSTOM_GAME(name: str) steam.Game ¶
Create a custom game instance for
change_presence()
. TheGame.id
will be set to15190414816125648896
and theGame.context_id
toNone
.Example:
await client.change_presence(game=steam.CUSTOM_GAME("my cool game"))
- Parameters
name – The name of the game to set your playing status to.
- Return type
- asyncclan
- asyncfetch
- asyncfriends_who_own
- defis_steam_game
- asyncplayer_count
- class steam.game.StatefulGame¶
Games that have state.
- await clan()¶
Fetch this game’s clan.
This can be useful to get a Game’s updates.
clan = await game.clan() async for update in clan.announcements().filter( lambda announcement: announcement.type in (steam.ClanEvent.MajorUpdate, steam.ClanEvent.SmallUpdate) ): ... # do something with the update
- Raises
ValueError – This game has no associated clan.
- Return type
- await friends_who_own()¶
Fetch the users in your friend list who own this game.
- Return type
- await fetch()¶
Short hand for:
game = await client.fetch_game(game)
- Return type
- asyncclan
- asyncfetch
- asyncfriends_who_own
- defhas_visible_stats
- defis_steam_game
- asyncplayer_count
- class steam.UserGame¶
Represents a Steam game fetched by
steam.User.games()
- total_play_time¶
The total time the game has been played for.
- Type
- await clan()¶
Fetch this game’s clan.
This can be useful to get a Game’s updates.
clan = await game.clan() async for update in clan.announcements().filter( lambda announcement: announcement.type in (steam.ClanEvent.MajorUpdate, steam.ClanEvent.SmallUpdate) ): ... # do something with the update
- Raises
ValueError – This game has no associated clan.
- Return type
- await fetch()¶
Short hand for:
game = await client.fetch_game(game)
- Return type
- await friends_who_own()¶
Fetch the users in your friend list who own this game.
- Return type
- asyncclan
- asyncfetch
- asyncfriends_who_own
- defis_free
- defis_on_linux
- defis_on_mac_os
- defis_on_windows
- defis_steam_game
- asyncplayer_count
- class steam.WishlistGame¶
Represents a Steam game fetched by
steam.User.wishlist()
.- added_at¶
The time the the game was added to their wishlist.
- Type
- created_at¶
The time the game was uploaded at.
- Type
- review_status¶
The review status of the game.
- Type
Any
- await clan()¶
Fetch this game’s clan.
This can be useful to get a Game’s updates.
clan = await game.clan() async for update in clan.announcements().filter( lambda announcement: announcement.type in (steam.ClanEvent.MajorUpdate, steam.ClanEvent.SmallUpdate) ): ... # do something with the update
- Raises
ValueError – This game has no associated clan.
- Return type
- await fetch()¶
Short hand for:
game = await client.fetch_game(game)
- Return type
- await friends_who_own()¶
Fetch the users in your friend list who own this game.
- Return type
- asyncclan
- asyncfetch
- asyncfriends_who_own
- defis_free
- defis_on_linux
- defis_on_mac_os
- defis_on_windows
- defis_steam_game
- asyncplayer_count
- class steam.FetchedGame¶
Represents a Steam game fetched by
steam.Client.fetch_game()
.- created_at¶
The time the game was uploaded at.
- Type
Optional[datetime.datetime]
- type¶
The type of the app.
- Type
Union[Literal[‘game’], Literal[‘dlc’], Literal[‘demo’], Literal[‘advertising’], Literal[‘mod’], Literal[‘video’]]
- dlc¶
The game’s downloadable content.
- Type
Optional[list[steam.Game]]
- movies¶
A list of the game’s movies, each of which has
name
,id
,url
and optionalcreated_at
attributes.- Type
Optional[list[steam.game.Movie]]
- await clan()¶
Fetch this game’s clan.
This can be useful to get a Game’s updates.
clan = await game.clan() async for update in clan.announcements().filter( lambda announcement: announcement.type in (steam.ClanEvent.MajorUpdate, steam.ClanEvent.SmallUpdate) ): ... # do something with the update
- Raises
ValueError – This game has no associated clan.
- Return type
- await fetch()¶
Short hand for:
game = await client.fetch_game(game)
- Return type
- await friends_who_own()¶
Fetch the users in your friend list who own this game.
- Return type
Steam IDs¶
- defis_valid
- class steam.SteamID(id=0, type=None, universe=None, instance=None)¶
Convert a Steam ID between its various representations.
Note
See
steam.utils.make_id64()
for the full parameter list.- property type: steam.enums.Type¶
The Steam type of the SteamID.
- property universe: steam.enums.Universe¶
The Steam universe of the SteamID.
- property id2_zero: str¶
The SteamID’s ID 2 accounted for bugged GoldSrc and Orange Box games.
Note
In these games the accounts
universe
,1
forType.Public
, should be theX
component ofSTEAM_X:0:1234
however, this was bugged and the value ofX
was0
.e.g
STEAM_0:0:1234
.
- property invite_code: str | None¶
The SteamID’s invite code in the s.team invite code format.
e.g.
cv-dgb
.
- staticmethod await from_url(url, session=None)¶
A helper function creates a SteamID instance from a Steam community url.
Note
See
id64_from_url()
for the full parameter list.- Return type
TradeOffers¶
- class steam.TradeOffer(*, message=None, token=None, item_to_send=None, item_to_receive=None, items_to_send=None, items_to_receive=None)¶
Represents a trade offer from/to send to a User. This can also be used in
steam.User.send()
.- Parameters
item_to_send (Items | None) – The item to send with the trade offer.
item_to_receive (Items | None) – The item to receive with the trade offer.
items_to_send (list) – The items you are sending to the other user.
items_to_receive (list) – The items you are receiving from the other user.
token (Optional[str]) – The the trade token used to send trades to users who aren’t on the ClientUser’s friend’s list.
message (Optional[str]) – The offer message to send with the trade.
- partner¶
The trade offer partner. This should only ever be a
SteamID
if the partner’s profile is private.- Type
Optional[Union[steam.User, steam.abc.SteamID]]
- state¶
The offer state of the trade for the possible types see
TradeOfferState
.- Type
- created_at¶
The time at which the trade was created.
- Type
Optional[datetime.datetime]
- updated_at¶
The time at which the trade was last updated.
- Type
Optional[datetime.datetime]
- expires¶
The time at which the trade automatically expires.
- Type
Optional[datetime.datetime]
- escrow¶
The time at which the escrow will end. Can be
None
if there is no escrow on the trade.Warning
This isn’t likely to be accurate, use
User.escrow()
instead if possible.- Type
Optional[datetime.timedelta]
- await confirm()¶
Confirms the trade offer. This rarely needs to be called as the client handles most of these.
- Raises
ClientException – The trade is not active.
ConfirmationError – No matching confirmation could not be found.
- await accept()¶
Accepts the trade offer.
Note
This also calls
confirm()
(if necessary) so you don’t have to.- Raises
ClientException – The trade is either not active, already accepted or not from the ClientUser.
ConfirmationError – No matching confirmation could not be found.
- await decline()¶
Declines the trade offer.
- Raises
ClientException – The trade is either not active, already declined or not from the ClientUser.
- await cancel()¶
Cancels the trade offer.
- Raises
ClientException – The trade is either not active or already cancelled.
- await counter(trade)¶
Counter a trade offer from an
User
.- Parameters
trade (steam.TradeOffer) – The trade offer to counter with.
- Raises
ClientException – The trade from the ClientUser or it isn’t active.
- is_gift()¶
Helper method that checks if an offer is a gift to the
ClientUser
- Return type
- is_our_offer()¶
Whether the offer was created by the
ClientUser
.- Return type
Images¶
- class steam.Image(fp, *, spoiler=False)¶
A wrapper around common image files. Used for
steam.User.send()
.- Parameters
fp (io.BufferedIOBase) – An image or path-like to pass to
open()
.spoiler (bool) – Whether or not to mark the image as a spoiler.
Note
- Currently supported image types include:
PNG
JPG/JPEG
GIF
Exceptions¶
The following exceptions are thrown by the library.
- exception steam.SteamException¶
Base exception class for steam.py.
- exception steam.ClientException¶
Exception that’s thrown when something in the client fails.
Subclass of
SteamException
.
- exception steam.LoginError¶
Exception that’s thrown when a login fails.
Subclass of
SteamException
.
- exception steam.InvalidCredentials¶
Exception that’s thrown when credentials are incorrect.
Subclass of
LoginError
.
- exception steam.NoCMsFound¶
Exception that’s thrown when no CMs can be found to connect to.
Subclass of
LoginError
.
- exception steam.AuthenticatorError¶
Exception that’s thrown when Steam cannot authenticate your details.
Subclass of
LoginError
.
- exception steam.ConfirmationError¶
Exception that’s thrown when a confirmation fails.
Subclass of
AuthenticatorError
.
- exception steam.HTTPException(response, data)¶
Exception that’s thrown for any web API error.
Subclass of
SteamException
.- response¶
The response of the failed HTTP request.
- message¶
The message associated with the error. Could be an empty string if no message can parsed.
- status¶
The status code of the HTTP request.
- code¶
The Steam specific error code for the failure.
- exception steam.Forbidden(response, data)¶
Exception that’s thrown when status code 403 occurs.
Subclass of
HTTPException
.
- exception steam.NotFound(response, data)¶
Exception that’s thrown when status code 404 occurs.
Subclass of
HTTPException
.
- exception steam.WSException(msg)¶
Exception that’s thrown for any websocket error. Similar to
HTTPException
.Subclass of
SteamException
.- msg¶
The received protobuf.
- message¶
The message that Steam sent back with the request, could be
None
.
- code¶
The Steam specific error code for the failure.
- exception steam.WSForbidden(msg)¶
Exception that’s thrown when the websocket returns an
Result
that means we do not have permission to perform an action. Similar toForbidden
.Subclass of
WSException
.
- exception steam.WSNotFound(msg)¶
Exception that’s thrown when the websocket returns an
Result
that means the object wasn’t found. Similar toNotFound
.Subclass of
WSException
.
- exception steam.InvalidSteamID(id, msg=None)¶
Exception that’s thrown when a SteamID cannot be valid.
Subclass of
SteamException
.- id¶
The invalid id.