Skip to content

Get item prices and volumes from the Steam Community Market using Python 3

License

Notifications You must be signed in to change notification settings

RoachxD/steam_community_market

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

steam-community-market

A synchronous Python read-only wrapper for the Steam Community Market API.

Version Supported Versions License Documentation Status GitHub Issues GitHub Stars Discord

Table of Contents

Introduction

steam-community-market is a Python library that provides a simple and efficient way to interact with the Steam Community Market API. It is designed to be easy to use and provides support for Python 3.9 and above.

Features:

  • Easy-to-use API
  • Compatible with Python 3.9 and above
  • Extensive documentation

Installation

To install the steam-community-market library, simply run:

  • Linux / macOS:
python3 -m pip install -U steam-community-market
  • Windows:
pip install -U steam-community-market

Usage

To use the library, first import it in your Python script:

from steam_community_market import *

Then, create an instance of the Market class, specifying the currency you want to use:

market = Market(currency=Currency.USD)

Now you can use the various functions provided by the library to interact with the Steam Community Market API.

Examples

Below you can find some examples on how to use different methods of the steam-community-market library.

First, let's import the required libraries for beautifully and correctly print our outputs, and define an item name constant:

import json
import os

# Because we love "Mann Co. Supply Crate Key" <3
MANN_CO_SUPPLY_CRATE_KEY = "Mann Co. Supply Crate Key"

Example: get_overview

print(
    "get_overview:",
    json.dumps(
        market.get_overview(AppID.TF2, MANN_CO_SUPPLY_CRATE_KEY),
        indent=2,
        ensure_ascii=False,
    ),
    sep=os.linesep,
)
# get_overview:
# {
#   'success': True,
#   'lowest_price': '2,22€',
#   'volume': '18,015',
#   'median_price': '2,25€'
# }

Example: get_overviews

market_hash_names = [MANN_CO_SUPPLY_CRATE_KEY, "Name Tag", "The Festivizer"]
print(
    "get_overviews:",
    json.dumps(
        market.get_overviews(AppID.TF2, market_hash_names),
        indent=2,
        ensure_ascii=False,
    ),
    sep=os.linesep,
)
# get_overviews:
# {
#   "Mann Co. Supply Crate Key": {
#     "success": true,
#     "lowest_price": "2,24€",
#     "volume": "18,015",
#     "median_price": "2,25€"
#   },
#   "Name Tag": {
#     "success": true,
#     "lowest_price": "0,37€",
#     "volume": "1,114",
#     "median_price": "0,38€"
#   },
#   "The Festivizer": {
#     "success": true,
#     "lowest_price": "1,26€",
#     "volume": "510",
#     "median_price": "1,25€"
#   }
# }

Example: get_lowest_price / get_price(lowest_price)

try:
    print(
        "get_lowest_price:",
        market.get_lowest_price(AppID.CSGO, "Weapon Barrel"),
        sep=os.linesep,
        end=os.linesep * 2,
    )
except InvalidItemOrAppIDException as e:
    print(
        "[InvalidItemOrAppIDException] get_lowest_price:",
        e,
        sep=os.linesep,
        end=os.linesep * 2,
    )

print(
    "get_price (lowest_price):",
    market.get_price(252490, "No Mercy AK47", "lowest_price"),
    sep=os.linesep,
    end=os.linesep * 2,
)
# 252490 - Rust's App ID
# [InvalidItemOrAppIDException] get_lowest_price:
# Item "Weapon Barrel" with app ID "730" is considered invalid by the Steam Community Market.
#
# get_price (lowest_price):
# 6.33

Example: get_prices

# get_prices
print(
    "get_prices:",
    json.dumps(
        market.get_prices(440, MANN_CO_SUPPLY_CRATE_KEY),
        indent=2,
        ensure_ascii=False
    ),
    sep=os.linesep,
)
# 440 - Team Fortress 2's App ID
# get_prices:
# {
#   'lowest_price': 2.22,
#   'median_price': 2.25
# }

Example: get_volume

# get_volume
# Getting information about "Steam" items is kind of weird, you need to look at its URL.
# IDF (CSGO Trading Card), you need to add 730- to. So it would be "730-IDF".
print(
    "get_volume:",
    market.get_volume(AppID.STEAM, "753-Sack of Gems"),
    sep=os.linesep,
)
# get_volume:
# 4982

For more examples and detailed explanations, please refer to the official documentation and the examples module.

Support

If you have any questions, issues, or suggestions, please create an issue on GitHub or join our Discord server.

Contributing

Contributions are always welcome! If you want to contribute, please fork the repository and submit a pull request.

Donations

If you find this library useful and would like to support the author and maintainer, you can donate using the following methods:

  • Author - @offish

    Steam Trade

    • Bitcoin: bc1qg275cltpez2dcedv2qucrtjxyhq4xurykstldk
  • Maintainer - @RoachxD

    Buy Me A Coffee Ko-fi

    • Bitcoin: bc1qmyyratw3zaf6jj7azrvyr8vqmflpvhwzcf2zp7
    • Ethereum: 0x8Ce07EA13A79bd40FeC8eEbC51BE5F2c69631031

License

steam-community-market is licensed under the MIT License.

About

Get item prices and volumes from the Steam Community Market using Python 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%