Digital Inspiration

about    faq    contact

Using the Wikipedia API - Live Demo with Source Code

wikipedia api

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);
elem.setAttribute (’type’,'text/javascript’);
document.getElementsByTagName (’head’) [0].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:

http://en.wikipedia.org/w/api.php?action=opensearch&search=india

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.

2. A "better" Wikipedia search which hooks up Google "Did you mean" with the Wikipedia API, so that misspellings also direct to the correct article.

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.

Related: Track Changes To Your Favorite Wikipedia Articles

Email This   Print Article   Save as PDF   Subscribe   Translate 

Published on April 28, 2008 under Internet, Tools
Tags: , , , , , ,

Recommended Google Software:

You may also like to read ..

 · The Logo Designs of YouTube and Airtel - Separated at Birth?
 · Wikipedia - We do not expect you to trust us.
 · All TechMeme Source Code in One File
 · Can You Cite an Off The Record Conversation
 · What is a Pastebin ?

Add a Comment

If you have a question that is not related to the above discussion, please post your question in the message board for quick answers. All comments are moderated.



 

Joing the Facebook Group

Visit Help Central

 

© 2008 Digital Inspiration - Technology, à la Carte | Mobile Edition | Videos | Terms

The articles are copyrighted to Amit Agarwal and can only be reproduced given the author's permission.

My Google  Netvibes  My Yahoo!  Windows Live  Bloglines  Newsgator  

Skip to top of the page ^^