[ updated answer : using SPARQL endpoint]
wdq is replaced by the official SPARQL endpoint , where this query looks like this:
PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?item ?itemLabel WHERE { ?item wdt:P646 "/m/0gnfq" . }
You can PREFIX wd: PREFIX wdt: PREFIX rdfs: PREFIX p: PREFIX v: SELECT? Item? ItemLabel WHERE {? Item wdt: P646 "/ m / 0gnfq". SERVICE wikibase: label {bd: serviceParam wikibase: language "en". }} rel = noreferrer> try this on query.wikidata.org
and to get the results of this query in JSON format, you can make a query at " https://query.wikidata.org/sparql?format=json&query=YOURQUERY ", where YOURQUERY is a SPARQL query with URI encoding:
https://query.wikidata.org/sparql?format=json&query=PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%20PREFIX%20wdt%3A%20%3Chttp% 3A% 2F% 2Fwww.wikidata.org% 2Fprop% 2Fdirect% 2F% 3E% 20SELECT% 20% 3Fitem% 20% 3FitemLabel% 20WHERE% 20% 7B% 20% 3Fitem% 20wdt% 3AP646% 20% 22% 2Fm% 2F0gnfq 22% 20. % 20SERVICE% 20wikibase% 3Alabel% 20% 7B% 20bd% 3AserviceParam% 20wikibase% 3Alanguage% 20% 22en% 22% 20% 20% 7D% 20% 7D
[ old answer : using WDQ]
you can get the wmflabs API ( documentation ) as follows:
http://wdq.wmflabs.org/api?q=string[646:/m/0gnfq]
Here I am asking for Wikidata entities with property 646
value /m/0gnfq
.
The answer will look like this:
{ "status": { "error": "OK", "items": 1, "querytime": "161ms", "parsed_query": "STRING[646:'/m/0gnfq']" }, "items": [ 180736 ] }
So the entity I was looking for is Q180736
.
Here, the request uses the string
parameter, since freebase identifiers are strings in Wikidata, but for properties that imply Wikidata entities as a value type, you will need to use the claim
parameter. Example from the documentation:
The requirement [138: 676555] returns all items that are named after (P138) Francis of Assisi (Q676555).