API Tutorial — Learn how to create a Notion Wiki for Guild Wars 2 (part 2)

Getting Started with the Guild Wars 2 API

Devon Fazekas
5 min readDec 22, 2022

Introduction

In this part 2 of our series, we will provide an introduction to the Guild Wars 2 (GW2) API, and explain how to get started with it. Whether you are a fan of the game or a developer interested in creating applications to use with the API, this blog post will provide the necessary background and steps to get started.

If you have not seen part 1 of our series, check it out here:
Part 1 — Understanding APIs, Postman, and Notion for Guild Wars 2 Wiki.

Getting Started with GW2 API

The first step is to find an API that supports Guild Wars 2. A good way to do this is to search for “Guild Wars 2 APIs” on a search engine. The following link is one such API for Guild Wars 2: https://wiki.guildwars2.com/wiki/API:Main. Within this page includes a wealth of documentation on what services their API offers, including instructions on their usage, expected responses, and any limitations. This API specifically offers both general usage and user-based usage which requires authentication. Since we’re creating a general wiki for items and locations within the game (not related to any particular player), we’ll only utilize the general services, hence we won’t require an API key.

Calling the API

The main page of the Guild Wars API documentation lists the available versions of the API. Currently, version-2 is the latest. Viewing its page (https://wiki.guildwars2.com/wiki/API:2), we see that the base URL for all its endpoints starts with https://api.guildwars2.com/v2.

The first API request we’ll try is to retrieve all the items in Guild Wars 2. Navigating through the version-2 of the documentation, you should find a page dedicated to items (https://wiki.guildwars2.com/wiki/API:2/items). Here, we see that the endpoint to request all items is /items. Appending this onto the base URL above, the complete API request looks like this: https://api.guildwars2.com/v2/items.

Paste this API request into the search bar of your browser. As shown below, you’ll receive a JSON data containing a list of numbers which represents the IDs of each item in Guild Wars 2.

Screenshot of item IDs from GW2.
Screenshot of item IDs from GW2.

Voila! You’ve successfully sent your first API request. But you may be correctly wondering how these IDs can help us achieve our original goal of getting information about items.

Thankfully, this API enables us to query for specific items using their IDs. We need to provide additional information via parameters. The documentation states that this endpoint supports a ids query parameter, which takes a comma-separated list of item IDs.

Query parameters are denoted by a question mark (?) followed by the query name, then an equal sign (=). For example, to query for the item represented by ID 4, the URL would be https://api.guildwars2.com/v2/items?ids=4.

The following screenshot shows the JSON response of this request, which includes values such as the item’s name, type, rarity, and so on.

Screenshot of item data from GW2 API.
Screenshot of item data from GW2 API.

Moving forward, we’ll continue to use many APIs between Guild Wars 2 and Notion. To simplify tracking requests and providing necessary parameters, we’ll set up Postman. This will help us categorize and streamline our API requests.

Getting Started with Postman

Once you install Postman, you should see a screen similar to the screenshot below.

We’ll start by creating a new Collection. Collections in Postman are a way to organize and manage your API requests. They’re useful for grouping related requests in one place and for quickly finding and accessing them.

For example, you could create a “Guild Wars 2” Collection to store all the API requests related to the game, and another called “Notion” for storing all APIs requests related to that tool.

Screenshot of Postman.
Screenshot of Postman.

In the “Guild Wars 2” Collection, create two Requests for the two APIs used previously. Name them something intuitive, such as “Get All Item IDs” and “Get Items by IDs”.

Get All Item IDs

For the first request (“Get all item IDs”), paste the URL into the page. Set the request type to “GET” and press [Send]. You should see the same JSON list of numbers as before.

Screenshot of requesting item IDs from Guild Wars 2 in Postman.
Screenshot of requesting item IDs from Guild Wars 2 in Postman.

Get Items by IDs

For the second request (“Get items by ID”), paste the URL like before. This time, you’ll notice in the Query Params section, our query parameter ids and its value 4 are extracted into a row. Press [Send] to return the JSON item info, just like before.

Screenshot of requesting item info from Guild Wars 2 in Postman.
Screenshot of requesting item info from Guild Wars 2 in Postman.

Now that we have successfully communicated with the Guild Wars 2 API server, we can use Notion to create pages based on this data.

Conclusion

Congratulations! 🎉🎊 We have successfully communicated with the Guild Wars 2 API server, allowing us to extract the data we need for our wiki. In the next part of this series we’ll explore how to set up the Notion API. Head over to Part 3 — Getting Started with the Notion API.

--

--

Devon Fazekas

Meet Devon, an entrepreneur who is passionate about helping others live better lives by creating environments that encourage creativity and innovation.