[Solved] Search through JSON query from Valve API in Python


If you are looking for a way to search through the stats list then try this:

import requests
import json

def findstat(data, stat_name):
    for stat in data['playerstats']['stats']:
        if stat['name'] == stat_name:
            return stat['value']

url = "http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=FE3C600EB76959F47F80C707467108F2&steamid=76561198185148697"
data = requests.get(url).text
data = json.loads(data)

total_kills = findstat(data, 'total_kills') # change 'total_kills' to your desired stat name
print(total_kills)

0

solved Search through JSON query from Valve API in Python