frissyn / valorant.py

Complete Python interface for the Valorant API. Works right out of the box!
https://valorantpy.readthedocs.io
MIT License
125 stars 19 forks source link

Cannot get AccountDTO via client.get_user(puuid) #34

Closed neilsorkin19 closed 2 years ago

neilsorkin19 commented 2 years ago

Getting an AccountDTO by name and tagline works (client.get_user_by_name(gameName#tagline)), but getting an AccountDTO by puuid (client.get_user())does not work.

Example using SEN ShahZam#huh: client.get_user("ZEwGdkv9sZL2pgwPUfEG-SnldEtqwaqW-neW8y7HL2jmdNptEKpgD598uUA-K7CUR-j67ktFdqJNhg") # SEN ShahZam, does not work client.get_user_by_name("SEN ShahZam#huh") # does work

frissyn commented 2 years ago

Thanks for reporting!

After reproducing this, I've found the issue. When Client.get_user_by_name is called, the client builds a URL pointing to the Riot Games API from the parameters and makes a request to it.

The API endpoint for Riot Accounts uses route rather than region, and the URL builder was using the wrong value. That returns a 400 reponse, and the client interprets it to be missing, giving you None.

Expected Behavior:

client = valorant.Client(KEY, region="na", route="americas")
client.get_user("puuid") # Should build => https://americas.api.riotgames.com/riot/account/v1/accounts/by-puuid/puuid

Actual Behavior:

client = valorant.Client(KEY, region="na", route="americas")
client.get_user("puuid") # Wrong URL => https://na.api.riotgames.com/riot/account/v1/accounts/by-puuid/puuid

I've added this bug to the v1.0.2 milestone, which will go live in a few days. Please use .get_user_by_name until then.