This is a improved version of the original backpack.tf-ws-service, with the focus on being lightweight in MongoDB (so it can be used in free tier) and with a better code structure and logging.
This is a table of contents for the README file:
- Project Title
- Table of Contents
- Important Notes
- Description
- Features
- Requirements
- Installation
- Issues
- Contribute
- License
- This project is a fork of the original backpack.tf-ws-service, with the focus on being lightweight in MongoDB (so it can be used in free tier) and with a better code structure and logging.
- This project is not affiliated with backpack.tf in any way.
- You need a backpack.tf API token to use this project.
- This project is in development, so it may have bugs and issues.
backpack.tf-ws-service is a script designed to connect to backpack.tf's websocket service and gather listing data.
It also calls the backpack.tf snapshot endpoint frequently to ensure the data is kept up to date.
This listings are stored in a MongoDB database.
- Real-time listing updates from backpack.tf's websocket service (using the backpack.tf websocket API)
- Frequent snapshot updates from backpack.tf's snapshot endpoint
- Storage of listing data in a MongoDB database (using pymongo)
- Prioritized items (items that get their snapshots retrieved more frequently)
- Python 3.10+
- A MongoDB instance running
- A backpack.tf API token
- Clone the repository:
git clone https://github.com/LucasHenriqueDiniz/backpack.tf-ws-service.git
- Install the required dependencies:
pip install -r requirements.txt
-
Create the json file with the api token and mongo settings (example in config-example.json):
{ "mongo_uri": "YOUR_MONGO_URI", "database_name": "YOUR_DATABASE_NAME", "collection_name": "YOUR_COLLECTION_NAME", "bptf_token": "YOUR_BPTF_TOKEN", "websocket_url": "wss://ws.backpack.tf/events", "print_events": 3, "prioritized_items": ["Mann Co. Supply Crate Key"] }
- mongo_uri: MongoDB URI to connect to the database
-
- Example: mongodb+srv://<MANGODB_USER>:<MANGODB_USER_PASSWORD>@backpacktf-database.123.mongodb.net/
- database_name: Database name where the data will be stored
-
- Example: backpacktf
- collection_name: Collection name where the data will be stored
-
- Example: listings
- bptf_token: backpack.tf API token
-
- You can get it here
- websocket_url: backpack.tf websocket url
-
- Use: wss://ws.backpack.tf/events
- print_events: logging from the code
-
- Example: 0 = critical, 1 = all, 2 = errors, 3 = errors and warnings, 4 = debug
- prioritized_items: Items that will have their snapshots retrieved more frequently
-
- Example: ["Mann Co. Supply Crate Key"]
- Run the main.py script (ensure you have a mongodb instance running too):
python main.py
If you encounter any issues, please open an issue in the issues tab.
Contributions are always welcome! Please create a pull request with your changes.
This project is licensed under the MIT License - see the LICENSE file for details.