Wikidata - is this query possible?

I want to make a request to WikiData where I get all the elements that connect to another element in some way.

For example, I have Item " Vienna " (Q1741). Now I want to get all items that have Item Vienna in any property.

I am currently using the API that wmflabs uses . Here I can make a request like

claim[189:1741]

      

This gives me each item with the property "Location" (P189) = "Vienna" (Q1741).

But I want something like

claim[*:1741]

      

to get all items where any mod is appropriate for "Vienna", for example "Place of Birth" (P19), "Place of Death" (P20) or something else. But wildcards don't work here.

Is it possible? How?


PS: I am not tied to this API, I could use any API for wikidat accessible via JS. There are also some SparQL endpoints for the Wikidata-Dumps available (like wikidataldf ), but I don't know how stable they are. But if someone can help with a solution using SPARQL I would be glad too.

+3


source to share


4 answers


you can use sparql query for Dbpedia to get the result for your specific resource, which is Vienna here . To get all the properties and their resource value used in Vienna, you can use

select ?property ?value where { 
<http://dbpedia.org/resource/Vienna> ?property ?value
 }

      

Check here You can select specific properties of a resource using a sparql query, for example:



select ?country ?density ?timezone ?thumbnail where { 
<http://dbpedia.org/resource/Vienna> dbpedia-owl:country ?country;
 dbpedia-owl:populationDensity ?density;
dbpedia-owl:timeZone ?timezone;
dbpedia-owl:thumbnail ?thumbnail.
}

      

Check

+2


source


maybe something like this:

SELECT ?node WHERE {?node ?pred wd:Q1741} 

      



see Wikidata Query Service

+2


source


But I want something and hellip; to get all items where any mod is suitable for "Vienna" [.]

In SPARQL, it's very simple. For example, DBpedia SPARQL endpoint :

select ?resource where {
  ?resource ?property dbpedia:Vienna 
}

      

SPARQL Results (capped at 100)

+1


source


There are already some SPARQL endpoints for Wikidat. However, they are still beta and only reflect the data from the last dump.

Your request will be this

See also this Wikidata help page

+1


source







All Articles