pseudonym117 / Riot-Watcher

Simple Python wrapper for the Riot Games API for League of Legends
MIT License
532 stars 150 forks source link

Getting started with TFT watcher #194

Closed enric1994 closed 2 years ago

enric1994 commented 2 years ago

I generated my API key but I get this 403 error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/riotwatcher/Handlers/ThrowOnErrorHandler.py", line 18, in after_request
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://euw1.api.riotgames.com/tft/summoner/v1/summoners/by-name/hking0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/enric/Downloads/lol.py", line 22, in <module>
    me = lol_watcher.summoner.by_name(my_region, 'hking0')
  File "/usr/local/lib/python3.9/site-packages/riotwatcher/_apis/team_fight_tactics/SummonerApi.py", line 39, in by_name
    return self._request_endpoint(
  File "/usr/local/lib/python3.9/site-packages/riotwatcher/_apis/NamedEndpoint.py", line 35, in _request_endpoint
    return self._base_api.raw_request(
  File "/usr/local/lib/python3.9/site-packages/riotwatcher/_apis/BaseApi.py", line 50, in raw_request
    mod = handler.after_request(
  File "/usr/local/lib/python3.9/site-packages/riotwatcher/Handlers/ThrowOnErrorHandler.py", line 20, in after_request
    raise ApiError(*err.args, request=err.request, response=err.response)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://euw1.api.riotgames.com/tft/summoner/v1/summoners/by-name/hking0

My code looks like this:

from riotwatcher import TftWatcher, ApiError

tft_watcher = TftWatcher('my-api-key')

my_region = 'euw1'

me = tft_watcher.summoner.by_name(my_region, 'hking0')
print(me)

I am sure it's a silly error. Thanks in advance!

PD: It would be nice to have an examples folder with some basic operations.

pseudonym117 commented 2 years ago

replace 'my-api-key' in that code with a real API key from https://developer.riotgames.com/