Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1023 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 1023 Bytes

mediawiki-js

Ultra-light, vanilla JavaScript wrapper of Mediawiki API for use in the browser.

Simple one-shot usage:

MediaWikiJS('https://en.wikipedia.org', {action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
    var pages = data.query.pages;
    alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});

Simple reusable usage:

var mwjs = MediaWikiJS('https://en.wikipedia.org');
mwjs.send({action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
    var pages = data.query.pages;
    alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});

Configuration object:

var mwjs = MediaWikiJS({baseURL: 'https://en.wikipedia.org', apiPath: '/w/api.php'});
mwjs.send({action: 'query', prop: 'revisions', titles: 'Main Page'}, function (data) {
    var pages = data.query.pages;
    alert('Last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].user);
});

To-dos

  1. Node support and publish