How can I get a list of the App IDs of all games in my library?
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?
Solution 1:
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.
Solution 2:
Here is a simpler method that works even when your games list is private:
- Apply for a Steam dev API key here.
- Visit https://steampowered.com and open the dev console (Windows: ctrl+shift+i; Mac: cmd+option+i)
- 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()