Skip to main content

Asynchronous python library for Steam authorization using protobuf

pypi: package Python: versions

Install

pip install pysteamauth

Usage

from pysteamauth.auth import Steam


async def main():
    steam = Steam(
        login='login', 
        password='password',
    )
    
    await steam.login_to_steam()

    await steam.request('https://steamcommunity.com')
    await steam.request('https://store.steampowered.com')
    await steam.request('https://help.steampowered.com')

If account have Steam Guard

from pysteamauth.auth import Steam

steam = Steam(
    login='login',
    password='password',
    shared_secret='shared_secret',
)

Cookie storage

Library uses default cookie storage BaseCookieStorage, which stores Steam cookies in application memory. But you can write own cookie storage. For example, redis storage:

import json
from typing import Dict

from aioredis import Redis
from pysteamauth.abstract import CookieStorageAbstract
from pysteamauth.auth import Steam


class RedisStorage(CookieStorageAbstract):

    redis = Redis()

    async def set(self, login: str, cookies: Dict) -> None:
        await self.redis.set(login, json.dumps(cookies))

    async def get(self, login: str, domain: str) -> Dict:
        cookies = await self.redis.get(login)
        if not cookies:
            return {}
        return json.loads(cookies).get(domain, {})


async def main():
    steam = Steam(
        login='login',
        password='password',
        cookie_storage=RedisStorage(),
    )
    
    await steam.login_to_steam()

Error processing

from pysteamauth.auth import Steam
from pysteamauth.errors import SteamError


async def main():
    try:
        await Steam('login', 'password').login_to_steam()
    except SteamError as error:
        print(error)

Or

from pysteamauth.auth import Steam
from pysteamauth.errors import SteamError, custom_error_exception


class LoginError(SteamError):
    ...


class RateLimitExceeded(SteamError):
    ...


custom_error_exception({
    5: LoginError,
    84: RateLimitExceeded,
})


async def main():
    try:
        await Steam('login', 'password').login_to_steam()
    except LoginError as error:
        print(error)

Output

{'error': 'InvalidPassword', 'code': 5}

Proto files

License

MIT

Release files for pysteamauth 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysteamauth 1.1.2
File Size Uploaded
pysteamauth-1.1.2.tar.gz 33.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysteamauth 1.1.2
File Interpreter ABI Platform
pysteamauth-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size:71.0 kB

Release files / pysteamauth-1.1.2.tar.gz

Download URL pysteamauth-1.1.2.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
097865de7146133c72e56a4f375fb8c9620b5356e7249c0732a47475bbb2fd19
BLAKE2b-256 checksum
How to use checksums
ec9bfb0339532a509a91ed8cd9cf3aebaf3fcb58daa074e61e424ecb9ab1e3ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / pysteamauth-1.1.2-py3-none-any.whl

Download URL pysteamauth-1.1.2-py3-none-any.whl
Size 37.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4a62f440241a0f6816957046fd58b8d109975094253846e298ddd0d3db88389
BLAKE2b-256 checksum
How to use checksums
a4113b13ff97cfb77bc9f803e0e70e8b5644c2a3e25ca10f3178d529b46abfd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.0

1 release file

1.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page