query-aa0b92b196b46ac54cf1ec98f00eed0c

rq turtle/ttl

MediaWiki API Search text of English labels on Wikidata, output information "instance of" or "subclass of".manual page, announcementSee

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?type ?typeLabel WHERE {
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" .
      bd:serviceParam wikibase:endpoint "www.wikidata.org" .
      bd:serviceParam mwapi:search "cheese" .
      bd:serviceParam mwapi:language "en" .
      ?item wikibase:apiOutputItem mwapi:item .
  }
  ?item (wdt:P279|wdt:P31) ?type
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }                       
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v2("?type"):::projected c6(["www.wikidata.org"]):::literal c12(["mwapi:item"]):::iri c10(["en"]):::literal c8(["cheese"]):::literal c2(["bd:serviceParam"]):::iri c4(["EntitySearch"]):::literal subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c2 --"mwapi:api"--> c4 c2 --"mwapi:endpoint"--> c6 c2 --"mwapi:search"--> c8 c2 --"mwapi:language"--> c10 v1 --"mwapi:apiOutputItem"--> c12 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P31"--> v2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P279"--> v2 end union0r <== or ==> union0l end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c2 --"mwapi:language"--> c10 end