官方guild wars 2 json api的简单包装。
gw2apiwrapper的Python项目详细描述
GW2APIWRAPPER是一个Python库,旨在通过Python抽象出与官方激战2(GW2)API交互的开销和复杂性。
这个库的目的是使编写和阅读python应用程序和工具变得简单,只需对gw2 api本身了解很少。
这是通过抽象出常用的标准json->;字典映射方案并用oop风格(例如item.name)表示法替换它来实现的。
安装
只需使用pip/pipenv安装,您就可以开始了:
pip install gw2apiwrapper
示例
fromgw2apiwrapperimportAccountAPI,GlobalAPI# Get an account based object. Requires API Key.personal=AccountAPI("<APIKEY>")# Get a 'Global' api object. (Non-authed)workHorse=GlobalAPI()# This is iterable, as not only does it fill the personal.bank# attribute, it also returns that information allowing it to be# used in loops..even though we don't here.personal.getBank()# Should be self documenting, but demonstrates that the previous# getBank() call actually populated that object's 'bank' attribute.bankIDs=[slot['id']forslotinpersonal.bankifslotisnotNone]# GlobalAPI's getItem can take different types, all documented.itemObjects=workHorse.getItem(bankIDs)# Get the names of all items in bank.foriteminitemObjects:print(item.name)
注释
这个项目正在半主动开发中。这项工作已经打下了基础,而且大部分api都已被考虑在内。如果您需要的东西丢失了,并且您希望它被添加,请随时打开问题(或拉取请求!)在Github上。