一定量的请求后,Steam Web api iplayerService响应空了
我正在写一个Python脚本,可以跟踪我的游戏时间。每30秒我“刷新”我从Steam Web API中获得的数据。但是,在经过一定量的电话(大约60个)之后,响应完全为空。
我知道每天最多有100.000个API呼叫,但似乎并没有得到限制,因为我还测试了每60秒,甚至每5分钟一次刷新一次,但是在60左右后,它总是空的呼叫。
这是一些代码:
from steam.webapi import WebAPI
from time import sleep
api = WebAPI(API_KEY, raw=False, format='json', https=True, http_timeout=10)
def game_data(steamids):
data = api.call('IPlayerService.GetOwnedGames', appids_filter=None, include_appinfo=True, include_free_sub=True, include_played_free_games=True, steamid=steamids)
return data['response']['games']
while True:
g_data = game_data(steamids)
playtime = []
for i in g_data:
playtime.append(i['playtime_forever'])
print(playtime)
sleep(30)
输出
{"response":{}}
我正在使用Steam库,该库的工作原理与请求库请求数据基本相同。似乎问题仅在iPlayerService接口上。
在上图中,我计算了请求的数量,如您所见,第60个请求失败了。它提出了一个键盘异常,因为响应是空的。
请让我知道您是否需要其他信息,希望有人知道如何解决此问题。
提前致谢!
I'm writing a Python script that keeps track of my playtime. Every 30 seconds I 'refresh' the data I get from the Steam Web API. But after a certain amount of calls (around 60), the response is totally empty.
I am aware of the maximum of 100.000 API calls per day, but it doesn't seem like I'm getting rate-limited, because I also tested refreshing every 60 seconds, even every 5 minutes, but it always is empty after around 60 calls.
Here's some of the code:
from steam.webapi import WebAPI
from time import sleep
api = WebAPI(API_KEY, raw=False, format='json', https=True, http_timeout=10)
def game_data(steamids):
data = api.call('IPlayerService.GetOwnedGames', appids_filter=None, include_appinfo=True, include_free_sub=True, include_played_free_games=True, steamid=steamids)
return data['response']['games']
while True:
g_data = game_data(steamids)
playtime = []
for i in g_data:
playtime.append(i['playtime_forever'])
print(playtime)
sleep(30)
Output
{"response":{}}
I'm using the steam library, which works basically the same as requesting data with the request library. It seems like the problem is only with the IPlayerService interface.
In the image above I counted the amount of requests, and as you can see, the 60th request failed. It raises a keyError exception, because the response is empty.
Please let me know if you need any other information, and hopefully someone knows how to fix this.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我刚刚找到了一个修复程序,而不是
getownedgames
使用getReclyedGameDgames
。这似乎没有60个限制,另一个限制为60。基本上,这是完全相同的响应,只是它仅返回过去2周内玩过的游戏,这对我来说完全可以。
So I just found a fix, instead of
GetOwnedGames
useGetRecentlyPlayedGames
.This one doesn't seem to have a limit of 60, which the other one has. It's basically the exact same response, except it only returns games that have been played in the past 2 weeks, which is totally fine for my use.