Consider helping out in updating the wiki for 3.4.0 - see Path_of_Exile_Wiki:To-do_list/3.4.0

Various people have reported issues with the ads on here. Make sure to report those advertisements

Today, 9/16, is the 6th Anniversary of Gamepedia's launch. Join us for an all-day Mega Stream on the Gamepedia Twitch channel! In addition, all users who log in during the anniversary week will receive a special achievement.

Path of Exile Wiki:Data query API

From Path of Exile Wiki
Jump to: navigation, search

Overview

Just like other wikis the Path of Exile wiki can be accessed through the Mediawiki API. This allows for much faster page editing as well as data retrieval.

In addition cargo can be used to execute powerful mediawikiwiki:Extension:Cargo/Querying_data and retrieve fields from cargo tables.

Using the API to retrieve Path of Exile data

If you need certain data such as item or mod data for your tools it is highly advised to use the cargo API to retrieve it. It will be much faster then scraping the wiki pages and reduce the overhead significantly on both your script and the wiki server.

When using tables, it's advisable to check the documentation of the module or template that adds the fields. You can also check CargoTables to see cargo tables or hit "Page values" in the Toolbar to see the currently set cargo values on the page.

Cargo data

Following things are exposed via the cargo API (list may be incomplete, please check CargoTables for the full list)

Examples

cargoquery

https://pathofexile.gamepedia.com/api.php?action=cargoquery&tables=items&fields=name&where=rarity=%22Unique%22%20AND%20class=%22Daggers%22&limit=5&group_by=name

This will return a json list containing the first 5 distinct names of unique items.

Breakdown:

Querystring Description SQL equivalent in query
https://pathofexile.gamepedia.com/api.php Entry point for the API N/A
action=cargoquery Perform a cargo query N/A
tables=items

fields=name

Select name from the table items SELECT `name` FROM `items`
where=rarity=%22Unique%22%20AND%20class=%22Daggers%22 But only where the field rarity is set to the value unique (e.g. only unique items) and where the field class is set to Daggers (e.g. only items whose item class is set to exactly daggers).

Due to the AND only rows are returned where both conditions are true

WHERE `rarity`="Unique" AND `class`="Daggers"
limit=5 Only select up to 5 rows LIMIT 5
group_by=name Group the results by the field name, leaving only one result per distinct value for "name". Essentially, items with the same name (such as the variations of Two-Toned Boots) will only be represented once in the result set GROUP BY `name`

At the time of writing, running this query will return a json like this:

{
    "cargoquery": [
        {
            "title": {
                "name": "Arakaali's Fang"
            }
        },
        {
            "title": {
                "name": "Bino's Kitchen Knife"
            }
        },
        {
            "title": {
                "name": "Bloodplay"
            }
        },
        {
            "title": {
                "name": "Divinarius"
            }
        },
        {
            "title": {
                "name": "Fragment of Eternity"
            }
        }
    ]
}

FAQ

Dealing with multiple tables on the same page

A lot of the wiki is setup with multiple tables that have 1:1 or 1:N relationships. If there isn't any particular key in the table, you generally you want to perform a JOIN query on the two tables, using the hidden row _pageID of both tables.

It's highly advised to check the template documentation about the fields and tables available.