|
| 1 | +# SteamCommunityKit |
| 2 | + |
| 3 | +`SteamCommunityKit` is a Python library for real Steam user workflows: |
| 4 | + |
| 5 | +- public Steam Web API reads with a normal `steamcommunity.com/dev` key |
| 6 | +- public no-key community reads such as profile XML, market data, inventory URLs, and group URLs |
| 7 | +- logged-in Steam Community actions such as profile edits, privacy updates, avatar upload, trade URL management, and group creation checks |
| 8 | +- session persistence helpers for refresh tokens, cookies, JSON bundles, and external `requests.Session` reuse |
| 9 | + |
| 10 | +This package is built around the workflows normal users can actually use. It does not try to wrap Steamworks publisher-only administration endpoints that require partner permissions. |
| 11 | + |
| 12 | +## Install |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install SteamCommunityKit |
| 16 | +``` |
| 17 | + |
| 18 | +For local development: |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install -e .[dev] |
| 22 | +``` |
| 23 | + |
| 24 | +## Choose The Right Mode |
| 25 | + |
| 26 | +Use no key when you only need public community data: |
| 27 | + |
| 28 | +```python |
| 29 | +from steamcommunitykit import SteamClient |
| 30 | + |
| 31 | +client = SteamClient() |
| 32 | +print(client.resolve_steam_id("gaben")) |
| 33 | +print(client.get_player_summary("https://steamcommunity.com/id/gaben/")) |
| 34 | +print(client.get_market_price_overview(730, "AK-47 | Redline (Field-Tested)")) |
| 35 | +``` |
| 36 | + |
| 37 | +Use a normal Steam Web API key when you need Web API calls: |
| 38 | + |
| 39 | +```python |
| 40 | +from steamcommunitykit import SteamClient |
| 41 | + |
| 42 | +client = SteamClient(api_key="YOUR_WEB_API_KEY") |
| 43 | +summary = client.get_player_summary("gaben") |
| 44 | +games = client.get_owned_games_for_user("https://steamcommunity.com/id/gaben/") |
| 45 | +news = client.get_news_summary(570, count=2) |
| 46 | + |
| 47 | +print(summary["personaname"]) |
| 48 | +print(games["game_count"]) |
| 49 | +print(news["items"][0]["title"]) |
| 50 | +``` |
| 51 | + |
| 52 | +Use community login when you need account-backed actions: |
| 53 | + |
| 54 | +```python |
| 55 | +from steamcommunitykit import SteamClient |
| 56 | + |
| 57 | +client = SteamClient() |
| 58 | +client.login_to_community("YOUR_USERNAME", "YOUR_PASSWORD") |
| 59 | + |
| 60 | +print(client.get_account_info()) |
| 61 | +print(client.get_trade_offer_url()) |
| 62 | +print(client.get_group_membership_state("Valve")) |
| 63 | +``` |
| 64 | + |
| 65 | +## Verified Workflow Examples |
| 66 | + |
| 67 | +### Save and restore a logged-in session |
| 68 | + |
| 69 | +```python |
| 70 | +from steamcommunitykit import SteamClient |
| 71 | + |
| 72 | +client = SteamClient() |
| 73 | +client.login_to_community("YOUR_USERNAME", "YOUR_PASSWORD") |
| 74 | +client.save_community_session_bundle("steam_session.json") |
| 75 | + |
| 76 | +restored = SteamClient() |
| 77 | +restored.load_community_session_bundle("steam_session.json") |
| 78 | +print(restored.get_community_session_state()) |
| 79 | +``` |
| 80 | + |
| 81 | +### Reuse Steam Community auth with raw requests |
| 82 | + |
| 83 | +```python |
| 84 | +from steamcommunitykit import SteamClient |
| 85 | + |
| 86 | +client = SteamClient() |
| 87 | +client.login_to_community("YOUR_USERNAME", "YOUR_PASSWORD") |
| 88 | + |
| 89 | +session = client.build_community_requests_session() |
| 90 | +response = session.get("https://steamcommunity.com/my/edit/") |
| 91 | +print(response.status_code) |
| 92 | +``` |
| 93 | + |
| 94 | +### Market snapshot from a full listing URL |
| 95 | + |
| 96 | +```python |
| 97 | +from steamcommunitykit import SteamClient |
| 98 | + |
| 99 | +client = SteamClient() |
| 100 | +snapshot = client.get_market_price_snapshot_by_url( |
| 101 | + "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29" |
| 102 | +) |
| 103 | +print(snapshot["price_overview"]["lowest_price"]) |
| 104 | +print(snapshot["listing_summary"]["listing_count"]) |
| 105 | +``` |
| 106 | + |
| 107 | +## Major Features |
| 108 | + |
| 109 | +### Authentication and session management |
| 110 | + |
| 111 | +- credential login with Steam Guard support |
| 112 | +- refresh-token login reuse |
| 113 | +- cookie string, cookie mapping, and JSON bundle import/export |
| 114 | +- file-based session save/load helpers |
| 115 | +- ready-to-use authenticated `requests.Session` |
| 116 | + |
| 117 | +### Community account features |
| 118 | + |
| 119 | +- account/profile bundle reads |
| 120 | +- profile edits for persona name, vanity URL, summary, real name, and location |
| 121 | +- privacy reads and writes |
| 122 | +- avatar upload |
| 123 | +- trade offer URL read/rotate |
| 124 | +- Web API key status page parsing |
| 125 | + |
| 126 | +### Groups |
| 127 | + |
| 128 | +- name, URL, and tag availability checks |
| 129 | +- group details, members, and multi-page member aggregation |
| 130 | +- group member summaries and indexed maps |
| 131 | +- group membership state parsing for the logged-in account |
| 132 | +- group creation with validation and clear limited-account errors |
| 133 | + |
| 134 | +### Market |
| 135 | + |
| 136 | +- search, normalized results, and exact-match helpers |
| 137 | +- price overview |
| 138 | +- listing summaries, maps, filtered lookups, and multi-page aggregation |
| 139 | +- item name ID, order histogram, order summary, and price history |
| 140 | +- one-shot market snapshots |
| 141 | +- full URL-based helper variants |
| 142 | + |
| 143 | +### Inventory |
| 144 | + |
| 145 | +- raw and normalized inventory reads |
| 146 | +- full pagination helpers |
| 147 | +- item search/filtering |
| 148 | +- item counts, asset ID lookup, and URL-based inventory helpers |
| 149 | + |
| 150 | +### Workshop and collections |
| 151 | + |
| 152 | +- published file detail helpers |
| 153 | +- collection details and child item helpers |
| 154 | +- query helpers with cursor pagination |
| 155 | +- normalized maps and exact-match finders |
| 156 | +- full workshop URL helper variants |
| 157 | + |
| 158 | +### Web API reads |
| 159 | + |
| 160 | +- users, friends, bans, owned games, recently played games, badges, levels |
| 161 | +- apps, news, user stats, trade/econ summaries, store searches, and utility endpoints |
| 162 | + |
| 163 | +## Documentation |
| 164 | + |
| 165 | +- [Authentication Guide](docs/authentication.md) |
| 166 | +- [Community Guide](docs/community.md) |
| 167 | +- [Groups Guide](docs/groups.md) |
| 168 | +- [Market Guide](docs/market.md) |
| 169 | +- [Inventory Guide](docs/inventory.md) |
| 170 | +- [Workshop Guide](docs/workshop.md) |
| 171 | +- [Web API Guide](docs/webapi.md) |
| 172 | +- [Testing Guide](docs/testing.md) |
| 173 | +- [Security Policy](SECURITY.md) |
| 174 | + |
| 175 | +## Testing |
| 176 | + |
| 177 | +Run the unit suite: |
| 178 | + |
| 179 | +```bash |
| 180 | +python -m pytest -q |
| 181 | +``` |
| 182 | + |
| 183 | +Run the public smoke suite with an API key: |
| 184 | + |
| 185 | +```bash |
| 186 | +python examples/smoke_test.py --api-key YOUR_WEB_API_KEY --public-only |
| 187 | +``` |
| 188 | + |
| 189 | +Run the community smoke suite with a Steam account: |
| 190 | + |
| 191 | +```bash |
| 192 | +python examples/smoke_test.py --username YOUR_USERNAME --password YOUR_PASSWORD --community-only |
| 193 | +``` |
| 194 | + |
| 195 | +## Notes |
| 196 | + |
| 197 | +- Some Web API features require a normal Steam Web API key. |
| 198 | +- Some community features require a logged-in session. |
| 199 | +- Some actions are restricted by Steam account state, such as limited accounts, Family View, or profile privacy. |
| 200 | +- When a feature requires more auth than the current client state provides, the package raises explicit `SteamAuthenticationError` or `SteamValidationError` messages instead of failing silently. |
| 201 | + |
| 202 | +## Disclaimer |
| 203 | + |
| 204 | +This project is not affiliated with Valve or Steam. Steam pages and response shapes can change over time, so some community-backed helpers may need maintenance if Steam updates its HTML or request flows. |
| 205 | + |
0 commit comments