Path of Exile Wiki:Data query API

From Path of Exile Wiki
Jump to navigation Jump to search

This page contains development information and is intended for developers and not regular end users.

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.

Cargo is a type of database used to store interesting values in various items, mods, versions etc. as rows in cargo tables. The stored values can then be used to execute powerful queries and retrieve fields from cargo tables. The syntax is similar to MySQL or SQL because it uses MySQL at its core.

The API documentation for querying Cargo tables can be found here.

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 than scraping the wiki pages and will significantly reduce the overhead on both your script and the wiki server.

When using tables, it's advisable to check the related module or template documentation. 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. Queries can also be made from the CargoQuery 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://www.poewiki.net/w/api.php?action=cargoquery&tables=items&fields=name&where=rarity=%22Unique%22%20AND%20class=%22Dagger%22&limit=5&group_by=name

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

Breakdown:

Querystring Description SQL equivalent in query
https://www.poewiki.net/w/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`

You can search for containment using searches where=name LIKE string.

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"
            }
        }
    ]
}

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.

For example getting the skill levels and experience for Blood RageBlood RageSpell, Duration, Physical
Level: (1-20)
Cost: (12-29) Life
Cooldown Time: 1.00 sec
Can Store 1 Use(s)
Cast Time: Instant
Requires Level 16Adds a buff that deals Physical Damage over time, while increasing Attack Speed and Life Leech. Killing an enemy while this buff is active refreshes the buff duration, and can grant a Frenzy Charge.Base duration is (7.00-10.80) seconds
Grants (5-15)% increased Attack Speed
1.2% of Attack Physical Damage Leeched as Life
You take 4% of your Maximum Life per second as Physical Damage
You take 4% of your Maximum Energy Shield per second as Physical Damage
25% chance to gain a Frenzy Charge on Kill

Additional Effects From 1-20% Quality:
Grants (0.25-5)% increased Attack Speed
Place into an item socket of the right colour to gain this skill. Right click to remove from a socket.
:

name level experience
Blood Rage 0
Blood Rage 1 0
Blood Rage 2 49,725
Blood Rage 3 145,439
Blood Rage 4 315,034

More...

Can be done through the API like this:

https://www.poewiki.net/w/api.php?action=cargoquery&tables=items,skill_levels&join_on=items._pageID=skill_levels._pageID&fields=items.name,skill_levels.level,skill_levels.experience&where=items.name=%22Blood%20Rage%22&order_by=skill_levels.level&limit=5

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

Offset a limited query

If you have a query that yields more results than the query limit it is possible to offset the results by using the offset parameter.

For example getting the next 5 skill levels and experience for Blood RageBlood RageSpell, Duration, Physical
Level: (1-20)
Cost: (12-29) Life
Cooldown Time: 1.00 sec
Can Store 1 Use(s)
Cast Time: Instant
Requires Level 16Adds a buff that deals Physical Damage over time, while increasing Attack Speed and Life Leech. Killing an enemy while this buff is active refreshes the buff duration, and can grant a Frenzy Charge.Base duration is (7.00-10.80) seconds
Grants (5-15)% increased Attack Speed
1.2% of Attack Physical Damage Leeched as Life
You take 4% of your Maximum Life per second as Physical Damage
You take 4% of your Maximum Energy Shield per second as Physical Damage
25% chance to gain a Frenzy Charge on Kill

Additional Effects From 1-20% Quality:
Grants (0.25-5)% increased Attack Speed
Place into an item socket of the right colour to gain this skill. Right click to remove from a socket.
:

name level experience
Blood Rage 5 514,379
Blood Rage 6 800,194
Blood Rage 7 1,201,538
Blood Rage 8 1,755,917
Blood Rage 9 2,510,966

More...

Can be done through the API like this:

https://www.poewiki.net/w/api.php?action=cargoquery&tables=items,skill_levels&join_on=items._pageID=skill_levels._pageID&fields=items.name,skill_levels.level,skill_levels.experience&where=items.name=%22Blood%20Rage%22&order_by=skill_levels.level&limit=5&offset=5

Grouping by field

The results can be grouped up with respect to the field. Continuing the Blood RageBlood RageSpell, Duration, Physical
Level: (1-20)
Cost: (12-29) Life
Cooldown Time: 1.00 sec
Can Store 1 Use(s)
Cast Time: Instant
Requires Level 16Adds a buff that deals Physical Damage over time, while increasing Attack Speed and Life Leech. Killing an enemy while this buff is active refreshes the buff duration, and can grant a Frenzy Charge.Base duration is (7.00-10.80) seconds
Grants (5-15)% increased Attack Speed
1.2% of Attack Physical Damage Leeched as Life
You take 4% of your Maximum Life per second as Physical Damage
You take 4% of your Maximum Energy Shield per second as Physical Damage
25% chance to gain a Frenzy Charge on Kill

Additional Effects From 1-20% Quality:
Grants (0.25-5)% increased Attack Speed
Place into an item socket of the right colour to gain this skill. Right click to remove from a socket.
example

name level) experience)
Blood Rage 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,0 0,49725,145439,315034,514379,800194,1201538,1755917,2510966,3527499,5426101,7390120,9963851,14640290,17657617,25480618,40744826,67017671,129889945,341913067

Can be done through the API like this:

https://www.poewiki.net/w/api.php?action=cargoquery&tables=items,skill_levels&join_on=items._pageID=skill_levels._pageID&fields=items.name,GROUP_CONCAT(skill_levels.level),GROUP_CONCAT(skill_levels.experience)&where=items.name=%22Blood%20Rage%22&order_by=level

Known issues

When selecting one or more fields that begin with an underscore, the request may return an error. To get around this issue, specify an alias for each field that begins with an underscore.

https://www.poewiki.net/w/api.php?action=cargoquery&tables=items&fields=items.name,items._ID=ID&where=items.rarity=%22Unique%22 ru:Path of Exile Wiki:Data query API