Steampy
A Steam trading library for python 3
Install / Use
/learn @bukson/SteampyREADME
Steam Trade Offers Client for Python
Donate bitcoin: 3PRzESHsTVkCFK7osjwFGQLZjSf7qXP1Ta
steampy is a library for Python, inspired by node-steam-tradeoffers, node-steam and other libraries for Node.js.
It was designed as a simple lightweight library, combining features of many steam libraries from Node.js into a single python module.
steampy is capable of logging into steam, fetching trade offers and handling them in simple manner, using steam user credentials
and SteamGuard file, or by passing sessionID and webCookie cookies.
'steampy' is also capable of using proxies.
steampy is developed with Python 3 using type hints and many other features its supported for Windows, Linux and MacOs.
Table of Content
Installation
Requires python 3.12 at least
pip install steampy
Usage
Obtaining SteamGuard from mobile device
Obtaining SteamGuard using Android emulation
** init(self, api_key: str, username: str = None, password: str = None, steam_guard: str = None, login_cookies: dict = None, proxies: dict = None) -> None:**
SteamClient needs at least api_key to provide some functionalities. User can also provide username, password and SteamGuard file to be able to log in and use more methods. Proxies are also supported.
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
User can also provide login_cookies from browser to log in by cookies.
from steampy.client import SteamClient
login_cookies = {} # provide dict with cookies
steam_client = SteamClient('MY_API_KEY',username='MY_USERNAME',login_cookies=login_cookies)
assert steam_client.was_login_executed
proxies dict can be provided for using proxy for internal SteamClient session.
from steampy.client import SteamClient
proxies = {
"http": "http://login:password@host:port",
"https": "http://login:password@host:port"
}
steam_client = SteamClient('MY_API_KEY', proxies=proxies)
If you have steamid, shared_secret and identity_secret you can place it in file Steamguard.txt instead of fetching SteamGuard file from device.
{
"steamid": "YOUR_STEAM_ID_64",
"shared_secret": "YOUR_SHARED_SECRET",
"identity_secret": "YOUR_IDENTITY_SECRET"
}
Examples
You'll need to obtain your API key and SteamGuard file in order to run the examples,
and then fill login and password in storehose.py file.
The storehouse.py file contains an example of handling incoming trade offers.
python storehouse.py
If you want to generate authentication codes and use steampy as steam desktop authenticator
then fill required secrets in desktop_authenticator.py file.
The desktop_authenticator.py file contains examples of generating such one time codes/
python desktop_authenticator.py
SteamClient methods
Unless specified in documentation, the method does not require login to work(it uses API Key from constructor instead)
def set_proxy(self, proxy: dict) -> dict
Set proxy for steampy session, example:
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
proxies = {
"http": "http://login:password@host:port",
"https": "http://login:password@host:port"
}
steam_client.set_proxies(proxies)
def set_login_cookies(self, cookies: dict) -> None
Set login cookies, can be used instead of normal login method.
from steampy.client import SteamClient
login_cookies = {} # provide dict with cookies
steam_client = SteamClient('MY_API_KEY',username='MY_USERNAME',login_cookies=login_cookies)
assert steam_client.was_login_executed
login(username: str, password: str, steam_guard: str) -> requests.Response
Log into the steam account. Allows to accept trade offers and some other methods.
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
You can also use with statement to automatically login and logout.
from steampy.client import SteamClient
with SteamClient('MY_API_KEY', 'MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE') as client:
client.some_method1(...)
client.some_method2(...)
...
logout() -> None
Using SteamClient.login method is required before usage
Logout from steam.
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
steam_client.logout()
You can also use with statement to automatically login and logout.
from steampy.client import SteamClient
with SteamClient('MY_API_KEY', 'MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE') as client:
client.some_method1(...)
client.some_method2(...)
...
is_session_alive() -> None
Using SteamClient.login method is required before usage
Check if session is alive. This method fetches main page and check
if user name is there. Thanks for vasia123 for this solution.
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
is_session_alive = steam_client.is_session_alive()
api_call(request_method: str, interface: str, api_method: str, version: str, params: dict = None) -> requests.Response
Directly call api method from the steam api services.
from steampy.client import SteamClient
steam_client = SteamClient('MY_API_KEY')
params = {'key': 'MY_API_KEY'}
summaries = steam_client.api_call('GET', 'IEconService', 'GetTradeOffersSummary', 'v1', params).json()
get_trade_offers_summary() -> dict
get_trade_offers(merge: bool = True, get_sent_offers: bool = True, get_received_offers: bool = True, use_webtoken: bool =False, max_retry:int = 5) -> dict
Fetching trade offers from steam using an API call. Method is fetching offers with descriptions that satisfy conditions:
* Are sent by us or others
* Are active (means they have `trade_offer_state` set to 2 (Active))
* Are not historical
* No time limitation
If merge is set True then offer items are merged from items data and items description into dict where items id is key
and descriptions merged with data are value.
get_sent_offers and get_received_offers control which offers are fetched.
max_retry controls how many retries the api call will try.
get_trade_offer(trade_offer_id: str, merge: bool = True, use_webtoken:bool =False) -> dict
if use_webtoken is True, then request sent will contain access_token instead of api_key
get_trade_receipt(trade_id: str) -> list
Using SteamClient.login method is required before usage
Getting the receipt for a trade with all item information after the items has been traded.
Do NOT store any item ids before you got the receipt since the ids may change.
"trade_id" can be found in trade offers: offer['response']['offer']['tradeid']. Do not use ´tradeofferid´.
make_offer(items_from_me: List[Asset], items_from_them: List[Asset], partner_steam_id: str, message:str ='') -> dict
Using SteamClient.login method is required before usage
Asset is class defined in client.py, you can obtain asset_id from SteamClient.get_my_inventory method.
This method also uses identity secret from SteamGuard file to confirm the trade offer.
No need to manually confirm it on mobile app or email.
This method works when partner is your friend or steam.
In returned dict there will be trade offer id by the key tradeofferid.
from steampy.client import SteamClient, Asset
from steampy.utils import GameOptions
steam_client = SteamClient('MY_API_KEY')
steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE')
partner_id = 'PARTNER_ID'
game = GameOptions.CS
my_items = steam_client.get_my_inventory(game)
partner_items = steam_client.get_partner_inventory(partner_id, game)
my_first_item = next(iter(my_items.values()))
partner_first_item = next(iter(partner_items.values()))
my_asset = Asset(my_first_item['id'], game)
partner_asset = Asset(partner_first_item['id'], game)
steam_client.make_offer([my_asset], [partner_asset], partner_id, 'Test offer')
make_offer_with_url(items_from_me: List[Asset], items_from_them: List[Asset], trade_offer_url: str, message: str = '', case_sensitive: bool = True) -> dict
Using SteamClient.login method is required before usage
This method is similar to SteamClient.make_offer, but it takes trade ur
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
83.2kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
337.3kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
