Wikidata queries

Let’s play with Wikidata (query.wikidata.org)

Return 20 items which are instance of human which have a twitter account:
SELECT ?item ?twitter
WHERE {
?item wdt:P31 wd:Q5 .
?item wdt:P2002 ?twitter .
} LIMIT 20

Screen Shot 2016-06-12 at 11.22.35

Or all Nobel Peace laureates:
Read the rest of this entry »


Wikidata

wikidata-logoWikidata is the Wikipedia project for structured knowledge. For example it knows that the capital of Spain is Madrid. The ruby gem wikidata has a basic support to retrieve it:


require 'wikidata'

Wikidata::Item.find_by_title('Spain').claims_for_property_id('P36').first.mainsnak.value.entity.label