Ware Ware - 11 months ago 61
Java Question

How to get all Property value Labels of an Wikidata Item?

How would you request the set of all Properties that an Item has?

Specifically, I'm looking for the English Labels for each Item that is the Value of an Item's Property.

E.g. "Earth":

"Challenger Deep",
"Solar System",
"oblate spheroid",
"World Ocean",

I'm using the Wikidata Toolkit library for now, but I'd take recommendations.

Answer Source

First you need to use MediaWiki API with action wbgetclaims to get all properties for each one claim. For example for Wikidata item Earth (Q2) the request will be:


Then you need to parse the response and to take id from the value for each one property. In this example, for property P1589 the item id is Q459173.

The last step is to get all item labels in English by another request. You have two variants, in both of them we use the all item ids from the previous step, separated by pipe |:

Update: I found how to get all item property labels by using only one request. The idea is to find all item links, and then to filter from them only these from namespace 0 which start with Q.