@mapbox/wikidata-changes-stream

Represent wikidata changes API as a node stream

Usage no npm install needed!

<script type="module">
  import mapboxWikidataChangesStream from 'https://cdn.skypack.dev/@mapbox/wikidata-changes-stream';
</script>

README

wikidata-changes-stream

Create node streams of change event objects from Wikidata's RecentChanges API.

createChangeStream()

Create a stream of change event objects from Wikidata.

createEntityStream()

Transform stream that requests full entities from change event objects.

Example

Stream the last 60 seconds of changes from Wikidata.

var wcs = require('wikidata-changes-stream');

var changes = wcs.createChangeStream({
    start: (+new Date)/1000 - 60,
    end: (+new Date)/1000
});

changes
    .pipe(wcs.createEntityStream())
    .on('data', function(obj) {
        console.log(JSON.stringify(obj));
    })
    .on('error', function(err) {
        console.error(err);
    });