Skip to main content

Library that interfaces with the Guild Wars 2 API that supports v1 and v2

Project description

Guild Wars 2 Banner

GuildWars2 API Client

Build Status

Library that interfaces with the Guild Wars 2 API that supports v1 and v2 - https://wiki.guildwars2.com/wiki/API:Main

Table of Contents

Prerequisites

  • Python v3.4 or higher

Installation

See PyPi package here:

pip install GuildWars2-API-Client
pip install git+https://github.com/JuxhinDB/gw2-api-interface.git#egg=gw2api

Usage

Basic Usage

Initializing a default client is simple. The following default values will be automatically set for you:

Thus you can create a basic client like so:

from gw2api import GuildWars2Client

gw2_client = GuildWars2Client()

The format for accessing an object will always be {client}.{object}.get(). For example:

gw2_client.build.get()
81583

Advanced Usage

API Objects

The client will automatically expose all the API objects available depending on the API version. This can be done by calling the dir() method on the client object, like so:

gw2_client = GuildWars2Client(version='v1')
dir(gw2_client)
['BASE_URL', 'LANG', 'VERSION',
'api_key', 'base_url', 'build', 'colors', 'continents', 'eventdetails',
'files', 'guilddetails', 'itemdetails', 'items', 'lang', 'mapfloor',
'mapnames', 'maps', 'proxy', 'recipedetails', 'recipes', 'session',
'skindetails', 'skins', 'verify_ssl', 'version', 'worldnames',
'wvwmatchdetails', 'wvwmatches', 'wvwobjectivenames']

All redundant protocol-methods (i.e. __repr__) were removed from the output, you can ofcourse see the full output when running this in your project.

Client Settings

To examine the client settings at any given point, simply print the object.

from gw2api import GuildWars2Client
gw2_client = GuildWars2Client()

gw2_client
<GuildWars2Client https://api.guildwars2.com
Version: v2
API Key: None
Language: en
Proxy: None
Verify SSL?: True>

Proxy and SSL

If at any given point you need to pass API requests through proxy (e.g. Fiddler) you can configure the client to pass all request through said proxy during client initialization.

from gw2api import GuildWars2Client
gw2_client = GuildWars2Client(proxy={'http': '127.0.0.1:8888', 'https': '127.0.0.1:8888'}, version='v1'})

Additionally if you’re passing through a local proxy, you may need to set SSL verification to false like so:

from gw2api import GuildWars2Client
gw2_client = GuildWars2Client(proxy={'http': '127.0.0.1:8888', 'https': '127.0.0.1:8888'}, version='v1', verify_ssl=False)

Authenticated Endpoints

There may be cases where certain endpoints such as Accounts or Guild related endpoints may require authentication. This is generally configured on initialization of the client, like so:

client = GuildWars2Client(api_key='API_KEY_VALUE_HERE')

If you want to generate your own API key, please refer to the following link.

Cursors and Limits

Currently unimplemented. If you require cursors & limits, a PR is greatly appreciated. I will be able to mentor you on the implementation if/when needed.

Examples

Below are a few examples and one-liners that may help when testing or debugging the project:

Using Fiddler:

from gw2api import GuildWars2Client
client = GuildWars2Client(proxy={'http': '127.0.0.1:8888', 'https': '127.0.0.1:8888'}, verify_ssl=False, api_key='API_KEY')

APIv2 Searching for Guild

client.guildsearch.get(name='Mythical Realms')
0CB3B1A7-4C70-E611-80D3-E4115BE8BBE8

APIv2 Retrieving guild members

client.guildidmembers.get('0CB3B1A7-4C70-E611-80D3-E4115BE8BBE8')
{"text": "access restricted to guild leaders"}  # :-(

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guildwars2_api_client-0.7.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

GuildWars2_API_Client-0.7.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file guildwars2_api_client-0.7.0.tar.gz.

File metadata

File hashes

Hashes for guildwars2_api_client-0.7.0.tar.gz
Algorithm Hash digest
SHA256 7b3f8044a5717fcf42fb9c683b1bf845a353746bd019c520586d99f5ecf1abf4
MD5 85bc7a474b7f38d812c97e47b0bbbd87
BLAKE2b-256 493adc1bb6c1ce4960c4c7c150ea0bd415504ae7067c394d2fcf723772e11b2a

See more details on using hashes here.

File details

Details for the file GuildWars2_API_Client-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for GuildWars2_API_Client-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1671dca0119a073a87b8c56538978585a8ef0d50f5d4117b3d5060ba87676900
MD5 7fa200f78ef7095784013b9068ad959a
BLAKE2b-256 d4882ee3b2fbee2200fc3d72599feafc5780e97d740933ff9bb278e198460829

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page