Reputation: 124
I'm fetching information from the opendota API. I've previously taken out a .csv list with approx. 160 match_ids which I want some more information from and then append certain values to a list.
With the code below, While looping through the list I receive a KeyError.
for x in finallist:
matchinfo = requests.get("https://api.opendota.com/api/matches/{}".format(x)).json()["match_id"]
print(matchinfo)
The KeyError is raised on a certain ID's, but if I use the code below, I get no KeyError and I see the information.
matchspec = requests.get("https://api.opendota.com/api/matches/4184421518").json()['match_id']
matchspec
So through this, 4184421518 prints information, but in the loop it stops at that ID and a couple more IDs below that. Why do I receive a KeyError in the for loop, but not when I specifically ask for the information?
Upvotes: 0
Views: 522
Reputation: 1624
Opendota api is rate limited to 60 requests/min. Make sure you are not exceeding that, as it seems like an error with the api response.
Upvotes: 2