为传奇联盟撰写与使用
lol-api的Python项目详细描述
它是传奇联盟api的python包装器,注意不要 超过速率限制。
在python 3.5上测试
完整的API文档:
link PYPI上提供软件包,请使用: pip install lol_api 或从源安装: git clone https://github.com/gradam/lol_api.git python setup.py test python setup.py install 首先你需要设置一些东西。为此,请导入设置。 要使用守护进程监视请求计数,请在另一个python实例中运行它。 其他参数: 指定区域传递region='your_region'作为
方法,如果未指定region_default,则传递给客户端的
使用。 如果lol api接受可选参数,则应将其作为关键字传递
完全按照api的预期命名。例如 包装器自动监视不超过每个区域的请求速率限制。
默认值为10/10秒和500/10分钟。这是
的默认limit
非生产密钥。使用生产限制的ID命令(每10个3000个
秒,每10分钟180000次)在“设置”中将“生产”设置为“真”。 您也可以通过设置UNLIMITED=True来关闭此功能。 如果超过速率限制
`` lol_api.exceptions.ratelimiteexcederror``将被引发。 测试要求见tests_requirements.txt文件。 运行测试: pip install -r tests_requirements.txt py.test 或运行: python setup.py test安装:
用法:
fromlol_api.settingsimportsettingssettings.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 instancesettings.initialize_watcher()
示例:
fromlol_api.settingsimportsettingsfromlol_api.api.championimportchampionsettings.API_KEY='mysecretapikey123'settings.REGION_DEFAULT='eune'settings.initialie_watcher(production=True)data=champion(champion_id=2)
守护进程:
fromlol_api.daemonimportApiDaemondaemon=ApiDaemon()daemon.run()
额外参数:
lol_api.api.lol_static_data.champion(champData='all')
附加数据:
lol_api.data
速率限制:
lol_api.settings.settings.PRODUCTION=True
运行测试
待办事项:
推荐PyPI第三方库