Skip to content

Quickstart

Steam API example

  • First a path to steam library file. This library should be provided with your game. Library for various OS (libsteam_api.so or steam_api.dll or libsteam_api.dylib) is distributed with Steam SDK available for Steam partners at https://partner.steamgames.com/downloads/list

  • Second. Your need to know application (game) identifier provided by Steam. Pass it as a parameter or put steam_appid.txt file with that ID in your game folder.

Note

Sample OpenGL app using steampak is available here: https://github.com/idlesign/steampak/tree/master/demo

Now you're ready to begin. API initialization is easy:

1
2
3
4
5
6
from steampak import SteamApi  # Main API entry point.

LIBRARY_PATH = '/home/me/my_steam_game/libsteam_api.so'
APP_ID = 480  # We use `Spacewar` ID. (This game is provided with SDK).

api = SteamApi(LIBRARY_PATH, app_id=APP_ID)

After that you can access various API parts as api object attributes:

# Let's print some friend names:
for user in api.friends:
    print(user.name)

# Print out some info from utils:
print(api.utils.country_code)
print(api.utils.ui_language)

# Achievements progress (Spacewar has no achievements though):
for ach_name, ach in api.apps.current.achievements:
    print('%s (%s): %s' % (ach.title, ach_name, ach.get_unlock_info()))