Tools and utilities for TF2 trading
Project description
tf2-utils
Tools and utilities for TF2 trading. Use 3rd party inventory providers, get SKUs directly from inventories, listen to BackpackTF's websocket and more.
Donate
- BTC:
bc1qntlxs7v76j0zpgkwm62f6z0spsvyezhcmsp0z2
- Steam Trade Offer
Features
- Get SKUs directly from inventories/offers
- Fetch inventories using 3rd party providers (avoid being rate-limited)
- Listen for Backpack.TF websocket events
- Listen for Prices.TF websocket events
Setup
Install
pip install tf2-utils
# or
python -m pip install tf2-utils
Upgrade
pip install --upgrade tf2-utils
# or
python -m pip install --upgrade tf2-utils
Usage
See examples or tests for more usage examples.
Inventory fetching
from tf2_utils import Inventory
# using 3rd party provider to avoid being rate-limited
provider = Inventory("steamsupply", "9st947vs0qmgfpeqde1gj92l0oqmhysm")
# using steam as inventory provider
provider = Inventory() # or Inventory("steamcommunity")
# get an inventory
inventory = provider.fetch("76561198253325712")
Gettings SKUs from inventories
NOTE: NOT ALL SKU ATTRIBUTES ARE ADDED YET
Get SKUs implicitly
from tf2_utils import Inventory, map_inventory
provider = Inventory("steamcommunity")
user_inventory = provider.fetch("76561198253325712")
inventory = map_inventory(user_inventory, add_skus=True)
Get a particular item's SKU
from tf2_utils import get_sku
inventory = map_inventory(user_inventory)
for item in inventory:
sku = get_sku(item)
BackpackTF Websocket
Handle one listing at a time
from tf2_utils import BackpackTFSocket
def my_function(data: dict):
print("got data!", data)
socket = BackpackTFSocket(my_function)
socket.listen()
Handle list of listings at a time
from tf2_utils import BackpackTFSocket
def my_function(data: list[dict]):
print("got listings")
for listing in data:
print("listing", listing)
socket = BackpackTFSocket(my_function, solo_entries=False)
socket.listen()
PricesTF Websocket
from tf2_utils import PricesTFSocket
def my_function(data: dict):
print("got data!", data)
socket = PricesTFSocket(my_function)
socket.listen()
Testing
# tf2-utils/
python -m unittest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tf2-utils-2.0.2.tar.gz
(142.9 kB
view hashes)
Built Distribution
tf2_utils-2.0.2-py3-none-any.whl
(66.8 kB
view hashes)
Close
Hashes for tf2_utils-2.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e6324fd497a2424476616703950bb260ed0964b5b9883c37cfa527698edc345 |
|
MD5 | 395237c257319c46968bc014d54f111f |
|
BLAKE2b-256 | d28b16b992cff85c7236067bca52a51b084daad58e096cedc2a387b545c1570e |