Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of all Wikidata properties?

What is the Wikidata API equivalent to this page which lists all known Wikidata properties? I would like to search for a property, e.g. 'doctoral advisor', and get back P184.

A similar function exists for items, but I can't seem to find the equivalent for properties.

like image 651
nerab Avatar asked Aug 02 '14 23:08

nerab


4 Answers

Using action=wbsearchentities with type=property should do. Wikidata API doc is here, search for "=wb" to get the Wikidata-specific functions.

like image 84
Magnus Manske Avatar answered Sep 20 '22 21:09

Magnus Manske


Update: thank to @nerab's answer, I updated wikidata-properties-dumper to use Quarry SQL results: that's indead much cleaner :)

Update 2: Quarry wasn't that flexible, I moved to use a SPARQL query and wrapped that in a Wikidata CLI command: wd props

I wrote a small script to query all properties with wikidata API's action=wbgetentities. It generate a json file with

key: value

being

property Pid: property label in the request language

I published the outputs for a few languages and could do for other language on request until there is an official (and cleaner) answer for this need

like image 27
maxlath Avatar answered Sep 19 '22 21:09

maxlath


Thanks to the comments in @maxlath's project, I found Quarry.

A list of all Wikidata properties can be fetched from

http://quarry.wmflabs.org/run/45013/output/1/json

This particular list is in English, but the query can be modified for other languages, too.

like image 30
nerab Avatar answered Sep 18 '22 21:09

nerab


You can use this SPARQL query: it returns property name, description and comma separated also known as labels from English language:

SELECT ?property ?propertyLabel ?propertyDescription (GROUP_CONCAT(DISTINCT(?altLabel); separator = ", ") AS ?altLabel_list) WHERE {
    ?property a wikibase:Property .
    OPTIONAL { ?property skos:altLabel ?altLabel . FILTER (lang(?altLabel) = "en") }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .}
 }
GROUP BY ?property ?propertyLabel ?propertyDescription
LIMIT 5000
like image 44
Michail Michailidis Avatar answered Sep 17 '22 21:09

Michail Michailidis