Guild Wars 2

Guild Wars 2

Games & Comics

The Guild Wars 2 API (application programming interface) is an interface that enables third-party applications to access data directly from the Guild Wars 2 servers.

Visit API🔁 Alternatives

📚 Documentation & Examples

Everything you need to integrate with Guild Wars 2

🚀 Quick Start Examples

Guild Wars 2 Javascript Examplejavascript
// Guild Wars 2 API Example
const response = await fetch('https://wiki.guildwars2.com/wiki/API:Main', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring the Guild Wars 2 API with JavaScript

The Guild Wars 2 API is a public API that allows developers to access information about the game and its playerbase. With the help of JavaScript, we can make API requests and parse the JSON data that is returned.

Getting Started

To begin using the API, we will need to create an API key. This can be done on the Guild Wars 2 account management page. Once we have our API key, we can begin making requests.

To make our requests in JavaScript, we will be using the Fetch API. This is a modern replacement for XMLHttpRequest and allows us to make HTTP requests in a much simpler and cleaner way.

Example Requests

Here are some example requests using the Guild Wars 2 API and JavaScript:

Retrieve account information

const apiKey = '<your-api-key>';
fetch(`https://api.guildwars2.com/v2/account?access_token=${apiKey}`)
  .then(response => response.json())
  .then(data => console.log(data));

This request will return information about the account associated with the provided API key.

Retrieve character information

const apiKey = '<your-api-key>';
const characterName = 'Character Name';
fetch(`https://api.guildwars2.com/v2/characters/${encodeURIComponent(characterName)}?access_token=${apiKey}`)
  .then(response => response.json())
  .then(data => console.log(data));

This request will return information about the specified character. Be sure to URL encode the character name in the request URL.

Retrieve item information

const itemId = 12345;
fetch(`https://api.guildwars2.com/v2/items/${itemId}`)
  .then(response => response.json())
  .then(data => console.log(data));

This request will return information about the item with the specified ID.

Retrieve achievement information

const achievementId = 12345;
fetch(`https://api.guildwars2.com/v2/achievements/${achievementId}`)
  .then(response => response.json())
  .then(data => console.log(data));

This request will return information about the achievement with the specified ID.

Conclusion

The Guild Wars 2 API is a powerful tool for developers looking to build applications and tools around the game. With the help of JavaScript and the Fetch API, we can easily make API requests and retrieve data. Happy coding!

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Aug 20Aug 22Aug 24Aug 26Aug 28Aug 30Sep 1Sep 3Sep 5Sep 7Sep 9Sep 11Sep 13Sep 15Sep 1804008001440Minutes
Online
Offline

Related APIs in Games & Comics