Path of Exile Wiki:Data query API: Difference between revisions
>OmegaK2 |
>OmegaK2 |
(No difference)
|
Revision as of 18:05, 20 April 2018
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.
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.
Items
All items on the wiki are exposed by Template:Item and are fully powered by semantic media wiki - this means you can query just about any property of an item to create convenient item lists.
Examples
cargoquery
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" } } ] }