### Install Project with Dev Dependencies Source: https://github.com/somespecialone/aiosteampy/blob/main/protobufs/README.md Install the project including optional development dependencies for protobuf generation. ```bash pip install -e .[dev] ``` -------------------------------- ### Install aiosteampy with uv Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install aiosteampy using uv, a fast Python package installer and dependency manager. ```sh uv add aiosteampy ``` -------------------------------- ### Install pre-release versions of aiosteampy with uv Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install pre-release versions of aiosteampy using uv with the --prerelease flag. ```sh uv add --prerelease aiosteampy ``` -------------------------------- ### Install aiosteampy with pip Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install the aiosteampy package using pip. This is the standard method for installing Python packages. ```sh pip install aiosteampy ``` -------------------------------- ### Install aiosteampy with SOCKS proxy support Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install aiosteampy with the 'socks' extra to enable SOCKS proxy support for the default HTTP transport. ```sh pip install aiosteampy[socks] ``` -------------------------------- ### Install pre-release versions of aiosteampy with Poetry Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Add pre-release versions of aiosteampy to your project using Poetry with the --allow-prereleases flag. ```sh poetry add --allow-prereleases aiosteampy ``` -------------------------------- ### Install pre-release versions of aiosteampy with pip Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install pre-release versions (alpha, beta, release candidates) of aiosteampy using pip by specifying the --pre flag. ```sh pip install --pre aiosteampy ``` -------------------------------- ### Install aiosteampy with Poetry Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Add aiosteampy as a dependency to your project using Poetry, a popular Python dependency management tool. ```sh poetry add aiosteampy ``` -------------------------------- ### Login to Steam with credentials and save session Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md This example demonstrates logging into a Steam account using username and password, handling 2FA codes (email or device), finalizing the session, obtaining web cookies, and serializing the session data to a JSON file. ```python import asyncio import json from aiosteampy.session import SteamSession, GuardConfirmationRequired async def login_with_credentials(): session = SteamSession() account_name = input("Input login: ") password = input("Input password: ") try: await session.with_credentials(account_name, password) except GuardConfirmationRequired as e: if e.email_code: code = input("Code from Steam has been sent to your email. Paste it here: ") await session.submit_auth_code(code, "email") elif e.device_code: code = input("Input code from Mobile Device Authenticator: ") await session.submit_auth_code(code, "device") else: input( ("Steam requests device or email confirmation. " "Click on the link from email or mobile application and press enter.") ) await session.finalize() print("Access token: ", session.access_token) print("Refresh token: ", session.refresh_token) await session.obtain_cookies() print("Web cookies obtained!") await session.transport.close() session_dump = session.serialize() with open(f"./{account_name}.session.json", "w") as f: json.dump(session_dump, f, indent=2) asyncio.run(login_with_credentials()) ``` -------------------------------- ### Install aiosteampy with wreq HTTP transport Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Install aiosteampy with the 'wreq' extra to use the wreq-python HTTP transport, which supports proxies, HTTP/2, and browser impersonation. ```sh pip install aiosteampy[wreq] ``` -------------------------------- ### Manage User Inventory and Market Listings Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/get_started.md Demonstrates fetching a user's inventory, getting market listings for an item, buying a listing, placing a sell order, and canceling it. Requires authentication. ```python from aiosteampy.client import SteamClient, AppContext client = SteamClient(...) # get inventory of the current user my_inventory = await client.inventory.get(AppContext.CS2) first_item = my_inventory.items[0] # fetch listings for this item class listings = await client.market.get_listings(first_item.description) first_listing = listings.listings[0] # buy first listing wallet_info = await client.market.buy_listing(first_listing) print("Remaining balance: ", wallet_info.balance) # let's increase price for about 20% my_price = int(first_listing.converted.price * 1.2) # place sell order on a market listing_id = await client.market.place_sell_listing(first_item, price=my_price) # hmm, we've changed our idea and want to cancel sell listing await client.market.cancel_sell_listing(listing_id) ``` -------------------------------- ### Fetch Market Listings Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/get_started.md Use SteamPublicClient to get market listings for a specific item in a given app. No authentication is required. ```python import asyncio from aiosteampy.client import SteamPublicClient, App async def get_market_listings(): client = SteamPublicClient() listings = await client.market.get_listings( "FAMAS | Rapid Eye Movement (Field-Tested)", App.CS2, ) print(listings.listings) asyncio.run(get_market_listings()) ``` -------------------------------- ### Send and Manage Trade Offers Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/get_started.md Example of sending a trade offer with specific items to a partner, accepting or declining it, and optionally canceling the offer. Requires authentication. ```python from aiosteampy.client import SteamClient, AppContext from aiosteampy.id import SteamID client = SteamClient(...) # get inventory of the current user my_inventory = await client.inventory.get(AppContext.CS2) # get all Nova Mandrel items from inventory gifts = list(filter(lambda i: "Nova Mandrel" in i.description.name, my_inventory.items)) partner = SteamID(123456789) # partner, which is in a friends list # make and confirm trade, fetch and return trade offer trade_offer_id = await client.trade.send( partner, gifts, message="Gift for my friend!", ) trade = await client.trade.get(trade_offer_id) # wait some time to give partner a time to react if trade.accepted: print("yeeahs") elif trade.declined: print("Bbut wmhhy?") elif trade.active: await client.trade.cancel(trade) # haha, we revoke our gift ``` -------------------------------- ### Load Steam session from a dump Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md This example shows how to load a previously saved Steam session from a JSON file. The session object will be restored with its tokens and cookies, though their validity is not guaranteed. ```python with open(f"./{account_name}.session.json", "r") as f: session = SteamSession.deserialize(json.load(f)) ``` -------------------------------- ### Get Current User Inventory Items Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Retrieves inventory items for the current user for predefined applications like CS2 and custom applications. Requires an authenticated SteamSession. ```python import asyncio from aiosteampy.session import SteamSession from aiosteampy.client import SteamClient, AppContext, App async def get_inventory(): session = SteamSession(...) client = SteamClient(session) # use predefined apps and their contexts cs2_default_inv = await client.inventory.get(AppContext.CS2) print("CS2 items: ", cs2_default_inv.items) cs2_trade_protected_inv = await client.inventory.get(AppContext.CS2_PROTECTED) print("CS2 trade protected items: ", cs2_trade_protected_inv.items) # create new App and AppContext BongoCatApp = App(3419430, "Bongo Cat") BongoCatDefault = BongoCatApp.with_context(2) bongo_cat_inv = await client.inventory.get(BongoCatDefault) print("Bongo Cat items: ", bongo_cat_inv.items) await client.transport.close() asyncio.run(get_inventory()) ``` -------------------------------- ### Get Steam Market Orders Histogram (Unauthenticated) Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Fetches the item orders histogram from the Steam Market using an unauthenticated client. This is useful for retrieving market data without needing to log in. ```python import asyncio from aiosteampy.client import SteamPublicClient, App async def get_histogram(): client = SteamPublicClient() # Glock-18 | Fully Tuned (Field-Tested) histogram = await client.market.get_orders_histogram(176611887) print("Get histogram: ", histogram) await client.transport.close() asyncio.run(get_histogram()) ``` -------------------------------- ### Generate Protobufs Source: https://github.com/somespecialone/aiosteampy/blob/main/protobufs/README.md Run the Python script from the project root to generate protobuf code. The generated code will be placed in the specified directory. ```bash python scripts/generate_protos.py ``` -------------------------------- ### Enable Steam Guard and Export Account Data Source: https://github.com/somespecialone/aiosteampy/blob/main/README.md Enables Steam Guard (2FA) for an account, prompts for confirmation codes, and exports the account secrets to a JSON file. Ensure to save the exported data immediately to prevent loss of access. ```python import json import asyncio from aiosteampy.session import SteamSession, Platform from aiosteampy.guard import SteamGuard, SmsConfirmationRequired, EmailConfirmationRequired async def enable_two_fa(): session = SteamSession(..., platform=Platform.MOBILE) guard = SteamGuard(session) try: guard.enable() except SmsConfirmationRequired as e: code = input(f"Guard activation code has been sent to your phone ({e.phone_hint}). Paste it here: ") except EmailConfirmationRequired: code = input("Guard activation code has been sent to your email. Paste it here: ") await guard.finalize(code) # Exported guard account contains secrets that cannot be retrieved once more # therefore, data must be saved ASAP to prevent loss of access to a user's Steam account guard_account = guard.export_account() with open(f"./{session.account_name or session.steam_id}.guard.json", "w") as f: json.dump(guard_account.serialize(), f) await guard.transport.close() asyncio.run(enable_two_fa()) ``` -------------------------------- ### Handle Network and Steam API Errors Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/get_started.md Illustrates how to catch and handle potential NetworkError exceptions during network operations and EResultError exceptions for Steam API-specific errors. ```python from aiosteampy.client import SteamClient, EResultError from aiosteampy.transport import NetworkError client = SteamClient(...) try: await client.profile.set_alias("my_awesome_alias") notifications = await client.notifications.get() except NetworkError: print("Need to pay my internet bills :(") except EResultError as e: print(f"Steam response with error ({e.result} | {e.msg} | {e.data}), what a surprise!") ``` -------------------------------- ### Fetch Item Price History Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/get_started.md Retrieve the price history of an item using SteamPublicClient. This method does not require login and returns a list of PriceHistoryEntry objects. ```python import asyncio from aiosteampy.client import SteamPublicClient, App async def get_price_history(): client = SteamPublicClient() entries = await client.market.get_price_history( "Collector's Bonk! Atomic Punch", App.TF2, ) for e in entries: print(e.date, e.price_raw, e.daily_volume) asyncio.run(get_price_history()) ``` -------------------------------- ### Marquee Animation CSS Source: https://github.com/somespecialone/aiosteampy/blob/main/docs/config/theme/main.html Defines a CSS animation for a marquee effect, used for announcements. Ensure the element has a defined height. ```css @keyframes marquee-left { to { transform: translateX(-100%); } } #announce-ukraine { height: 1rem; } #announce-ukraine > a { position: absolute; left: 0; right: 0; overflow: hidden; display: flex; white-space: nowrap; font-style: italic; } #announce-ukraine > a > span { animation: marquee-left 1s linear infinite;; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.