Using the Wikidata API

I recently used Wikidata to retrieve dates of birth and death for a set of people. Figuring out the Wikidata API wasn’t obvious, and the documentation was circular or broken, but here’s what I ended up doing.

First, discover the entity ID:

https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Maurice%20Sendak&language=en

While it’s possible to query the ID directly for date of birth (P569) and date of death (P570) properties, I couldn’t figure out how to request two properties in one request. Singularly, this will retrieve a record for Date of Birth:

https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=Q314771&property=P569

Dropping the property argument and sending one request for the entire entity is probably faster, and filtering for specific properties is easily done afterwards.

A list of Wikidata’s cryptic property ids is here: Wikidata:List of properties/all (that’s a lot better than wading through the Wikidata Query editor

All queries should probably include &format=json&callback=foo as well.

Overall, this felt pretty clumsy. I ended up doing a lot of manual copy-and-paste to fix missing data.

MuseumofModernArt/collection

MoMA posted their entire collection dataset to GitHub. No images are included, but the records include the canonical url of every artwork in the collection. Wow.  Update Several other museums already did this: The Cooper Hewitt Collection The Tate Gallery The Minneapolis Institute of Arts MuseumofModernArt/collection