query-bae4cdcda8132d5db9daf00b3cf0c459

rq turtle/ttl

Using wikibase:mwapi with SDC statements on Commons is up and running I was experimenting with how to combine SDC SPARQL queries with information stored in SQL database like category membership, presence of specific templates, etc. I could not fine any way with exception of wikibase:mwapi service, I tried https://wcqs-beta.wmflabs.orgHi now that

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT  ?file ?wd ?fileStr {
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Artworks with mismatching structured data P6243 property" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "page" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "timestamp" .
     ?pageid wikibase:apiOutputItem mwapi:pageid.
     ?ns     wikibase:apiOutput "@ns".
  }
  #?file schema:contentUrl ?url .
  FILTER (?ns = "6") # files only
  BIND (replace(str(?pageid),'http://www.wikidata.org/entity/','https://commons.wikimedia.org/entity/M')  as ?fileStr)
  BIND (str(?file)  as ?fileStr)
  ?file wdt:P6243 ?wd .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?file"):::projected v4("?fileStr"):::projected v1("?ns") v2("?pageid") v5("?wd"):::projected c15(["max"]):::literal c21(["@ns"]):::literal c19(["mwapi:pageid"]):::iri c11(["categorymembers"]):::literal c3(["bd:serviceParam"]):::iri c9(["Category:Artworks with mismatching structured data P6243 property"]):::literal c13(["page"]):::literal c7(["commons.wikimedia.org"]):::literal c5(["Generator"]):::literal c17(["timestamp"]):::literal f0[["?ns = '6'"]] f0 --> v1 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 --"mwapi:api"--> c5 c3 --"mwapi:endpoint"--> c7 c3 --"mwapi:gcmtitle"--> c9 c3 --"mwapi:generator"--> c11 c3 --"mwapi:gcmtype"--> c13 c3 --"mwapi:gcmlimit"--> c15 c3 --"mwapi:gcmsort"--> c17 v2 --"mwapi:apiOutputItem"--> c19 v1 --"mwapi:apiOutput"--> c21 end bind1[/"replace(str(?pageid),'http://www.wikidata.org/entity/','https://commons.wikimedia.org/entity/M')"/] v2 --o bind1 bind1 --as--o v4 bind2[/"str(?file)"/] v4 --o bind2 bind2 --as--o v4 v4 --"wdt:P6243"--> v5