Wikipedia recently introduced a new auto-complete search feature that offers keyword suggestions in real-time as you type the characters in the Wikipedia search box.
For instance, if you type "GOO", the drop down will show titles of all Wikipedia entries that begin with the word "GOO" (see screenshot).
This Google Suggest like feature is actually built on an undocumented but public Wikipedia API that can easily be used to retrieve useful information from the Wikipedia database. To demonstrate the use of Wikipedia API, here is a simple Wikipedia spell checker app:
The above spell checker fires an Wikipedia API query to see if Wikipedia has an entry about the word you just entered in the search box and says "Correct" if it finds one.
For the geeks, here’s the actual source code:
var url = ‘http://en.wikipedia.org/w/api.php?action=opensearch&search=value&format=json&callback=spellcheck‘;
var elem = document.createElement (‘script’);
elem.setAttribute (‘src’, url);
document.getElementsByTagName (‘head’) .appendChild (elem);
A related example – if you want to know about Wikipedia articles that begin with the term "India", just the following URL in your web browser:
The above Wikipedia URL would return the following set of words:
["india",["India","INDIA","India (album)","India (cat)","India (disambiguation)","India (name)","India (porn star)","India (region)","India (singer)","India (subcontinent)"]]
So what else could one do with the Wikipedia API ? Here are some more uses:
1. A WordPress plugin which auto links terms to Wikipedia articles.
3. A Firefox extension which allows single click querying of terms.
The Wikipedia API was dissected by Pratham who maintains a very interesting tumbleblog at pratham.name and tweets here. Note that this not an official API (Wikipedia is not talking about this yet), therefore use on a production system is not advised.