# python-tf2-utilities
A fast, reliable, and easy-to-use Python library for accessing detailed Team Fortress 2 (TF2) data, including items, skins, effects, and more. Built for developers, this library simplifies retrieving and managing TF2 assets, with minimal setup and optimized performance.
Inspired by [TF2autobot's node-tf2-schema](https://github.com/TF2Autobot/node-tf2-schema) and [TF2autobot's node-tf2-sku](https://github.com/TF2Autobot/node-tf2-sku), this library supports a wide range of TF2-related applications.
## Key Features
- **Item Management:** Easily convert between item SKUs, names, and object formats.
- **Schema Integration:** Access and manipulate detailed TF2 schema data, such as item attributes, qualities, and effects.
- **Comprehensive Tools:** Work with unusual effects, paint kits, skins, crate series, crafting recipes, and trade configurations.
- **Lightweight Mode:** Optimize performance by only loading essential schema data for resource-constrained applications.
- **Automatic Updates:** Automatically stay up to date with schema changes through configurable update intervals.
- **User-Friendly API:** Simplify development with clean, consistent, and intuitive methods.
## Installation
Install the library using pip:
```py
pip install tf2-utilities
```
### Prerequisites:
- Python 3.9 or later
- A Steam Web API key (obtain it from [here](https://steamcommunity.com/dev/apikey))
## Getting Started
### Initialize the Library
To initialize the schema, you’ll need your Steam Web API key:
```py
from tf2utilities.main import TF2
# Initialize the TF2 utilities with your Steam API key and settings
schema = TF2(
api_key="your_steam_api_key", # Your Steam Web API key
auto_update=True, # Enable automatic schema updates
update_time=86400, # Update interval in seconds (default: 1 day)
lite=False # Enable lightweight mode (default: False)
).schema
```
### Common Use Cases
- Convert Item SKU to Item Name
```py
item_name = schema.get_name_from_sku("5021;6")
print(item_name) # Output: "Mann Co. Supply Crate Key"
```
- Convert Item Name to Item SKU
```py
item_sku = schema.get_sku_from_name("Mann Co. Supply Crate Key")
print(item_sku) # Output: "5021;6"
```
- Retrieve TF2 Schema as JSON
```py
schema_data = schema.to_json()
print(schema_data) # Output: JSON representation of the schema data
```
### SKU Utilities
- Convert Item SKU to Item Object
```py
from tf2utilities.sku import SKU
item_object = SKU.from_string("5021;6")
print(item_object) # Output: Item object representing the SKU
```
- Convert Item Object to Item SKU
```py
item_object = {
"defindex": 5021,
"quality": 6,
"craftable": True,
"tradable": True,
"killstreak": 0,
"australium": False,
"effect": None,
"festive": False,
"paintkit": None,
"wear": None,
"quality2": None,
"craftnumber": None,
"crateseries": None,
"target": None,
"output": None,
"outputQuality": None,
"paint": None
}
item_sku = SKU.from_object(item_object)
print(item_sku) # Output: "5021;6"
```
- Convert Steam API Data to Item SKU
```py
item_sku = SKU.from_API(item_data)
print(item_sku) # Output: SKU based on API data
```
## Configuration
| Parameter | Description | Default |
|----------------|------------------------------------------------------|----------------|
| `api_key` | Your Steam Web API key. | None |
| `auto_update` | Enable or disable automatic schema updates. | False |
| `update_time` | Time interval (in seconds) between schema updates. | 86400 (1 day) |
| `lite` | Enable lightweight mode for reduced memory usage. | False |
## Contributing
We welcome contributions! If you’d like to improve the library, fix bugs, or add features, please fork the repository, create a branch, and submit a pull request. For ideas or issues, feel free to open an issue on GitHub.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/j0hnnyblack/python-tf2-utilities",
"name": "tf2-utilities",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "tf2, teamfortress2, steam, trade, trading",
"author": "Johnny Black",
"author_email": "lokedixon@hotmail.my",
"download_url": "https://files.pythonhosted.org/packages/3f/5c/8481fa6cbc6d508f9c3ee4ef60d2077be78586384387d8c21cf08c21b0cc/tf2-utilities-3.0.0.tar.gz",
"platform": null,
"description": "# python-tf2-utilities\nA fast, reliable, and easy-to-use Python library for accessing detailed Team Fortress 2 (TF2) data, including items, skins, effects, and more. Built for developers, this library simplifies retrieving and managing TF2 assets, with minimal setup and optimized performance.\n\nInspired by [TF2autobot's node-tf2-schema](https://github.com/TF2Autobot/node-tf2-schema) and [TF2autobot's node-tf2-sku](https://github.com/TF2Autobot/node-tf2-sku), this library supports a wide range of TF2-related applications.\n\n## Key Features\n- **Item Management:** Easily convert between item SKUs, names, and object formats.\n- **Schema Integration:** Access and manipulate detailed TF2 schema data, such as item attributes, qualities, and effects.\n- **Comprehensive Tools:** Work with unusual effects, paint kits, skins, crate series, crafting recipes, and trade configurations.\n- **Lightweight Mode:** Optimize performance by only loading essential schema data for resource-constrained applications.\n- **Automatic Updates:** Automatically stay up to date with schema changes through configurable update intervals.\n- **User-Friendly API:** Simplify development with clean, consistent, and intuitive methods.\n\n## Installation\nInstall the library using pip:\n```py\npip install tf2-utilities\n```\n\n### Prerequisites:\n- Python 3.9 or later\n- A Steam Web API key (obtain it from [here](https://steamcommunity.com/dev/apikey))\n\n## Getting Started\n\n### Initialize the Library\nTo initialize the schema, you\u2019ll need your Steam Web API key:\n```py\nfrom tf2utilities.main import TF2\n\n# Initialize the TF2 utilities with your Steam API key and settings\nschema = TF2(\n api_key=\"your_steam_api_key\", # Your Steam Web API key\n auto_update=True, # Enable automatic schema updates\n update_time=86400, # Update interval in seconds (default: 1 day)\n lite=False # Enable lightweight mode (default: False)\n).schema\n```\n\n### Common Use Cases\n\n- Convert Item SKU to Item Name\n```py\nitem_name = schema.get_name_from_sku(\"5021;6\")\nprint(item_name) # Output: \"Mann Co. Supply Crate Key\"\n```\n\n- Convert Item Name to Item SKU\n```py\nitem_sku = schema.get_sku_from_name(\"Mann Co. Supply Crate Key\")\nprint(item_sku) # Output: \"5021;6\"\n```\n\n- Retrieve TF2 Schema as JSON\n```py\nschema_data = schema.to_json()\nprint(schema_data) # Output: JSON representation of the schema data\n```\n\n### SKU Utilities\n\n- Convert Item SKU to Item Object\n```py\nfrom tf2utilities.sku import SKU\n\nitem_object = SKU.from_string(\"5021;6\")\nprint(item_object) # Output: Item object representing the SKU\n```\n\n- Convert Item Object to Item SKU\n```py\nitem_object = {\n \"defindex\": 5021,\n \"quality\": 6,\n \"craftable\": True,\n \"tradable\": True,\n \"killstreak\": 0,\n \"australium\": False,\n \"effect\": None,\n \"festive\": False,\n \"paintkit\": None,\n \"wear\": None,\n \"quality2\": None,\n \"craftnumber\": None,\n \"crateseries\": None,\n \"target\": None,\n \"output\": None,\n \"outputQuality\": None,\n \"paint\": None\n}\nitem_sku = SKU.from_object(item_object)\nprint(item_sku) # Output: \"5021;6\"\n```\n\n- Convert Steam API Data to Item SKU\n```py\nitem_sku = SKU.from_API(item_data)\nprint(item_sku) # Output: SKU based on API data\n```\n\n## Configuration\n| Parameter | Description | Default |\n|----------------|------------------------------------------------------|----------------|\n| `api_key` | Your Steam Web API key. | None |\n| `auto_update` | Enable or disable automatic schema updates. | False |\n| `update_time` | Time interval (in seconds) between schema updates. | 86400 (1 day) |\n| `lite` | Enable lightweight mode for reduced memory usage. | False |\n\n## Contributing\nWe welcome contributions! If you\u2019d like to improve the library, fix bugs, or add features, please fork the repository, create a branch, and submit a pull request. For ideas or issues, feel free to open an issue on GitHub.\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Get information about TF2 items, effects, skins and more",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://github.com/j0hnnyblack/python-tf2-utilities"
},
"split_keywords": [
"tf2",
" teamfortress2",
" steam",
" trade",
" trading"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "72b8ac1f9953695a3171864d08b2febc54dc93bcfb63a5eb57d32e40fc452cd9",
"md5": "1b3d87efa09280fb8e57f406be39d272",
"sha256": "98623e2f3d3cafc74d249deb49dcf69eab8a665fb3e8b5e8bcf00b3f34f868c3"
},
"downloads": -1,
"filename": "tf2_utilities-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b3d87efa09280fb8e57f406be39d272",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 20089,
"upload_time": "2025-01-10T09:23:06",
"upload_time_iso_8601": "2025-01-10T09:23:06.388609Z",
"url": "https://files.pythonhosted.org/packages/72/b8/ac1f9953695a3171864d08b2febc54dc93bcfb63a5eb57d32e40fc452cd9/tf2_utilities-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3f5c8481fa6cbc6d508f9c3ee4ef60d2077be78586384387d8c21cf08c21b0cc",
"md5": "18e6d9da6adf436bcd4ef6d69a3a7df4",
"sha256": "85d05a67806cd407536abfc3b3e6ec7819c508cdba3fe576d80a7fd815158bd2"
},
"downloads": -1,
"filename": "tf2-utilities-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "18e6d9da6adf436bcd4ef6d69a3a7df4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19006,
"upload_time": "2025-01-10T09:23:08",
"upload_time_iso_8601": "2025-01-10T09:23:08.828080Z",
"url": "https://files.pythonhosted.org/packages/3f/5c/8481fa6cbc6d508f9c3ee4ef60d2077be78586384387d8c21cf08c21b0cc/tf2-utilities-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-10 09:23:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "j0hnnyblack",
"github_project": "python-tf2-utilities",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tf2-utilities"
}