Steam API - 当我没有游戏时可用统计数据?

问题描述 投票:0回答:1

当从 Steam API 获取游戏的用户统计数据时,使用:

url = f"http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/"
params = {
    'appid': self.appid,
    'key': apikey,
    'steamid': steamid
}
response = requests.get(url, params=params)

如果游戏不被拥有,则返回 None。然而,无论游戏是否被拥有,我都希望能够查看可用的统计名称,因为我想显示它们。有什么办法可以做到这一点吗?我需要找到一个运行所有游戏的帐户吗?谢谢。

python-requests steam steam-web-api
1个回答
0
投票

找到了一个简单的解决方案 - 使用游戏模式端点返回统计名称及其显示名称,这非常有用,以及一些有用的信息。

def gameschema(appid):
    url = "http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/"
    params = {
        'appid': appid,
        'key': apikey
    }
    response = requests.get(url, params=params)
    return response.json()

这将返回此(片段):

© www.soinside.com 2019 - 2024. All rights reserved.