wrapper and utils for League of Legends API
It is python wrapper for League of Legends api that watch out to not exceed rate limit.
Tested on python 3.5
Full api documentation: link
Package is available on PyPI so just use:
pip install lol_api
or to install from source:
git clone https://github.com/gradam/lol_api.git
python setup.py test
python setup.py install
First you need to set up few thing. To do so import settings.
from lol_api.settings import settings settings.API_KEY = 'your_api_key' # If you do not wont to pass region to each api call just do: settings.REGION_DEFAULT = 'some_region' # Now if you are going to use watcher daemon you have to pass server info: settings.DAEMON_SERVER = ('server_ip', port) # If you prefer to use local watcher instance settings.initialize_watcher()
from lol_api.settings import settings from lol_api.api.champion import champion settings.API_KEY = 'mysecretapikey123' settings.REGION_DEFAULT = 'eune' settings.initialie_watcher(production=True) data = champion(champion_id=2)
To use Daemon for watching request count run him in another python instance.
from lol_api.daemon import ApiDaemon daemon = ApiDaemon() daemon.run()
To specify the region pass region='your_region' as the argument to method, if not specified region_default passed to Client will be used.
If lol api accept optional arguments, it should be pass as a keyword named exactly as expected by api. eg.
Wrapper automatically watch to not exceed requests rate limit per region. Default value is 10 per 10 seconds and 500 per 10 minutes. This is default limit for non production keys. Id order to use production limit ( 3000 per 10 seconds and 180000 per 10 minutes ) set PRODUCTION to True in settings.
lol_api.settings.settings.PRODUCTION = True
You can also turn this off by setting UNLIMITED=True.
If Rate limit is exceeded “lol_api.exceptions.RateLimitExceededError“ will be raised.
Requirements for tests are in tests_requirements.txt file.
To run tests:
pip install -r tests_requirements.txt
python setup.py test