Skip to main content

Tools and utilities for TF2 trading

Project description

tf2-utils

License Stars Issues Size Discord Code style

Tools and utilities for TF2 trading. Use 3rd party inventory providers, get SKUs directly from inventories, listen to BackpackTF's websocket and more.

Donate

Usage

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 BackpackTFWebsocket

def my_function(data: dict):
    print("got data!", data)

socket = BackpackTFWebsocket(my_function)

socket.listen()

Handle list of listings at a time

from tf2_utils import BackpackTFWebsocket

def my_function(data: list[dict]):
    print("got listings")

    for listing in data:
        print("listing", listing)

socket = BackpackTFWebsocket(my_function, solo_entries=False)

socket.listen()

Setup

Install

pip install tf2-utils
# or 
python -m pip install tf2-utils

Upgrade

pip upgrade tf2-utils
# or 
python -m pip upgrade tf2-utils

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

tf2-utils-2.0.0.tar.gz (62.2 kB view hashes)

Uploaded Source

Built Distribution

tf2_utils-2.0.0-py3-none-any.whl (63.9 kB view hashes)

Uploaded Python 3

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