Retrieve a list of installed games from the Steam API

↘锁芯ラ 提交于 2019-12-04 14:35:58

问题


I'm working on a Steam Roulette program, and I'm trying to create filters. One of the filters I'd like to implement is (if the user data was loaded with SteamWorks), is to return a list of games (preferably in App ID form) that he/she has installed on his computer that I can then compare to my original full list to remove unneeded values; like a filter to get rid of games the user doesn't have installed on his machine from the list of possible games that can be picked.

In case:

Steam Roulette was an online trend, in the form of a web application in which the user picks a random game out of his/her Steam library and plays it.

Right now, I'm retrieving user details using the Web API using the Steam ID retrieved with SteamUser.GetSteamID().ToString() and feeding it into:

string apiURL = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=" + APIKey + "&steamid=" + id + "&format=json&include_appinfo=1";

And reading the returned .json information from there to generate a list of games that the program can pick from.


Is there any SteamWorks function I can use to retrieve a list of games that is installed on the computer, as opposed to all the games that the player owns/has, without reading the steam libraries for their respective folders?

If no possible function exist, is there any way to manually (outside the API) get a list of installed games?


回答1:


This file C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf

Contains the paths to all local steam libraries. (excluding the one in the default library)

Then get just get the value in the steam_appid.txt that's located in each game's folder ({library}\steamapps\common\{game}\steam_appid.txt) and you will have a list of all installed games' steam app id.




回答2:


I was looking into doing this myself. Unfortunately the steam api does not return a value that could reliably tell you if it's installed on your pc. However looking through the folder where your games are installed (mine is "C:\Program Files (x86)\Steam\steamapps\common") I found that each game folder contains a text file with it's steam app id. So you could recursively look in each folder and build a list of IDs first. Then, use the app ID list with the JSON getOwnedGames for the full name and other info.



来源:https://stackoverflow.com/questions/33662175/retrieve-a-list-of-installed-games-from-the-steam-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!