This project is a parser for the steam market of such games as CS 2, Team Fortress 2, Dota 2, PUBG, RUST, etc.
This guide describes the steps to install and run the project on Linux and Windows.
Before you start, make sure that the following components are installed on your system:
- Python 3 (check with
python3 --versionLinux /python --versionWindows)
- pip (check with
pip --version) - Git (check with
git --version) - Python Virtual Environment (venv)
- Linux Shell (for example, Bash)
Clone the project repository using Git:
git clone https://github.com/RandomProgramm3r/Steam-Market-ScraperCreate a virtual environment using the venv command, which allows you to isolate project dependencies:
python3 -m venv venv # Linux
python -m venv venv # WindowsActivate the virtual environment:
source venv/bin/activate # Linux
source venv/Scripts/activate # WindowsInstall the dependencies for local development:
pip install -r requirements.txtFor code consistency and quality checks, use Ruff - a unified linter/formatter:
# Run linting checks.
ruff check
# Auto-fix fixable lint issues
ruff check --fix
# Format code.
ruff formatpython3 -m unittest discover -v # Linux
python -m unittest discover -v # WindowsA market_scraper function retrieves pricing information for a specified item from the Steam Community Market.
It constructs the request URL using the item name, Steam application ID, and the desired currency, the fetches and decodes the JSON response.
the list of all available currencies is stored in data.py, as well as a list with some games from steam. (you can add your own games)
import data
def market_scraper(
item_name: str,
app_id: int,
currency: int = data.Currency.USD.value,
) -> str:
passimport data
import scraper
# Example usage: Fetch price information for 'Dreams & Nightmares Case' in USD for the CS2 app.
print(
scraper.market_scraper(
'Dreams & Nightmares Case',
data.Apps.CS2.value,
data.Currency.USD.value,
),
){
"success": true,
"lowest_price": "$2.19",
"volume": "112,393",
"median_price": "$2.16",
"game_name": "CS2",
"currency_name": "USD",
"item_name": "Dreams & Nightmares Case"
}see more in examples.py
async def main():
items = [
('Dreams & Nightmares Case', data.steam_data.Apps.CS2.value, data.steam_data.Currency.USD.value),
('Mann Co. Supply Crate Key', data.steam_data.Apps.TEAM_FORTRESS_2.value, data.steam_data.Currency.EUR.value),
...
]
tasks = [
src.scraper.async_.market_scraper_async(name, app_id, currency)
for name, app_id, currency in items
]
results = await asyncio.gather(*tasks)
for result in results:
print(result)
if __name__ == '__main__':
asyncio.run(main()){
"success": true,
"lowest_price": "$2.19",
"volume": "112,393",
"median_price": "$2.16",
"game_name": "CS2",
"currency_name": "USD",
"item_name": "Dreams & Nightmares Case"
}
{
"success": true,
"lowest_price": "2,01β¬",
"volume": "18,776",
"median_price": "2,03β¬",
"game_name": "TEAM_FORTRESS_2",
"currency_name": "EUR",
"item_name": "Mann Co. Supply Crate Key"
}