Skip to content

hldh214/buff2steam

Repository files navigation

Special thanks to the generous sponsorship by:

logo

Buff2steam

Build and release

Welcome to buff2steam, a Python script for finding items on buff that are cheaper than on Steam Community Market. This readme provides an overview of the project and instructions on how to use it.

Disclaimer: Recently, some users have reported that their accounts were banned by Buff for using this project. Please be careful and use at your own risk.

简体中文

Table of Contents

Table of contents generated with markdown-toc

Introduction

buff2steam is a script, for crawling items from buff which cheaper than steamcommunity.

With buff2steam, you can crawl items on buff and compare their prices to those on steamcommunity. After setting the threshold in the config.json file, the script will automatically calculate the price difference and filter out matching items.

demo

The output includes:

  • buff_id: goods_id in url: https://buff.163.com/market/goods?goods_id=2334
  • price: item price on buff
  • sell/want: item sell/buy order count on steamcommunity market
  • b_o_ratio: ratio obtained by selling this item to the highest buy order in the steamcommunity market immediately (transaction fee included)
  • ratio: possible ratio obtained by selling this item with the lowest sell order price in the steamcommunity market (transaction fee included)

The last two ratios are the ratio of the price difference. The lower the value, the better, and it means that you have obtained the discounted steam wallet balance through this transaction.

Then you can buy items from buff manually and sell them to the steamcommunity.

Webgui

A small webgui is hosted on 127.0.0.1:1821 (more work needed)

Requirements

To use buff2steam, you need to have:

  • python >= 3.7
  • pip install --user pipenv
  • pipenv sync
  • cp config.sample.json config.json

Usage

# Use the UTF-8 mode on Windows
export PYTHONUTF8=1

# activate a new shell with pipenv
pipenv shell
python -m buff2steam

# or run directly inside pipenv
pipenv run python -m buff2steam

Run with Docker

Docker Image

# Build image yourself
docker buildx build -t buff2steam_local .
docker run -e buff2steam_local

# Or use prebuilt image
docker run -it --name buff2steam --rm -v $PWD/config.json:/app/config.json ghcr.io/hldh214/buff2steam

Configuration

config.json

{
  "main": {
    "debug": true, // false
    "game": "csgo",  // dota2
    "game_appid": "730",  // 570
    "accept_buff_threshold": 0.65,  // acceptable ratio
    "accept_steam_threshold": 0.8,  // acceptable maximum ratio before fetching prices (in case of Steam API ratelimit)
    "min_volume": 0,  // minimal number of sales in 24 hours for an item to be viable
    "min_price": 500,  // CNY, 500 == 5 yuan
    "max_price": 30000,  // CNY, 30000 == 300 yuan
    "webgui_refresh_time": 1 // update time of webgui in seconds or false, for none
  },
  "buff": {
    "sort_by": "sell_num.desc",  // sort by Quantity (descending), Available options: null, "price.asc", "price.desc", "sell_num.desc"
    "request_interval": 4,  // buff api request interval (in seconds)
    "requests_kwargs": {
      "headers": {
        "cookie": "session=1-GyCKVt_sSLoNtu2yeM9hY8FPeWTr8Q6ayOYIifqxKLM82044786689",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
        "Referer": "https://buff.163.com/market/dota2",
        "X-Requested-With": "XMLHttpRequest"
      }
    }
  },
  "steam": {
    "request_interval": 4,  // steam api request interval (in seconds)
    "requests_kwargs": {
      "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
      }
    }
  }
}

buff_session

session

To set the buff_session field in config.json, follow these steps:

  • Open https://buff.163.com/market/ in Chrome
  • Press F12 to open the developer console
  • Go to the Network tab and refresh the webpage
  • Filter by Doc and find session in the Set-Cookie field under Response Headers
  • Copy the value of session and paste it into config.json -> buff.requests_kwargs.headers.cookie

StarChart

starchart

License

buff2steam is open-source software licensed under the Unlicense License. See the LICENSE file for more information.