Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the Wikipedia API support searches for a specific template?

Is it possible to query the Wikipedia API for articles that contain a specific template? The documentation does not describe any action that would filter search results to pages that contain a template. Specifically, I am after pages that contain Template:Persondata. After that, I am hoping to be able to retrieve just that specific template in order to populate genealogy data for the openancestry.org project.

The query below shows that the Albert Einstein page contains the Persondata Template, but it doesn't return the contents of the template, and I don't know how to get a list of page titles that contain the template. http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=Albert%20Einstein&tlcontinue=736|10|ParmPart

Returns:

<api>
 <query>
  <pages>
   <page pageid="736" ns="0" title="Albert Einstein">
    <templates>
     ...
     <tl ns="10" title="Template:Persondata"/>
     ...
    </templates>
   </page>
  </pages>
 </query>
 <query-continue>
  <templates tlcontinue="736|10|Reflist"/>
 </query-continue>
</api>

I suspect that I can't get what I need from the API, but I'm hoping I'm wrong and that someone has already blazed a trail down this path.

like image 885
grenade Avatar asked Oct 28 '10 12:10

grenade


People also ask

How does Wikipedia API work?

Your program sends requests to the API to get access to wiki features. For example, log in to a wiki, create and edit a page, search for a title, search for content text, or parse content. The Action API is available for third-party developers, Wikimedia extension developers, and wiki site administrators.

Is there an API for Wikipedia?

What is the Wikipedia API? The Wikipedia API (official documentation) is supported by the MediaWiki's API and provide access to Wikipedia and other MediaWiki data without interacting with the user interface.

What does Wikipedia use for search?

Wikipedia uses a powerful search engine, with a search box on every page. The search box will navigate directly to a given page name upon an exact match. But, you can force it to show you other pages that include your search string by including a tilde character ~ anywhere in the query.

How do you find someone on Wikipedia?

On the left-hand side of your screen there is a search box with two buttons under it labeled "Go" and "Search". Put your keyword in the searchbox. Go - (or Enter on keyboard) will take you to the article, if it exists. Search - will search the text of all pages on the wiki (with some restrictions, see below).


1 Answers

The accepted answer explains how to list pages using a certain template, but if you need to search for pages using the template, you can with the hastemplate: search keyword: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=hastemplate:NPOV%20physics

like image 152
Tgr Avatar answered Oct 18 '22 15:10

Tgr