Skip to main content

Simple library to trade and interact with steam market, webapi, guard

Project description

Asyncsteampy

license pypi Tests codecov CodeFactor versions black steam

This library is a soft fork of bukson/steampy ⚠ and created only to provide asynchronous methods and proxies support.

Docs, examples you can read from original README. Differences of usage and new features listed below 📖

Must work with python 3.6 and above like origin, but tested only on 3.10


Navigation


Installation

pip install asyncsteampy

pipenv install asyncsteampy

poetry add asyncsteampy

Login&Init

Now you don't need to pass username, password, steamguard args to login method, you can do this in constructor.

from asyncsteampy.client import SteamClient as AsyncSteamClient

async_steam_client = AsyncSteamClient('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE/STEAMGUARD_DICT',
                                      api_key="API_KEY")

Instead of passing str path or pathlib.Path to steamguard.txt file or even json serialized string you can just use dict object:

steamguard = {
    "steamid": "YOUR_STEAM_ID_64",
    "shared_secret": "YOUR_SHARED_SECRET",
    "identity_secret": "YOUR_IDENTITY_SECRET",
}

AsyncIO

All methods that require connection to steam network now have asyncio support (it uses aiohttp) and are asynchronous : client, market, chat.

from asyncsteampy.client import SteamClient as AsyncSteamClient

async_steam_client = AsyncSteamClient('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE/STEAMGUARD_DICT',
                                      api_key="API_KEY")
await async_steam_client.login()
buy_order_id = "some_buy_order_id"
response = await async_steam_client.market.cancel_buy_order(buy_order_id)
# do other async work
await async_steam_client.close(logout=True)

If you end your operations, ⚠️ keep in mind, you always need to close your async_steam_client. This will do logout (if logout=True) and close aiohttp session properly. Also, you can await async_steam_client.logout() without closing session if you need this for some reason.

Async context manager usage example:

from asyncsteampy.client import SteamClient as AsyncSteamClient

async with AsyncSteamClient('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE/STEAMGUARD_DICT',
                            api_key="API_KEY") as async_steam_client:
    await async_steam_client.do_what_you_need()

There you don't need to call close, async context manager do it automatically when execution passes the block of code.

Proxy support

If your proxy type is socks4/5 you should look at this small but precious library aiohttp-socks, if proxy type http/https, or you don't like aiohttp-socks you can use aiohttp-proxy instead.

import aiohttp
from aiohttp_socks import ProxyConnector

from asyncsteampy.client import SteamClient as AsyncSteamClient

connector = ProxyConnector.from_url('proxy_type://proxy_url_with_or_no_auth')
session_with_proxy = aiohttp.ClientSession(connector=connector)

# Finally, pass session object in AsyncSteamClient

async_steam_client = AsyncSteamClient(..., session=session_with_proxy)
async with AsyncSteamClient(..., session=session_with_proxy) as async_steam_client:
    ...

Tests

To run tests clone repo, install with dev dependencies

poetry install

Create env variables listed in tests/data and run pytest from project dir:

pytest

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

asyncsteampy-0.1.3.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

asyncsteampy-0.1.3-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file asyncsteampy-0.1.3.tar.gz.

File metadata

  • Download URL: asyncsteampy-0.1.3.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1022-azure

File hashes

Hashes for asyncsteampy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d2b6ceab23c84cc9ace78654884b1ff21c00c47248a4e59b0d3ffe9bef0c065d
MD5 727f304371db3d533c536e881b978662
BLAKE2b-256 4f02551b178998f3f2822652fa4e5e4040185e1bf8d8fd6038854f1ddf18188b

See more details on using hashes here.

File details

Details for the file asyncsteampy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: asyncsteampy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1022-azure

File hashes

Hashes for asyncsteampy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c71d507997933dec2fa24eb416d1763af7f6e8ead064e843ed7d739f03bdb5ad
MD5 a7ea53579407e9d4411bb336a912825f
BLAKE2b-256 963d8c17aa3e420216912343c6b0c9000606642ddf7e62939d149c6d97f46ec0

See more details on using hashes here.

Supported by

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