3

I want to do a query on WikiData where I get all items, that are somehow connect to another item.

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

The API I currently use is the one from wmflabs. Here I can do a query like

claim[189:1741]

This gives me every item with property "Place of discovery" (P189) = "Vienna" (Q1741).

But what I want is something like

claim[*:1741]

to get all items where any property fits "Vienna", for example "Birthplace" (P19), "Place of Death" (P20) or anything else. But wildcards are not working here.

Is this possible? How?


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

Termininja
  • 6,620
  • 12
  • 48
  • 49
dynobo
  • 675
  • 1
  • 6
  • 15

4 Answers4

2

you can use sparql query to Dbpedia to get result for you particular resource, which here is Vienna. To get all property and their value of resource Vienna use can use

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

Check here You can choose specific properties of resource using sparql query like this .

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

user1583465
  • 167
  • 1
  • 2
  • 11
2

maybe something like this:

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

see on Wikidata Query Service

Alexan
  • 8,165
  • 14
  • 74
  • 101
1

But what I want is something … to get all items where any property fits "Vienna"[.]

In SPARQL this is very easy. E.g., on DBpedia's SPARQL endpoint:

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

SPARQL results (limited to 100)

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
1

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

Your query would be this one

See also this help page on Wikidata

benestar
  • 552
  • 4
  • 12