Search code examples
pythonriot-games-api

python riotwatcher bad request for url


I'm trying to access to the matchlist of a player from his puuid, but when i execute my code, i get an error... Why is this error happening? I have the right RiotApiKey, and the right player_puuid because when i execute the request from https://developer.riotgames.com/apis#match-v5/GET_getMatchIdsByPUUID it works and returns me the matchlist, i cant find why this simple task doesnt work. Thanks for your help

My code:

from riotwatcher import LolWatcher
from settings import RiotKey,riotApiRegion,player_puuid

watcher = LolWatcher(RiotKey)
matches = watcher.match.matchlist_by_puuid(riotApiRegion,player_puuid)

Then i get this error :

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://euw1.api.riotgames.com/lol/match/v5/matches/by-puuid/RGAPI-a65424c1-2e67-44b0-97f5-0179453c3f5e/ids

Solution

  • The new match_v5 uses a new type of region instead of "euw1" for exemple now it's "europe".

    old = ["na1", "euw1", "eun1", "kr", "br1", "jp1", "ru", "oc1", "tr1", "la1", "la2"]
    
    new = ["europe", "asia", "americas"]
    
    from riotwatcher import LolWatcher
    from settings import RiotKey,riotApiRegion,player_puuid
    
    watcher = LolWatcher(RiotKey)
    matches = watcher.match.matchlist_by_puuid("europe", player_puuid)