A simple wrapper around the offical Guild Wars 2 JSON API.
Project description
gw2apiwrapper is a Python library designed to abstract away the overhead and complexity of interacting with the official Guild Wars 2 (GW2) API via Python.
The library aims to make it easy to write and read Python applications and tools with only a minimal knowledge of the GW2 API itself.
This is accomplished by abstracting away the standard JSON->dictionary mapping scheme that is so commonly used and replace it with an OOP-style (eg. item.name) notation.
Installation
Simply install with pip/pipenv and you’re good to go:
pip install gw2apiwrapper
Example
from gw2apiwrapper import AccountAPI, 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'] for slot in personal.bank if slot is not None]
# GlobalAPI's getItem can take different types, all documented.
itemObjects = workHorse.getItem(bankIDs)
# Get the names of all items in bank.
for item in itemObjects:
print(item.name)
NOTES
This project is in semi-active development. The groundwork is laid, and most of the API is accounted for. If something you need is missing and you’d like it added feel free to open an issue (or a pull request!) on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gw2apiwrapper-2.7.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5419f89df0d5efa0e08a7513f7b0e7803409e9a0e6ebd3ff94c4b32392ad2c98 |
|
MD5 | 63982e7bc01f505e1e31ab2a52efee9e |
|
BLAKE2b-256 | b7584553ddaaed80d721886c9433e9c62c0a32037372ae9975fcc02001e74cef |