Google-sheets – Steam Webapi & Hours played for a specific game – Google Sheets

google sheetsgoogle-apps-scriptgoogle-sheets-custom-function

So I have managed to get a list of owned games and total hours in each game with =importJson. The only issue is I only want data for one game. The json query returns all owned games. The api wiki says I am able to filter by appid (in this case I want appid 393380 only) however I am having trouble figuring out where to put the string the wiki is describing, any thoughts?

=ImportJSON("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=1470922A6B6E5C001546E51ACA5D987B&format=json&steamid="&B2)

https://docs.google.com/spreadsheets/d/1yPNsNbS5osdORa9UfYc62WbqCApbeipHTUbU_DUOOGw/edit?usp=sharing

https://developer.valvesoftware.com/wiki/Steam_Web_API#GetOwnedGames_.28v0001.29

Best Answer

You need to include the &input_json={"appids_filter":393380} at the end of the URL.

So your URL would be ("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=1470922A6B6E5C001546E51ACA5D987B&steamid=XXXXXXXXXXXXXXXX&format=json&input_json={"appids_filter":[393380]})

The JSON must be URL encoded as well. However if your profile is not set to public it will return an Internal Server Error from what I understand.

I could not get this to work because it kept sending me a 500 Internal Server Error. I used this documentation https://developer.valvesoftware.com/wiki/Steam_Web_API#Calling_Service_interfaces