Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

AIOSTEAMPY

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

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


Stand With Ukraine

[!WARNING] 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.

[!IMPORTANT] Beta Steam Market methods, models, and related functionality will replace old when Steam migrate their website keeping old names whenever possible. No longer functional methods will be removed conveniently.

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

SteamSession provides functionality to log into user account using either credentials or QR. When the login process has been finalized web auth cookies can be obtained to enable interaction with SteamCommunity domains like Confirmations (see guard), Market, TradeOffers, Profile and Inventory (see client). Methods serialize and deserialize allows to dump/load SteamSession into/from JSON-safe dict.

Demonstrative example of using SteamSession to log into account with credentials, obtaining web cookies and finally dump session into file:

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())

Session can then be loaded from a dump. Although not verified for expiration, tokens and cookies will be restored:

with open(f"./{account_name}.session.json", "r") as f:
    session = SteamSession.deserialize(json.load(f))

Guard

SteamGuard embodies Steam Mobile Authenticator functionality from mobile app. Can activate account 2FA (similar to using SDA), generate auth codes, sign auth requests made with other SteamSession by QR, handle Steam Confirmations. Eventually, guard requires session with mobile app platform.

Here we're using SteamGuard to activate Authenticator and dump SteamGuardAccount data into a file then:

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())

Client

SteamClient composes all Steam domains implementations: Market, Trade Offers, Inventory, Profile, Wallet and more. Each domain is responsible for related functionality. For example, Market domain contain methods allow to retrieve and buy listings from Steam Market, place buy and sell orders. Trade Offers provides methods to send, accept or deny offers and so on.

There is also a SteamPublicClient entity in aiosteampy.client namespace that allows interaction with Steam from unauthenticated (anonymous) user perspective.

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(...)

    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())

Retrieving item orders histogram from SteamMarket with an unauthenticated client:

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())

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.
  • Retrieve, accept, and deny 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.
  • Inspect CS2 items.
  • 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 (like find game match).
  • Social interaction like groups, clans, and chat.
  • Get confused with the complexity of usage.

Contribution 💛

Feedback, suggestions, and bug reports are welcome!

If you have any question regarding a project, don't hesitate to ask one in Q&A.

Before creating a pull request, please try to keep project style and code quality while contributing. Use formatter (currently Ruff) whenever possible respecting configuration in pyproject.toml. Remove unrelated code changes from PR and generally be concise, thanks!.

Credits

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

Helpful links

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.0b13.tar.gz (110.1 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.0b13-py3-none-any.whl (140.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiosteampy-1.0.0b13.tar.gz
Algorithm Hash digest
SHA256 10582becf2df2fbd27ea688f67c9a63a67ee58b7bc9061687053eaa4e696adad
MD5 6ffd6877cc829aa15fe2258a5f5c3b58
BLAKE2b-256 0bd97fcb8b2ac815369c8c49747f97b4f1f065ddcf1e823ff9380eda407cc256

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiosteampy-1.0.0b13.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.0b13-py3-none-any.whl.

File metadata

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

File hashes

Hashes for aiosteampy-1.0.0b13-py3-none-any.whl
Algorithm Hash digest
SHA256 36a5a48dc282bd96d841cd2220498d3c68f35ad0ff682a71b3b414003c807203
MD5 c0ba3786503f435bf7aa9fcb0afd9b2a
BLAKE2b-256 6c99c1d6dd625d8869e7bffab0adb3a1ae83ded4420d0119168019a5d6090159

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiosteampy-1.0.0b13-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.

Release history Release notifications | RSS feed

This release

1.0.0b13 This release

2 files

0.7.21

2 files

0.7.20

2 files

0.7.19

2 files

0.7.18

2 files

0.7.17

2 files

0.7.16

2 files

0.7.15

2 files

0.7.14

2 files

0.7.13

2 files

0.7.12

2 files

0.7.11

2 files

0.7.10

2 files

0.7.9

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Supported by

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