github macbre/nodemw v0.19.0
Initial helpers for WikiData

latest releases: v0.22.0, v0.21.0, v0.20.0...
21 months ago

This release of nodemw brings a few helpers for interacting with Wikidata.

  • Add a support for WikiData by @macbre in #395
  • More test cases for wikidata + set a global jest timeout to 5 seconds by @macbre in #396

An example:

const wikidata = require("nodemw/lib/wikidata");
const client = new wikidata();

// Where is Saksun, Faroe Islands located?
const geo = await client.getEntityClaim("Q928875" /* Saksun */, "P625" /* place location */);

// will give you the geolocation of the place
expect(geo[0].mainsnak.datavalue.value).toMatchObject({
  latitude: 62.248888888889,
  longitude: -7.1758333333333,
});

// When was Albert Einstein born?
const res = await client.getArticleClaims("Albert Einstein");

const dateOfBirth = res.P569[0].mainsnak.datavalue.value;
expect(dateOfBirth.time).toMatch(/1879-03-14/);

const dateOfDeath = res.P570[0].mainsnak.datavalue.value;
expect(dateOfDeath.time).toMatch(/1955-04-18/);

// interwiki links for a given article
const links = await client.getArticleSitelinks("Albert Einstein");
console.log(links.enwiki); // {site: "enwiki", title: "Albert Einstein", badges: ["Q17437798"]}

What else has changed

  • build(deps-dev): bump @jest/globals from 29.4.0 to 29.4.1 by @dependabot in #397
  • build(deps-dev): bump jest from 29.4.0 to 29.4.1 by @dependabot in #398

Full Changelog: v0.18.1...v0.19.0

Don't miss a new nodemw release

NewReleases is sending notifications on new releases.