Skip to content

Builds a database of backpack.tf listings, automatically adding and deleting them from the public backpack.tf websocket. Uses mongodb.

License

Notifications You must be signed in to change notification settings

LucasHenriqueDiniz/backpack.tf-ws-service

 
 

Repository files navigation

backpack.tf-ws-service

backpack.tf-ws-service

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.

Table of Contents

This is a table of contents for the README file:

Important Notes

  • 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.

Description

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.

Features

  • 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)

Requirements

  • Python 3.10+
  • A MongoDB instance running
  • A backpack.tf API token

Installation

  1. Clone the repository:
git clone https://github.com/LucasHenriqueDiniz/backpack.tf-ws-service.git
  1. Install the required dependencies:
pip install -r requirements.txt
  1. 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"]
  1. Run the main.py script (ensure you have a mongodb instance running too):
python main.py

Issues

If you encounter any issues, please open an issue in the issues tab.

Contribute

Contributions are always welcome! Please create a pull request with your changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Builds a database of backpack.tf listings, automatically adding and deleting them from the public backpack.tf websocket. Uses mongodb.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%