MediaWiki API client written in node.js
- nodejs
npm install nodemw
Or Download the latest stable version via GitHub.
git clone https://github.com/macbre/nodemw.git
- HTTP requests are stored in queue and performed in serial, there's no risk of flooding the server
- nodemw core uses promise pattern powered by deffered-js library
- nodemw supports articles creation / edit / move / delete, file uploads (using given content or via provided URL)
- 5000 edits on Poznań Wiki as Pyrabot - scripts repository
An example script can be found in /examples
directory.
cd examples
node pagesInCategory.js
The last parameter of each function in nodemw API is a callback which will be fired when the requested action is done.
var bot = require('./lib/bot').bot;
// pass configuration object
var client = new bot({
server: 'en.wikipedia.org', // host name of MediaWiki-powered site
path: '/w', // path to api.php script
debug: false // is more verbose when set to true
});
client.getArticle('foo', function(data) {
// ...
});
nodemw can use config files as well as objects directly provided to bot
object constructor.
// read config from external file
var client = new bot('config.js');
Config file is a JSON-encoded object with the following fields (see /examples/config-DIST.js
file):
{
server: 'en.wikipedia.org', // host name of MediaWiki-powered site
path: '/w', // path to api.php script
debug: false, // is more verbose when set to true
username: 'foo', // account to be used when logIn is called (optional)
password: 'bar' // password to be used when logIn is called (optional)
}
Log-in using given credentials - read more
Gets the list of all categories on a wiki
Gets the list of pages in a given category - read more
Gets the list of pages by a given prefix - read more
Gets article content and its meta data - read more
Creates / edits an article - read more
Deletes an article - read more
Returns token required for a number of MediaWiki API operations
Gets information about current bot's user (including rights and rate limits) - read more
Moves (aka renames) given article - read more
Gets list of all images on a wiki
Gets list of all articles using given image
Get list of all images that are used on a given page - read more
Gets metadata (including uploader, size, dimensions and EXIF data) of given image
Returns XML with preprocessed wikitext - read more
Makes a GET request to provided resource and returns its content.
Returns entries from recent changes (starting from a given point)
Returns entries from recent changes (starting from a given point)
Uploads a given raw content as a File:[filename] - read more
Uploads a given external resource as a File:[filename]
Gets a value of a given template parameter from article's preparsed content (see expandTemplates)
Gets all external links used in article
- Use promise pattern instead of callbacks.
- Log to a file.
- Set proper User Agent.
- Basic wikitext parsing and modifications (reading/replacing/adding template parameters)
- --File uploads--