Skip to main content

Manage Steam sessions, Guard, Market, trade offers and more.

Project description

AIOSTEAMPY

Made in Ukraine steam license Poetry Ruff Snyk Badge pypi Release Docs Ask DeepWiki

Manage Steam sessions, Guard, Market, trade offers and more.


Stand With Ukraine

[!IMPORTANT] The project is heading toward 1.0.0 and there can be some changes until stable release but library design as a whole with most API will stay.

Documentation

Installation

Project published on PyPI under aiosteampy name so can be installed with:

pip install aiosteampy
poetry add aiosteampy
uv add aiosteampy

Prereleases

To install prerelease versions (alpha, beta, release candidates), consider allowing the package manager to do it:

pip install --pre aiosteampy
poetry add --allow-prereleases aiosteampy
uv add --prerelease aiosteampy

Extras

Extras can be installed with aiosteampy[<extra>] install target.

Project uses aiohttp as default HTTP transport with all its capabilities and limitations.

  • socks - enable socks type web proxy support for default HTTP transport.
  • wreq - wreq-python HTTP transport implementation. Supports proxies, HTTP/2, and browser impersonification. Will be used automatically once installed.

Quick start

Package separated into main modules which can be imported from aiosteampy namespace:

  • session - Steam Session management and auth tokens negotiation.
  • guard - Steam Guard/Mobile Authenticator (2FA) functionality.
  • client - abstract container for Steam domains implementations (Market, Trade Offers, etc.).

Session

Simple demonstrative example of using SteamSession to log in into account with credentials and then print access and refresh tokens:

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.raw)
    print("Refresh token: ", session.refresh_token.raw)

    await session.transport.close()


asyncio.run(login_with_credentials())

Guard

Using SteamGuard to enable Steam Mobile Auhtenticator (similar to using SDA functionality) and dump SteamGuardAccount data into a file:

import json
import asyncio

from aiosteampy.session import SteamSession
from aiosteampy.guard import SteamGuard, SmsConfirmationRequired, EmailConfirmationRequired


async def enable_two_fa():
    session = SteamSession(...)  # authenticated session

    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}.guard.json", "w") as f:
        json.dump(guard_account.serialize(), f)

    await session.transport.close()


asyncio.run(enable_two_fa())

Client

Using SteamClient with authenticated SteamSession to get current user inventory items:

import asyncio

from aiosteampy.session import SteamSession
from aiosteampy.client import SteamClient, AppContext, App


async def get_inventory():
    session = SteamSession(...)  # authenticated session

    client = SteamClient(session)

    cs2_default = await client.inventory.get(AppContext.CS2)
    print("CS2 items: ", cs2_default.items)

    cs2_trade_protected = await client.inventory.get(AppContext.CS2_PROTECTED)
    print("CS2 items in hold: ", cs2_trade_protected.items)

    # create new App and AppContext
    BongoCatApp = App(3419430, "Bongo Cat")
    BongoCatDefault = AppContext(BongoCatApp, 2)

    bongo_cat = await client.inventory.get(BongoCatDefault)
    print("Bongo Cat items: ", bongo_cat.items)

    await session.transport.close()


asyncio.run(get_inventory())

Key features ✨

  • Stateful: Manages user sessions state throughout the lifecycle.
  • Declarative: There are models for almost every data.
  • Typed: High-end support with extensive typing.
  • Friendly: Intuitive and straightforward API.
  • Flexible: Custom HTTP transport layer can be implemented to fit user needs.
  • Asynchronous: Fully async implementation using asyncio.

What I can do with this

  • Login using credentials and QR, obtain auth web cookies.
  • Operate Trade Offers: send, accept, decline, and counter.
  • Place and cancel buy/sell orders, purchase listings directly on Steam Market.
  • Dump & Load tokens and cookies to enable Session persistence.
  • De/serialize Client state reducing boilerplate and unnecessary work.
  • Accept, deny, and retrieve Steam Mobile Device confirmations.
  • Enable Steam Mobile Authenticator for user account and save secrets.
  • Import secrets from famous SDA format (maFile).
  • Setup, edit information of user Steam profile.
  • Get user account wallet balance, redeem Wallet or Gift codes.
  • Lost access to a user account by denying guidelines and warnings while being unvigilant.
  • And more!

What I can't do

  • Buy app and their package on Steam Store.
  • WebSocket connection to Steam servers.
  • Interact with game servers (inspect CS2 items, find game match, etc.).
  • Social interaction like groups, clans, and chat.
  • Get confused with the complexity of usage.

Contribution 💛

Feedback, suggestions, and bug reports are welcome!

Please keep project style and code quality while contributing, thanks. Use formatter (currently Ruff) whenever possible respecting configuration in pyproject.toml. Remove unrelated code changes from PR and generally be concise, thanks again.

Credits

Sources of inspiration and ideas, concepts, and general knowledge:

Helpful links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiosteampy-1.0.0a2.tar.gz (98.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiosteampy-1.0.0a2-py3-none-any.whl (122.3 kB view details)

Uploaded Python 3

File details

Details for the file aiosteampy-1.0.0a2.tar.gz.

File metadata

  • Download URL: aiosteampy-1.0.0a2.tar.gz
  • Upload date:
  • Size: 98.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiosteampy-1.0.0a2.tar.gz
Algorithm Hash digest
SHA256 9af4122fabff1af4f2fd51b9976181ccc553a13b53e4ac4414bba4e58e768298
MD5 c843e68df01a91345204552fccb80a00
BLAKE2b-256 89b2f4945fd790cc37acf678c2639897366f00b611933c6d7e1c27f211b1e89c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiosteampy-1.0.0a2.tar.gz:

Publisher: release.yml on somespecialone/aiosteampy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiosteampy-1.0.0a2-py3-none-any.whl.

File metadata

  • Download URL: aiosteampy-1.0.0a2-py3-none-any.whl
  • Upload date:
  • Size: 122.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiosteampy-1.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 42895a13889a8c81c64e0b7aa15bcb47b71638c1700d1d1afac6cf6df2c326d3
MD5 eb8bb816a730fc771972e5604d936d36
BLAKE2b-256 7f1e6aef96ec1ba03d7d2971f66ac1a5af0d8bdc13eab0fe4b124491e03f2aac

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiosteampy-1.0.0a2-py3-none-any.whl:

Publisher: release.yml on somespecialone/aiosteampy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page