3

I tried without success get this query:

https://www.wikidata.org/w/api.php?action=wbsearchentities&search=arturo&format=json&language=en&uselang=en&type=item

but only with elements from instance "human of", that means from P31 : Q5

Any help will be preciated because I can't find a way to set up those props. This kind of query explodes in SPARQL but if someone has a relative answer to get the same result (search for all people with his name start with....) will be preciated too.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116

1 Answers1

3

I'm really not sure that's possible with the Mediawiki API. It was not possible a few years ago and I don't think the feature has been implemented since then.

But Open Refine has a reconciliation service with Wikidata based on an API that can filter by type ("instance of") or property. Its developer has not yet advertised it explicitly as a standalone API, but this is in project. Here is an example of use: find in Wikidata the people called "arturo" instances of human (Q5) and whose occupation (P106) is actor (Q33999).

https://tools.wmflabs.org/openrefine-wikidata/en/api?query={
                      "query":"arturo",
                      "limit":6,
                      "type" : "Q5",
                      "properties" : [
                         { "pid" : "P106" , "v" : "Q33999"}
                         ]
                         }

Result.

The main problem with this query is it will only return Arturos which are explicitly an instance of Q5. This will be the case of this one, but not of those who are, for example, only instance of "film maker" (and it does not matter that film maker is himself a subclass of "human"). Sparql can handle class transitivity using the property paths (eg : wdt:P279*/wdt:P31*), but this API has not (yet) implemented them.

Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23
  • 2
    Thanks for response, but openrefine didn't help a lot. (Your answer helps anyway, thanks!) I've already tried. It lacks a lot of filters and data is not consistent because wikidata has a lot of problems with his elasticsearch motor. Actually, as you mentioned, this question has no answer at the moment, but thanks for your effort. – Leandro Bardelli Mar 15 '18 at 14:33