8

I have over 1100 games and am saving them all locally, and want associated data for the games so I can easily transfer games from PC to PC on my home network, but the game ID is needed, and I'm not really up to the task of finding them all manually.

I found this script that downloads all header images for the games I own on Steam, but is there a way to get an overview of all App IDs of all of the games in my Steam library?

1
  • 1
    Hi HTWingNut, welcome to Arqade! I've added the original script link back - now that the question no longer asks for a recommendation for an external script, I don't think it's removal is warranted - it made the answers that addressed the script confusing without it. Hope that helps :)
    – Robotnik
    Mar 9, 2020 at 6:18

4 Answers 4

11

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.

4
  • Wow, thanks for that detail! That is great. I can use Python 3 just fine. I only used Python 2 because that other code was written for it. I'll give it a go. I haven't done any real scripting for ages, but your code will make it easy! Thanks so much.
    – HTWingNut
    Mar 7, 2020 at 15:43
  • Thanks. I ran it, but it gave me an error that 'urllib' has no attribute 'request'
    – HTWingNut
    Mar 7, 2020 at 16:02
  • Ok, I had to import urllib.request as well. Any way for it to also add the associated file name to the ID. With comma or Tab delimiter? Thanks again.
    – HTWingNut
    Mar 7, 2020 at 16:26
  • I ended up just changing 'appID' attribute to 'name' attribute and ran it again and just copy/pasted data into an excel spreadsheet. Thanks.
    – HTWingNut
    Mar 7, 2020 at 16:37
8

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()

5

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.

2

Okay, I think I've got the easiest way. You can scrape necessary values from the XML using Google Sheets.

Open up Google Sheets and in a new sheet input:

=importxml("https://steamcommunity.com/id/{0}/games?tab=all&xml=1","//appID")

And next to it:

=importxml("https://steamcommunity.com/id/{0}/games?tab=all&xml=1","//name")

Replace {0} with your profile ID, as directed in another comment, it can be found under "Edit Profile" in Steam settings.

This will create you the table with all the game IDs next to all the names.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .