Talking to wikipedia

With Js



How do you access wikipedia programatically ?

Mediawiki Api

http://en.wikipedia.org/w/api.php
(List of all the available options)

https://www.mediawiki.org/wiki/API:Client_code
(List of client libraries in various languages)





Who doesn't use a browser !

Lets use javascript to talk to the API 


Have you guys written js before ?


Heard of events & callbacks ?

Lets play with the API


Without writing any code yet :-)

https://www.mediawiki.org/wiki/Special:ApiSandbox

Lets pick a task


  • The authors of the first 100 edits in an article 
  • Read the edit comments in an article
  • The list of images used in an article






I'm sure you guys have better ideas :-)

Userscripts


Userscripts are available directly in a wikipedia page.
They can do a lot of nifty things for you.

List of available userscripts



A tool I built with the API


Code
  Demo




thank you


Events


Events Mozilla Docs
jQuery Events

Examples

Callbacks


Functions are objects in javascript.
They can be passed to other functions like variables.

Examples

Ajax


Ajax is Asynchronous Javascript & XML.
The callbacks don't get executed right away.

Example

Callback Nesting


jQuery when() , then() & done() 
Example
Made with Slides.com