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