https://github.com/nyurik/mwapi
MediaWiki tiny core API wrapper
https://github.com/nyurik/mwapi
Last synced: 18 days ago
JSON representation
MediaWiki tiny core API wrapper
- Host: GitHub
- URL: https://github.com/nyurik/mwapi
- Owner: nyurik
- Created: 2016-04-13T18:58:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T22:34:38.000Z (over 6 years ago)
- Last Synced: 2025-04-07T21:48:46.177Z (22 days ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MediaWiki bare minimum promise-based API library
This library, initially written by the original developer of MediaWiki API,
is a minimalistic set of functions to help access Wikipedia and other MW sites.Thi library does not try to wrap any of the MediaWiki's APIs with functions.
Instead, it handles errors, warnings, continuations, basic datatypes, without
hiding any MW API with extra functions. Other libraries may choose to use
this library as the base, and build richer interface.Eventually the goal is to make this library equaly usable from NodeJS and browser.
# NodeJS
```
var MWApi = require('mwapi'),
mwapi = new MWApi(
'Name of my program (email@ and wikiUser)',
'https://en.wikipedia.org/w/api.php'),mwapi.iterate({
// Execute 'query' call to MW API
action: 'query',
prop: 'revisions',
titles: ['API', 'Main%20Page'],
rvprop: 'content'
}, (response) => {
// Callback function to handle each result from the API
// process response object
// return either boolean or a promise of a boolean
// if true, continue iterating, false to stop
}).then(() => {
// done with the API call
}, (err) => {
// an error occurred during API call
});
```