Skip to main content

stntrading

License Stars Issues Size Discord Code style

Interact with STNTrading.eu's API hosted at https://api.stntrading.eu

For getting inventories and item names, I recommend using tf2-utils.

Installation

pip install stntrading

Update

pip install --upgrade stntrading

Setup

Find or register your API key on https://stntrading.eu/dev/apikey

If you want to access BETA endpoints shown here, you need STN Premium. For more information read this.

Usage

>>> from stntrading import STN, EStateCodes

>>> stn = STN("26bf8abb59e86b4301aaff5b88547aaf") # (fake api key)

>>> stn.get_key_prices()
{'success': 1, 'result': {'pricing': {'buyPrice': 570.0, 'sellPrice': 606.0}}}

>>> stn.get_key_stock()
{'success': 1, 'result': {'stock': {'canBuy': 15, 'canSell': 15, 'stockLevel': 702, 'stockLimit': 1770}}}

>>> stn.request_key_trade("buy", 1)
{'success': 0, 'error': "Failed to create trade: 'NotEnoughCurrenciesUser'"}

>>> stn.get_trade_status(20530029)
{'success': 1, 'result': {'trade': {'state': 15, 'tradeOfferId': 6697968536}}}

>>> EStateCodes(15).name
CANCELLED_AFTER_SENDING

>>> stn.request_item_trade("buy", "The Team Captain", 1)
{'success': 1, 'result': {'tradeDetails': {'id': 20530029, 'bot': '76561198309976634'}}}

>>> stn.request_item_trade("sell", [12552033523], 1)
{'success': 0, 'error': "Failed to create trade: 'UserItemOverstocked'"}

# ----------------------
# if STN Premium access:
# ----------------------
>>> stn.get_schema()
{'success': 1, 'result': {'schema': ['A Brush with Death', 'A Color Similar to Slate', 'A Deep Commitment to Purple', ...]}}

>>> stn.get_item_details("The Team Captain")
{'success': 1, 'item': {'full_name': 'The Team Captain', 'pricing': {'buy': {'keys': 0, 'metal': 10.0}, 'sell': {'keys': 0, 'metal': 10.88}}, 'stock': {'level': 48, 'limit': 100}}}

Documentation

Documentation can be found on the official wiki or using Swagger.

License

Copyright (c) 2020-2024 offish

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for stntrading 1.1.0

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

Source distribution (sdist)

Source distribution for stntrading 1.1.0
File Size Uploaded
stntrading-1.1.0.tar.gz 6.1 kB Details

Built distribution (wheel)

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

Total release size: 12.0 kB

Release files / stntrading-1.1.0.tar.gz

Download URL stntrading-1.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3adeddee715a384b6387ce58928f2a96938724c66de3f66dc331baf09f978db0
BLAKE2b-256 checksum
How to use checksums
e17f2b96e5bc6018595892df1d1a6845727940a18c7496e4e0a5cefa1e98eba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / stntrading-1.1.0-py3-none-any.whl

Download URL stntrading-1.1.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
670b0993ee02c2530d0eb2d458aa22ebb662c6c12dc055040dc17ea18a311336
BLAKE2b-256 checksum
How to use checksums
d540cfcdec1bf987834ff5c161144f8b928434564092f855e42ca11104f3b8ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

1 release file

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