How can I get a list of the App IDs of all games in my library?

The script you've linked gets your entire Steam library as XML. The ID you're looking for is included in the XML.

The script retrieves your library from the following link:

http://steamcommunity.com/id/{0}/games?tab=all&xml=1

where {0} is your profile ID. To find your profile ID, go to your profile page on Steam, click on "Edit Profile", and the ID will be the number in the "Custom URL" section. Alternatively, you can log in to Steam in your browser, go to your profile page, and get the ID from the URL in your browser's address bar.

The XML contains a steamID (your profile name), a steamID64 (a unique number), and a list of your games.

Here's an example of a game I own:

<game>
    <appID>220</appID>
    <name>
        <![CDATA[ Half-Life 2 ]]>
    </name>
    <logo>
        <![CDATA[
            https://steamcdn-a.akamaihd.net/steam/apps/220/capsule_184x69.jpg
        ]]>
    </logo>
    <storeLink>
        <![CDATA[ https://steamcommunity.com/app/220 ]]>
    </storeLink>
    <statsLink>
        <![CDATA[
            https://steamcommunity.com/id/{steamID64}/stats/HL2
        ]]>
    </statsLink>
    <globalStatsLink>
        <![CDATA[ https://steamcommunity.com/stats/HL2/achievements/ ]]>
    </globalStatsLink>
</game>

Which means that I own a game called "Half-Life 2", whose ID is 220.

Now all we need to do is write the function that'll give us a list of game IDs.

NOTE: The script you've linked is written in Python 2, but I use Python 3. If you have to use Python 2, you'll need to do the conversion yourself, which shouldn't be too hard to do.

def get_ids(username):
    tree = ET.parse(get_steam_xml(username))
    root = tree.getroot()

    if root.find('error') is not None:
        print(root.find('error').text)
        sys.exit(0)

    return {game.find('appID').text: game.find('name').text for game in root.iter('game')}

Or if you want a full standalone script:

import os
import sys
import urllib.request
import xml.etree.ElementTree as ET


def get_steam_xml(username):
    xml_url = 'http://steamcommunity.com/id/{}/games?tab=all&xml=1'.format(
        username)
    return urllib.request.urlopen(xml_url)


def get_ids(username):
    tree = ET.parse(get_steam_xml(username))
    root = tree.getroot()

    if root.find('error') is not None:
        print(root.find('error').text)
        sys.exit(0)

    return {game.find('appID').text: game.find('name').text for game in root.iter('game')}


def main():
    username = input('Steam username: ')
    path_to_save = input(
        'Path to save (leave blank for current directory): ')

    if path_to_save == '':
        path_to_save = '.'
    else:
        path_to_save = path_to_save.replace('\\', '/')
        if path_to_save[-1:] == '/':
            path_to_save = path_to_save[:-1]

    if not os.path.isdir(path_to_save):
        print('Directory does not exist')
        sys.exit(0)

    with open(path_to_save + '/ids.txt', 'w', encoding='utf-8') as f:
        for id, name in get_ids(username).items():
            f.write("{},{}\n".format(id, name))


if __name__ == '__main__':
    main()

This creates a "ids.txt" file where each line is in the format: id,name. Note that a game's name can contain commas. If you need the file in a different format, you'll need to modify the script yourself.


Here is a simpler method that works even when your games list is private:

  1. Apply for a Steam dev API key here.
  2. Visit https://steampowered.com and open the dev console (Windows: ctrl+shift+i; Mac: cmd+option+i)
  3. Paste in the following script, replacing the profile ID and dev API key with your own:
const devApiKey = 'xxxxxxxxxxxxxxxxxxx';
const profileId = '12345678901234567890';
const response = await fetch(`https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=${devApiKey}&steamid=${profileId}&format=json`);
const json = await response.json();
const appIds = json.response.games.map(o => o.appid);
console.log(JSON.stringify(appIds));

How it works

Of course, you should never paste in random code into your dev console without understanding how it works. Fortunately, this script is stupidly simple: it calls the Steam Web API GetOwnedGames call, then strips out only the appIds and prints them to the console using JSON.stringify()


Go to this url: https://steamcommunity.com/id/<userID>/games?xml=1, and exchange <userID> for your username.
The generated xml file will list all games in your library (they might have to be set to public), and their respective App ID will be between <appID> tags.

You can use Notepad++ to filter them out.

Tags:

Steam