API Reference#
The following section outlines the API of steam.py’s CSGO extension module.
Client#
- class steam.ext.csgo.Client(**options)#
Represents a client connection that connects to Steam. This class is used to interact with the Steam API, CMs and the CSGO Game Coordinator.
Client
is a subclass ofsteam.Client
, so whatever you can do withsteam.Client
you can do withClient
.- property user: ClientUser#
Represents the connected client.
None
if not logged in.
- await inspect_item(*, owner: IndividualID, asset_id: int, d: int) BaseInspectedItem #
- await inspect_item(*, market_id: int, asset_id: int, d: int) BaseInspectedItem
- await inspect_item(*, url: str) BaseInspectedItem
Inspect an item.
- Parameters:
owner – The owner of the item.
asset_id – The asset id of the item.
d – The “D” number following the “D” character.
market_id – The id of the item on the steam community market.
url – The full inspect url to be parsed.
- Return type:
BaseInspectedItem
- await fetch_match(id: int, *, outcome_id: int, token: int) Match #
- await fetch_match(*, code: str) Match
Fetch a match by its id or share code.
- Return type:
- get_user(id)#
Returns a user from cache with a matching ID or
None
if the user was not found.- Parameters:
id (Intable) – The ID64 of the user.
- Return type:
User | None
- await fetch_user(id)#
Fetches a user with a matching ID.
- Parameters:
id (Intable) – The ID64 of the user.
- Return type:
- async for ... in all_apps(*, limit=None, modified_after=None, include_games=True, include_dlc=True, include_software=True, include_videos=True, include_hardware=True)#
An asynchronous iterator over all the apps on Steam.
- Parameters:
limit (int | None) – The maximum number of apps to search through. Default is
None
. Setting this toNone
will fetch all of the apps, but this will be a very slow operation.modified_after (datetime.datetime | None) – A time to search for apps after.
include_games (bool) – Whether to include games.
include_dlc (bool) – Whether to include DLC.
include_software (bool) – Whether to include software.
include_videos (bool) – Whether to include videos.
include_hardware (bool) – Whether to include hardware.
- Yields:
AppListApp
- await anonymous_login()#
Initialize a connection to a Steam CM and login anonymously.
- await change_presence(*, app=None, apps=None, state=None, ui_mode=None, flags=None, force_kick=False)#
Set your status.
- Parameters:
app (App | None) – An app to set your status as.
apps (Iterable[App] | None) – A list of apps 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 to forcefully kick any other playing sessions.
- 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 close()#
Close the connection to Steam.
- await code()#
Get the current steam guard code.
Warning
This will read from
sys.stdin
if no shared_secret was passed tologin()
.- Return type:
- await create_clan(name, /, *, abbreviation=None, community_url=None, public=True, headline=None, summary=None, language=None, country=None, state=None, city=None, apps=None, avatar=None)#
Create a clan.
- Parameters:
name (str) – The name of the clan.
avatar (Media | None) – The avatar of the clan.
abbreviation (str | None) – The abbreviation of the clan.
community_url (URL_ | str | None) – The community URL of the clan.
public (bool) – Whether the clan is public.
headline (str | None) – The headline of the clan.
summary (str | None) – The summary of the clan.
language (Language | None) – The language of the clan.
country (str | None) – The country of the clan.
state (str | None) – The state of the clan.
city (str | None) – The city of the clan.
apps (Iterable[App] | None) – The apps the clan is associated with.
- Return type:
- await create_group(name, /, *, members, avatar=None, tagline=None)#
Create a group.
- await create_post(content, /, app=None)#
Create a post.
- Parameters:
- Return type:
- property effects: Sequence[ClientEffect]#
A read-only list of all the effects the client has.
- property emoticons: Sequence[ClientEmoticon]#
A read-only list of all the emoticons the client has.
- @event(coro)#
A decorator that registers 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:
F
- await fetch_app(id, /, *, language=None)#
Fetch an app from its ID.
- Parameters:
- Raises:
ValueError – Passed id isn’t for a valid app.
- Return type:
- await fetch_bundle(id, /, *, language=None)#
Fetch a bundle from its ID.
- Parameters:
- Return type:
- await fetch_clan(id, /)#
Fetches a clan from the websocket with a matching ID.
- async for ... in fetch_listings(name, app)#
Fetch the listings for an item.
- await fetch_package(id, /, *, language=None)#
Fetch a package from its ID.
- Parameters:
- Raises:
ValueError – Passed id isn’t for a valid package.
- Return type:
- await fetch_price(name, app, currency=None)#
Fetch the
PriceOverview
for an item.- Parameters:
- Return type:
- await fetch_price_history(name, app, currency=None)#
Fetch the price history for an item.
- await fetch_product_info(*, apps=(), packages=())#
Fetch product info.
- await fetch_published_file(id, /, *, revision=PublishedFileRevision.Default, language=None)#
Fetch a published file from its ID.
- Parameters:
id (int) – The ID of the published file.
revision (PublishedFileRevision) – The revision of the published file to fetch.
language (Language | None) – The language to fetch the published file in. If
None
, the current language is used.
- Return type:
PublishedFile | None
- await fetch_published_files(*ids, revision=PublishedFileRevision.Default, language=None)#
Fetch published files from their IDs.
- Parameters:
ids (int) – The IDs of the published files.
revision (PublishedFileRevision) – The revision of the published files to fetch.
language (Language | None) – The language to fetch the published files in. If
None
, the current language is used.
- Return type:
list[PublishedFile | None]
- await fetch_server(*, id=None, ip=None, port=None)#
Fetch a
GameServer
from its ip and port or its Steam ID orNone
if fetching the server failed.- Parameters:
Note
Passing an
ip
,port
andid
to this function will raise anTypeError
.- Return type:
GameServer | None
- await fetch_servers(query=None, /, *, limit=100)#
Query game servers.
- Parameters:
See also
- Return type:
- await fetch_store_item(*, apps=(), packages=(), bundles=(), language=None)#
Fetch store items.
- await fetch_trade(id, /, *, language=None)#
Fetches a trade with a matching ID or
None
if the trade was not found.- Parameters:
- Return type:
TradeOffer[Item[User], Item[ClientUser], User] | None
- await fetch_users(*ids)#
Fetches a list of
User
.Note
The
User
objects returned are unlikely to retain the order they were originally in.
- get_app(id, /)#
Creates a
PartialApp
instance from its ID.- Parameters:
id (int) – The app id of the app.
- Return type:
PartialApp[None]
- get_bundle(id, /)#
Creates a
PartialBundle
instance from its ID.- Parameters:
id (int) – The ID of the bundle.
- Return type:
- get_clan(id, /)#
Get a clan from cache with a matching ID or
None
if the group was not found.
- get_group(id, /)#
Get a group from cache with a matching ID or
None
if the group was not found.
- get_package(id, /)#
Creates a
PartialPackage
from its ID.- Parameters:
id (int) – The ID of the package.
- 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:
TradeOffer | None
- property latency: float#
Measures latency between a heartbeat send and the heartbeat interval in seconds.
- await login(*args, **kwargs)#
Initialize a connection to a Steam CM and login.
If no
shared_secret
is passed, you will have to manually enter a Steam guard code usingcode()
.- Parameters:
username – The username of the account to login to.
password – The password of the account to login to.
shared_secret – The shared secret for the account to login to.
identity_secret – The identity secret for the account to login to.
refresh_token – The refresh token of the account to login to.
- await on_announcement_create(announcement, /)#
Called when an announcement in a clan is created.
- Parameters:
announcement (steam.Announcement) – The announcement that was created.
- await on_authentication_ticket_update(ticket, response, state, /)#
Called when the client’s authentication ticket is updated.
- Parameters:
ticket (steam.AuthenticationTicket) – The updated ticket.
response (steam.AuthSessionResponse) – The response code from the CM.
state (int) – The state of the ticket.
- await on_clan_join(clan, /)#
Called when the client joins a new clan.
- Parameters:
clan (steam.Clan) – The joined clan.
- await on_clan_leave(clan, /)#
Called when the client leaves a clan.
- Parameters:
clan (steam.Clan) – The left clan.
- await on_clan_update(before, after, /)#
Called when a clan is updated, due to one or more of the following attributes changing:
avatar_url
- Parameters:
before (steam.Clan) – The clan’s state before it was updated.
after (steam.Clan) – The clan’s state now.
- await on_event_create(event, /)#
Called when an event in a clan is created.
- Parameters:
event (steam.Event) – The event that was created.
- await on_friend_add(friend, /)#
Called when a friend is added to the client’s friends list.
- Parameters:
friend (steam.Friend) – The friend that was added.
- await on_friend_remove(friend, /)#
Called when you or the
friend
remove each other from your friends lists.- Parameters:
friend (steam.Friend) – The friend who was removed.
- await on_group_join(group, /)#
Called when the client joins a new group.
- Parameters:
group (steam.Group) – The joined group.
- await on_group_leave(group, /)#
Called when the client leaves a group.
- Parameters:
group (steam.Group) – The left group.
- await 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 on_reaction_add(reaction, /)#
Called when a reaction is added to a message.
- Parameters:
reaction (MessageReaction) – The reaction that was added.
- await on_reaction_remove(reaction, /)#
Called when a reaction is removed from a message.
- Parameters:
reaction (MessageReaction) – The reaction that was removed.
- await redeem_package(id, /)#
Redeem a promotional free licenses package from its ID.
- property refresh_token: str | None#
The refresh token for the logged in account, can be used to login.
- await register_cd_key(key, /)#
Register a CD key.
- Parameters:
key (str) – The CD key to register.
- Return type:
- run(*args, debug=False, **kwargs)#
A blocking method to start and run the client.
Shorthand for:
async def main(): async with client: await client.login(...) asyncio.run(main())
It is not recommended to subclass this method, it is normally favourable to subclass
login()
as it is a coroutine.Note
This takes the same arguments as
login()
.- Return type:
- async for ... in search_market(query='', *, limit=100, search_description=True, sort_by='popular', reverse=True)#
-
- Return type:
AsyncGenerator[MarketSearchItem, None]
- property stickers: Sequence[ClientSticker]#
A read-only list of all the stickers the client has.
- async for ... in trade_history(*, limit=100, before=None, after=None, language=None, include_failed=True)#
An asynchronous iterator for accessing a
steam.ClientUser
’ssteam.TradeOffer
objects.Examples
Usage:
async for trade in client.trade_history(limit=10): items = [getattr(item, "name", str(item.id)) for item in trade.receiving] items = ", ".join(items) or "Nothing" print("Partner:", trade.user) print("Sent:", items)
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.
language (Language | None) – The language to fetch the trade in.
None
uses the current language.include_failed (bool) – Whether to include trades that failed.
- Yields:
- await trade_url(generate_new=False)#
Fetches this account’s trade url.
- Parameters:
generate_new (bool) – Whether or not to generate a new trade token, defaults to
False
.- Return type:
TradeURLInfo
- property trades: Sequence[TradeOffer[Asset[User], Asset[ClientUser], User]]#
A read-only list of all the trades the connected client can see.
- async for ... in user_news(*, limit=None, before=None, after=None, app=None, flags=None, language=None)#
Fetch news for the user.
- Parameters:
limit (int | None) – The maximum number of news entries to fetch.
before (datetime.datetime | None) – The date to fetch news before.
after (datetime.datetime | None) – The date to fetch news after.
app (App | None) – The app to fetch news entries related to.
flags (UserNewsType | None) – The type of news to fetch.
language (Language | None) – The language to fetch the news in. If
None
, the current language is used.
- Return type:
AsyncGenerator[UserNews, None]
- await wait_for(event, *, check=<return_true>, timeout=None)#
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 (str) – The event name from the event reference, but without the
on_
prefix, to wait for.check (Callable[[...], bool]) – 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 (float | None) – By default,
wait_for()
function does not timeout, however, in the case atimeout
parameter is passed after the amount of seconds passesasyncio.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:
Any
- await wait_until_gc_ready()#
Wait for the
on_gc_ready()
method to be dispatched.See also
wait_for_ready()
- await wait_until_ready()#
Waits until the client’s internal cache is all ready.
Event Reference#
These events function similar to the regular events, and all of the events there are also
applicable to Client
. These are however unique to the CSGO extension module.
- await steam.ext.csgo.Client.on_gc_connect(self)#
Called after the client receives the welcome message from the GC.
Warning
This is called every time we craft an item and disconnect so same warnings apply to
steam.Client.on_connect()
- await steam.ext.csgo.Client.on_gc_disconnect(self)#
Called after the client receives the goodbye message from the GC.
Warning
This is called every time we craft an item and disconnect so same warnings apply to
steam.Client.on_connect()
- await steam.ext.csgo.Client.on_gc_ready(self)#
Called after the client connects to the GC and has the
schema
,Client.user.inventory()
and set up and account info (is_premium()
andbackpack_slots
).Warning
This is called every time we craft an item and disconnect so same warnings apply to
steam.Client.on_connect()
- await steam.ext.csgo.Client.on_item_receive(self, item)#
Called when the client receives an item.
- Parameters:
item (csgo.BackpackItem) – The received item.
- await steam.ext.csgo.Client.on_item_remove(self, item)#
Called when the client has an item removed from its backpack.
- Parameters:
item (csgo.BackpackItem) – The removed item.
- await steam.ext.csgo.Client.on_item_update(self, before, after)#
Called when the client has an item in its backpack updated.
- Parameters:
before (csgo.BackpackItem) – The item before being updated.
after (csgo.BackpackItem) – The item now.
Bot#
ext.csgo
also provides a Bot
class, which is a subclass of Client
and steam.ext.commands.Bot
.
- class steam.ext.csgo.Bot(**options)#
Represents a Steam bot.
Bot
is a subclass ofBot
, so whatever you can do withBot
you can do withBot
.- add_check(predicate)#
Add a global check to the bot.
- Parameters:
predicate (Check) – The check to add.
- add_command(command)#
Add a command to the internal commands list.
- Parameters:
command (Command[CogT]) – The command to register.
- add_listener(func, name=None)#
Add a function from the internal listeners list.
- after_invoke(coro)#
Register a coroutine to be ran after a command has been invoked.
- Return type:
BotInvokeT
- async for ... in all_apps(*, limit=None, modified_after=None, include_games=True, include_dlc=True, include_software=True, include_videos=True, include_hardware=True)#
An asynchronous iterator over all the apps on Steam.
- Parameters:
limit (int | None) – The maximum number of apps to search through. Default is
None
. Setting this toNone
will fetch all of the apps, but this will be a very slow operation.modified_after (datetime.datetime | None) – A time to search for apps after.
include_games (bool) – Whether to include games.
include_dlc (bool) – Whether to include DLC.
include_software (bool) – Whether to include software.
include_videos (bool) – Whether to include videos.
include_hardware (bool) – Whether to include hardware.
- Yields:
AppListApp
- await anonymous_login()#
Initialize a connection to a Steam CM and login anonymously.
- before_invoke(coro)#
Register a coroutine to be ran before any arguments are parsed.
- Return type:
BotInvokeT
- await can_run(ctx)#
Whether or not the context’s command can be ran.
- await change_presence(*, app=None, apps=None, state=None, ui_mode=None, flags=None, force_kick=False)#
Set your status.
- Parameters:
app (App | None) – An app to set your status as.
apps (Iterable[App] | None) – A list of apps 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 to forcefully kick any other playing sessions.
- check(predicate)#
Register a global check for all commands. This is similar to
commands.check()
.- Return type:
Check[MaybeBool]
- 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 close()#
Unloads any extensions and cogs, then closes the connection to Steam.
- await code()#
Get the current steam guard code.
Warning
This will read from
sys.stdin
if no shared_secret was passed tologin()
.- Return type:
- @command(callback=None, /, *, name=None, cls=<class 'steam.ext.commands.commands.Command'>, **attrs)#
A decorator that could be called. A decorator that invokes
command()
and adds the createdCommand
to the internal command list.- Parameters:
- Returns:
The created command.
- Return type:
Callable[[CoroFuncT], C] | C
- property converters: MappingProxyType[type[Any], Sequence[Converters]]#
A read only mapping of registered converters.
- await create_clan(name, /, *, abbreviation=None, community_url=None, public=True, headline=None, summary=None, language=None, country=None, state=None, city=None, apps=None, avatar=None)#
Create a clan.
- Parameters:
name (str) – The name of the clan.
avatar (Media | None) – The avatar of the clan.
abbreviation (str | None) – The abbreviation of the clan.
community_url (URL_ | str | None) – The community URL of the clan.
public (bool) – Whether the clan is public.
headline (str | None) – The headline of the clan.
summary (str | None) – The summary of the clan.
language (Language | None) – The language of the clan.
country (str | None) – The country of the clan.
state (str | None) – The state of the clan.
city (str | None) – The city of the clan.
apps (Iterable[App] | None) – The apps the clan is associated with.
- Return type:
- await create_group(name, /, *, members, avatar=None, tagline=None)#
Create a group.
- await create_post(content, /, app=None)#
Create a post.
- Parameters:
- Return type:
- property effects: Sequence[ClientEffect]#
A read-only list of all the effects the client has.
- property emoticons: Sequence[ClientEmoticon]#
A read-only list of all the emoticons the client has.
- @event(coro)#
A decorator that registers 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:
F
- await fetch_app(id, /, *, language=None)#
Fetch an app from its ID.
- Parameters:
- Raises:
ValueError – Passed id isn’t for a valid app.
- Return type:
- await fetch_bundle(id, /, *, language=None)#
Fetch a bundle from its ID.
- Parameters:
- Return type:
- await fetch_clan(id, /)#
Fetches a clan from the websocket with a matching ID.
- async for ... in fetch_listings(name, app)#
Fetch the listings for an item.
- await fetch_match(id=..., *, outcome_id=..., token=..., code=...)#
Fetch a match by its id or share code.
- Return type:
- await fetch_package(id, /, *, language=None)#
Fetch a package from its ID.
- Parameters:
- Raises:
ValueError – Passed id isn’t for a valid package.
- Return type:
- await fetch_price(name, app, currency=None)#
Fetch the
PriceOverview
for an item.- Parameters:
- Return type:
- await fetch_price_history(name, app, currency=None)#
Fetch the price history for an item.
- await fetch_product_info(*, apps=(), packages=())#
Fetch product info.
- await fetch_published_file(id, /, *, revision=PublishedFileRevision.Default, language=None)#
Fetch a published file from its ID.
- Parameters:
id (int) – The ID of the published file.
revision (PublishedFileRevision) – The revision of the published file to fetch.
language (Language | None) – The language to fetch the published file in. If
None
, the current language is used.
- Return type:
PublishedFile | None
- await fetch_published_files(*ids, revision=PublishedFileRevision.Default, language=None)#
Fetch published files from their IDs.
- Parameters:
ids (int) – The IDs of the published files.
revision (PublishedFileRevision) – The revision of the published files to fetch.
language (Language | None) – The language to fetch the published files in. If
None
, the current language is used.
- Return type:
list[PublishedFile | None]
- await fetch_server(*, id=None, ip=None, port=None)#
Fetch a
GameServer
from its ip and port or its Steam ID orNone
if fetching the server failed.- Parameters:
Note
Passing an
ip
,port
andid
to this function will raise anTypeError
.- Return type:
GameServer | None
- await fetch_servers(query=None, /, *, limit=100)#
Query game servers.
- Parameters:
See also
- Return type:
- await fetch_store_item(*, apps=(), packages=(), bundles=(), language=None)#
Fetch store items.
- await fetch_trade(id, /, *, language=None)#
Fetches a trade with a matching ID or
None
if the trade was not found.- Parameters:
- Return type:
TradeOffer[Item[User], Item[ClientUser], User] | None
- await fetch_user(id)#
Fetches a user with a matching ID.
- Parameters:
id (Intable) – The ID64 of the user.
- Return type:
- await fetch_users(*ids)#
Fetches a list of
User
.Note
The
User
objects returned are unlikely to retain the order they were originally in.
- get_app(id, /)#
Creates a
PartialApp
instance from its ID.- Parameters:
id (int) – The app id of the app.
- Return type:
PartialApp[None]
- get_bundle(id, /)#
Creates a
PartialBundle
instance from its ID.- Parameters:
id (int) – The ID of the bundle.
- Return type:
- get_clan(id, /)#
Get a clan from cache with a matching ID or
None
if the group was not found.
- get_cog(name)#
Get a loaded cog or
None
.
- get_command(name)#
Get a command.
- await get_context(message, *, cls=<class 'steam.ext.commands.context.Context'>)#
Get the context for a certain message.
- get_group(id, /)#
Get a group from cache with a matching ID or
None
if the group was not found.
- get_package(id, /)#
Creates a
PartialPackage
from its ID.- Parameters:
id (int) – The ID of the package.
- Return type:
- await get_prefix(message)#
Get the command prefix for a certain message.
- 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:
TradeOffer | None
- get_user(id)#
Returns a user from cache with a matching ID or
None
if the user was not found.- Parameters:
id (Intable) – The ID64 of the user.
- Return type:
User | None
- @group(callback=None, /, *, name=None, cls=None, **attrs)#
A decorator that invokes
group()
and adds the createdGroup
to the internal command list.- Parameters:
- Returns:
The created group command.
- Return type:
Callable[[CoroFuncT], G] | G
- property help_command: HelpCommand | None#
The bot’s help command.
- await inspect_item(*, owner=None, asset_id=0, d=0, market_id=0, url='')#
Inspect an item.
- Parameters:
- Return type:
BaseInspectedItem
- await invoke(ctx)#
Invoke a command. This will parse arguments, checks, cooldowns etc. correctly.
- Parameters:
ctx (Context) – The invocation context.
- property latency: float#
Measures latency between a heartbeat send and the heartbeat interval in seconds.
- @listen(name=None, /)#
A decorator that could be called. Register a function as a listener. Calls
add_listener()
. Similar toCog.listener()
- Parameters:
name (
str
) – The name of the event to listen for. Will default tofunc.__name__
.- Return type:
Callable[[F], F] | F
- await load_extension(extension)#
Load an extension.
- Parameters:
extension (str | PathLike[str]) – The name of the extension to load.
- Raises:
ImportError – The
extension
is missing a setup function.
- await login(*args, **kwargs)#
Initialize a connection to a Steam CM and login.
If no
shared_secret
is passed, you will have to manually enter a Steam guard code usingcode()
.- Parameters:
username – The username of the account to login to.
password – The password of the account to login to.
shared_secret – The shared secret for the account to login to.
identity_secret – The identity secret for the account to login to.
refresh_token – The refresh token of the account to login to.
- await on_announcement_create(announcement, /)#
Called when an announcement in a clan is created.
- Parameters:
announcement (steam.Announcement) – The announcement that was created.
- await on_authentication_ticket_update(ticket, response, state, /)#
Called when the client’s authentication ticket is updated.
- Parameters:
ticket (steam.AuthenticationTicket) – The updated ticket.
response (steam.AuthSessionResponse) – The response code from the CM.
state (int) – The state of the ticket.
- await on_clan_join(clan, /)#
Called when the client joins a new clan.
- Parameters:
clan (steam.Clan) – The joined clan.
- await on_clan_leave(clan, /)#
Called when the client leaves a clan.
- Parameters:
clan (steam.Clan) – The left clan.
- await on_clan_update(before, after, /)#
Called when a clan is updated, due to one or more of the following attributes changing:
avatar_url
- Parameters:
before (steam.Clan) – The clan’s state before it was updated.
after (steam.Clan) – The clan’s state now.
- await on_event_create(event, /)#
Called when an event in a clan is created.
- Parameters:
event (steam.Event) – The event that was created.
- await on_friend_add(friend, /)#
Called when a friend is added to the client’s friends list.
- Parameters:
friend (steam.Friend) – The friend that was added.
- await on_friend_remove(friend, /)#
Called when you or the
friend
remove each other from your friends lists.- Parameters:
friend (steam.Friend) – The friend who was removed.
- await on_group_join(group, /)#
Called when the client joins a new group.
- Parameters:
group (steam.Group) – The joined group.
- await on_group_leave(group, /)#
Called when the client leaves a group.
- Parameters:
group (steam.Group) – The left group.
- await 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 on_reaction_add(reaction, /)#
Called when a reaction is added to a message.
- Parameters:
reaction (MessageReaction) – The reaction that was added.
- await on_reaction_remove(reaction, /)#
Called when a reaction is removed from a message.
- Parameters:
reaction (MessageReaction) – The reaction that was removed.
- await process_commands(message, /)#
A method to process commands for a message.
Warning
This is vital for commands to function. If you have an
on_message()
as a registered event usingevent()
commands will not be dispatched. Remember to add a call to this in youron_message()
event.- Parameters:
message (Message) – The message to get the context for.
- await redeem_package(id, /)#
Redeem a promotional free licenses package from its ID.
- property refresh_token: str | None#
The refresh token for the logged in account, can be used to login.
- await register_cd_key(key, /)#
Register a CD key.
- Parameters:
key (str) – The CD key to register.
- Return type:
- await reload_extension(extension)#
Atomically reload an extension. If any error occurs during the reload the extension will be reverted to its original state.
- Parameters:
extension (str | PathLike[str]) – The name of the extension to reload.
- Raises:
ModuleNotFoundError – The
extension
wasn’t found in the loaded extensions.
- remove_check(predicate)#
Remove a global check from the bot.
- Parameters:
predicate (Check) – The check to remove.
- await remove_cog(cog)#
Remove a cog from the internal list.
- Parameters:
cog (Cog[Self]) – The cog to remove.
- remove_command(name)#
Remove a command from the internal commands list.
- remove_listener(func, name=None)#
Remove a function from the internal listeners list.
- run(*args, debug=False, **kwargs)#
A blocking method to start and run the client.
Shorthand for:
async def main(): async with client: await client.login(...) asyncio.run(main())
It is not recommended to subclass this method, it is normally favourable to subclass
login()
as it is a coroutine.Note
This takes the same arguments as
login()
.- Return type:
- async for ... in search_market(query='', *, limit=100, search_description=True, sort_by='popular', reverse=True)#
-
- Return type:
AsyncGenerator[MarketSearchItem, None]
- property stickers: Sequence[ClientSticker]#
A read-only list of all the stickers the client has.
- async for ... in trade_history(*, limit=100, before=None, after=None, language=None, include_failed=True)#
An asynchronous iterator for accessing a
steam.ClientUser
’ssteam.TradeOffer
objects.Examples
Usage:
async for trade in client.trade_history(limit=10): items = [getattr(item, "name", str(item.id)) for item in trade.receiving] items = ", ".join(items) or "Nothing" print("Partner:", trade.user) print("Sent:", items)
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.
language (Language | None) – The language to fetch the trade in.
None
uses the current language.include_failed (bool) – Whether to include trades that failed.
- Yields:
- await trade_url(generate_new=False)#
Fetches this account’s trade url.
- Parameters:
generate_new (bool) – Whether or not to generate a new trade token, defaults to
False
.- Return type:
TradeURLInfo
- property trades: Sequence[TradeOffer[Asset[User], Asset[ClientUser], User]]#
A read-only list of all the trades the connected client can see.
- await unload_extension(extension)#
Unload an extension.
- Parameters:
extension (str | PathLike[str]) – The name of the extension to unload.
- Raises:
ModuleNotFoundError – The
extension
wasn’t found in the loaded extensions.
- property user: ClientUser#
Represents the connected client.
None
if not logged in.
- async for ... in user_news(*, limit=None, before=None, after=None, app=None, flags=None, language=None)#
Fetch news for the user.
- Parameters:
limit (int | None) – The maximum number of news entries to fetch.
before (datetime.datetime | None) – The date to fetch news before.
after (datetime.datetime | None) – The date to fetch news after.
app (App | None) – The app to fetch news entries related to.
flags (UserNewsType | None) – The type of news to fetch.
language (Language | None) – The language to fetch the news in. If
None
, the current language is used.
- Return type:
AsyncGenerator[UserNews, None]
- await wait_for(event, *, check=<return_true>, timeout=None)#
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 (str) – The event name from the event reference, but without the
on_
prefix, to wait for.check (Callable[[...], bool]) – 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 (float | None) – By default,
wait_for()
function does not timeout, however, in the case atimeout
parameter is passed after the amount of seconds passesasyncio.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:
Any
- await wait_until_gc_ready()#
Wait for the
on_gc_ready()
method to be dispatched.See also
wait_for_ready()
- await wait_until_ready()#
Waits until the client’s internal cache is all ready.
Utility Functions#
Decodes a match share code.
- Returns:
Source for ShareCode:
class ShareCode(NamedTuple): match_id: int outcome_id: int token: int
- Return type:
steam.ext.csgo.utils.ShareCode
Enumerations#
- class steam.ext.csgo.ItemQuality#
- Undefined = -1#
- Normal = 0#
- Genuine = 1#
- Vintage = 2#
- Unusual = 3#
- Unique = 4#
- Community = 5#
- Developer = 6#
- SelfMade = 7#
- Customised = 8#
- Strange = 9#
- Completed = 10#
- Haunted = 11#
- Tournament = 12#
- Favoured = 13#
- Max = 14#
- class steam.ext.csgo.ItemFlags#
- CannotTrade = 1#
- CannotCraft = 2#
- CanBeTradedByFreeAccounts = 4#
- NotEcon = 8#
Items that cannot interact in the economy (can’t be traded, gift-wrapped, crafted, etc.)
- PurchasedAfterStoreCraftabilityChanges2012 = 16#
Cosmetic items coming from the store are now usable in crafting
- ForceBlueTeam = 32#
- StoreItem = 64#
- Preview = 128#
- class steam.ext.csgo.ItemOrigin#
- Invalid = -1#
- Drop = 0#
- Achievement = 1#
- Purchased = 2#
- Traded = 3#
- Crafted = 4#
- StorePromotion = 5#
- Gifted = 6#
- SupportGranted = 7#
- FoundInCrate = 8#
- Earned = 9#
- ThirdPartyPromotion = 10#
- GiftWrapped = 11#
- HalloweenDrop = 12#
- PackageItem = 13#
- Foreign = 14#
- CDKey = 15#
- CollectionReward = 16#
- PreviewItem = 17#
- SteamWorkshopContribution = 18#
- PeriodicScoreReward = 19#
- Recycling = 20#
- TournamentDrop = 21#
- StockItem = 22#
- QuestReward = 23#
- LevelUpReward = 24#
- Max = 25#
Models#
- class steam.ext.csgo.Backpack#
A class to represent the client’s backpack.
- class steam.ext.csgo.Team#
Represents a team in a match
- players: list[MatchPlayer]#
- class steam.ext.csgo.Round#
Represents a round of a match
- property players: list[MatchPlayer]#
- class steam.ext.csgo.Match#
Represents a match of CSGO
- property players: list[MatchPlayer]#
All the players that appeared in the match.
- class steam.ext.csgo.PartialUser#
- await csgo_profile()#
Fetches this users CSGO profile info.
- Return type:
ProfileInfo[Self]
- await recent_matches()#
Fetches this user’s recent games.
- Return type:
Matches
- class steam.ext.csgo.User#
- class steam.ext.csgo.ClientUser#
- await csgo_profile()#
Fetches this users CSGO profile info.
- Return type:
ProfileInfo[Self]
- await live_games()#
- Return type:
…
- class steam.ext.csgo.MatchPlayer#
- await add()#
Sends a friend invite to the user to your friends list.
- await block()#
Blocks the user.
- await cancel_invite()#
Cancels an invitation sent to the user. This effectively does the same thing as
remove()
.
- 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.- Parameters:
token (str | None) – The user’s trade offer token, not required if you are friends with the user.
- Return type:
timedelta | None
- async for ... in history(*, limit=100, before=None, after=None)#
An asynchronous iterator for accessing a channel’s
steam.Message
s.Examples
Usage:
async for message in channel.history(limit=10): print("Author:", message.author, "Said:", message.content)
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 remove()#
Remove the user from your friends list.
- await send(content=..., /, *, trade=None, media=None)#
Send a message, trade or image to an
User
.- Parameters:
content (Any) – The message to send to the user.
trade (TradeOffer[Asset[User], Asset[ClientUser], Any] | None) –
The trade offer to send to the user.
Note
This will have its
id
attribute updated after being sent.media (Media | None) – The media to send to the user.
- 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:
UserMessage[ClientUser] | None
- await trigger_typing()#
Send a typing indicator to the channel once.
Note
This only works in DMs.
- 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 channel.typing(): ... # do your expensive operations
- Return type:
AsyncGenerator[None, None]
- await unblock()#
Unblocks the user.