Search code examples
pythonsteamsteam-web-api

Getting information about the game using the steam api


How can I get the name, description, price of the game, but not use the `python-steam-api'?

I did so, but it's using the python-steam-api

from decouple import config

KEY = config("STEAM_API_KEY")

steam = Steam(KEY)

game = steam.apps.get_app_details(271590)
print(game)

The Valve documentation only specifies the possibilities to get information about the user, and only through them to take any information about the game

The documentation I was looking at - https://developer.valvesoftware.com/wiki/Steam_Web_API


Solution

  • You can use steam storefront api. It's separate from the steam web API. It's unofficial and it's used by the steam store itself.

    import requests
    
    
    def get_game_details(app_id):
        url = f"https://store.steampowered.com/api/appdetails?appids={app_id}"
        response = requests.get(url)
        data = response.json()
    
        if data[str(app_id)]['success']:
            game_data = data[str(app_id)]['data']
            name = game_data['name']
            description = game_data['short_description']
            if 'price_overview' in game_data:
                price = game_data['price_overview']['final_formatted']
            else:
                price = 'Free' if game_data['is_free'] else 'price not available'
            return {
                'name': name,
                'description': description,
                'price': price
            }
        else:
            return 'details not found'
    
    
    app_id = 111111  # replace it with our game app id
    game_details = get_game_details(app_id)
    print(game_details)