Difference between revisions of "PCGamingWiki:API"
From PCGamingWiki, the wiki about fixing PC games
m (updated page and included mention of MediaWiki API) |
m (updated API examples) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | ==API== | ||
''This page might not be updated to reflect all available API endpoints or functionality.'' | ''This page might not be updated to reflect all available API endpoints or functionality.'' | ||
+ | |||
===MediaWiki API=== | ===MediaWiki API=== | ||
− | {{ii}} As the PCGamingWiki is based on MediaWiki, the built-in [https://www.mediawiki.org/wiki/API:Main_page MediaWiki API] can be used to access a lot of data. MediaWiki extensions we use | + | {{ii}} As the PCGamingWiki is based on MediaWiki, the built-in [https://www.mediawiki.org/wiki/API:Main_page MediaWiki API] endpoint can be used to access a lot of data. Some MediaWiki extensions we use such as [https://www.semantic-mediawiki.org/wiki/Help:API Semantic MediaWiki] and [https://www.mediawiki.org/wiki/Extension:Cargo/Exporting_data#API Cargo] also exposes their own API actions through the MediaWiki API. |
− | + | {{++}} If you want to retrieve the Semanic MediaWiki properties (e.g. cover image, developer, publisher, release date, etc) of a page, the {{Code|browsebysubject}} API action is currently the most relevant one if you know the page name. See [https://www.pcgamingwiki.com/w/api.php?action=browsebysubject&format=json&subject=NieR%3A%20Automata this example] ([https://www.pcgamingwiki.com/wiki/Special:ApiSandbox#action=browsebysubject&format=json&subject=NieR%3A%20Automata sandbox]). | |
− | {{++}} If you want to retrieve the Semanic MediaWiki properties (e.g. cover image, developer, publisher, release date, etc) of a page, the {{Code|browsebysubject}} API action is currently the most relevant one if you know the page name. See [https://www.pcgamingwiki.com/w/api.php?action=browsebysubject&format=json&subject=NieR%3A%20Automata this example] ([https://www.pcgamingwiki.com/wiki/Special:ApiSandbox#action=browsebysubject&format=json&subject=NieR%3A%20Automata sandbox]) | + | {{mm}} The '''[[Special:ApiSandbox|API Sandbox]]''' can be helpful in figuring the API out. |
+ | |||
+ | |||
+ | '''Examples:''' | ||
+ | {{ii}} '''Find PCGW page(s) using the SMW property [[Property:Steam AppID|Steam AppID]]:''' {{Pre|1=https://www.pcgamingwiki.com/w/api.php?action=askargs&conditions=Steam_AppID::863550&format=jsonfm}} | ||
+ | |||
+ | {{ii}} '''Retrieve all populated SMW properties for a single page:''' {{Pre|1=https://www.pcgamingwiki.com/w/api.php?action=browsebysubject&subject=Hitman_2&format=jsonfm}} | ||
+ | :* ''<code>Hitman_2</code>'' was retrieved using the previous example query.'' | ||
+ | :* ''<code>#0#</code> at the end of the <code>subject</code> key represents the MediaWiki namespace the page resides under, see [https://www.pcgamingwiki.com/w/api.php?action=query&meta=siteinfo&siprop=namespaces the siteinfo API action] for the details. <code>#0#</code> refers to the main namespace of the site.'' | ||
+ | |||
+ | {{ii}} '''Retrieve specific populated SMW properties for a single page retrieved using the the SMW property [[Property:Steam AppID|Steam AppID]]:''' {{Pre|1=https://www.pcgamingwiki.com/w/api.php?action=askargs&conditions=Steam+AppID::863550&printouts=4K_Ultra_HD{{!}}Ultra-widescreen{{!}}Published_by&format=jsonfm}} | ||
+ | :* ''This example retrieves the [[Property:4K Ultra HD|4K Ultra HD]], [[Property:Ultra-widescreen|Ultra-widescreen]], and [[Property:Published by|Published by]] SMW properties. | ||
+ | :* ''<code>%7C</code> is an URL encoded <code>|</code> that is used to separate multiple specified properties to retrieve.'' | ||
+ | |||
===Redirect API=== | ===Redirect API=== | ||
− | {{ii}} Our custom redirect API allows us to redirect incoming users using any Steam ID to the relevant PCGamingWiki page. | + | {{ii}} Our custom redirect API allows us to redirect incoming users using any registered GOG ID, Steam App ID, or WineHQ ID to the relevant PCGamingWiki page. |
{{mm}} [https://github.com/PCGamingWiki/api Source code] | {{mm}} [https://github.com/PCGamingWiki/api Source code] | ||
− | |||
+ | '''Examples:''' | ||
+ | {{ii}} '''GOG ID:''' {{Pre|1=https://www.pcgamingwiki.com/api/gog.php?page=1785384169}} | ||
+ | |||
+ | {{ii}} '''Steam App ID:''' {{Pre|1=https://www.pcgamingwiki.com/api/appid.php?appid=674020}} | ||
+ | |||
+ | {{ii}} '''WineHQ:''' {{Pre|1=https://www.pcgamingwiki.com/api/winehq.php?appid=15482}} | ||
+ | |||
+ | __NOTOC__ __NOEDITSECTION__ [[Category:PCGamingWiki]] | ||
− | + | |
Revision as of 20:30, 11 November 2020
API
This page might not be updated to reflect all available API endpoints or functionality.
MediaWiki API
- As the PCGamingWiki is based on MediaWiki, the built-in MediaWiki API endpoint can be used to access a lot of data. Some MediaWiki extensions we use such as Semantic MediaWiki and Cargo also exposes their own API actions through the MediaWiki API.
- If you want to retrieve the Semanic MediaWiki properties (e.g. cover image, developer, publisher, release date, etc) of a page, the
browsebysubject
API action is currently the most relevant one if you know the page name. See this example (sandbox). - The API Sandbox can be helpful in figuring the API out.
Examples:
- Find PCGW page(s) using the SMW property Steam AppID:
https://www.pcgamingwiki.com/w/api.php?action=askargs&conditions=Steam_AppID::863550&format=jsonfm
- Retrieve all populated SMW properties for a single page:
https://www.pcgamingwiki.com/w/api.php?action=browsebysubject&subject=Hitman_2&format=jsonfm
Hitman_2
was retrieved using the previous example query.#0#
at the end of thesubject
key represents the MediaWiki namespace the page resides under, see the siteinfo API action for the details.#0#
refers to the main namespace of the site.
- Retrieve specific populated SMW properties for a single page retrieved using the the SMW property Steam AppID:
https://www.pcgamingwiki.com/w/api.php?action=askargs&conditions=Steam+AppID::863550&printouts=4K_Ultra_HD%7CUltra-widescreen%7CPublished_by&format=jsonfm
- This example retrieves the 4K Ultra HD, Ultra-widescreen, and Published by SMW properties.
%7C
is an URL encoded|
that is used to separate multiple specified properties to retrieve.
Redirect API
- Our custom redirect API allows us to redirect incoming users using any registered GOG ID, Steam App ID, or WineHQ ID to the relevant PCGamingWiki page.
- Source code
Examples:
- Steam App ID:
https://www.pcgamingwiki.com/api/appid.php?appid=674020