Skip to main content
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"}  # :-(

Metadata

Release files for GuildWars2-API-Client 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GuildWars2-API-Client 0.8.0
File Size Uploaded Provenance
guildwars2_api_client-0.8.0.tar.gz 18.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for GuildWars2-API-Client 0.8.0
File Interpreter ABI Platform
guildwars2_api_client-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.7 kB

Release files / guildwars2_api_client-0.8.0.tar.gz

Download URL guildwars2_api_client-0.8.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c22c3bfdb6148cd2872cacec194108a63942ff4caa23eb1f59e9dffcfc04aa4c
BLAKE2b-256 checksum
How to use checksums
6e23a8f0da8ad446aab90b3b792736d260b0d97810631aa960f63abca9c1798d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Release files / guildwars2_api_client-0.8.0-py3-none-any.whl

Download URL guildwars2_api_client-0.8.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30f55386b6f0691b843344a48bf09202eec462431234a59021aa17e56d5ccee1
BLAKE2b-256 checksum
How to use checksums
eb1dd6dfed32eba8d076737914e8aaf5d20a4283cfb3d15c08f33b24bfbaef5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Security for GuildWars2-API-Client 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page