query-36fabf607103a3e79528d4815134b5f2

rq turtle/ttl

List of all files in Category:Flora Batava - KB copy, and its subcategories SELECT ?category ?categoryName ?file ?title WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Generator" . bd:serviceParam wikibase:endpoint "commons.wikimedia.org" . bd:serviceParam mwapi:gcmtitle "Category:Flora Batava - KB copy" . bd:serviceParam mwapi:generator "categorymembers" . bd:serviceParam mwapi:gcmlimit "max" . ?categoryName wikibase:apiOutput mwapi:title . ?pageid wikibase:apiOutput "@pageid" . ?ns wikibase:apiOutput "@ns". } FILTER (?ns = "14") # (sub)categories only BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?category)

SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Generator" . bd:serviceParam wikibase:endpoint "commons.wikimedia.org" . bd:serviceParam mwapi:gcmtitle ?categoryName. bd:serviceParam mwapi:generator "categorymembers" . bd:serviceParam mwapi:gcmtype "file" . bd:serviceParam mwapi:gcmlimit "max" . ?title wikibase:apiOutput mwapi:title . ?pageid2 wikibase:apiOutput "@pageid" . } BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid2)) AS ?file) } ORDER BY ?category ?title

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# List of all files in Category:Flora Batava - KB copy, and its subcategories
SELECT ?category ?categoryName ?file ?title
WHERE
{
  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
    bd:serviceParam mwapi:gcmtitle "Category:Flora Batava - KB copy" .
    bd:serviceParam mwapi:generator "categorymembers" .
    bd:serviceParam mwapi:gcmlimit "max" .
    ?categoryName wikibase:apiOutput mwapi:title .
    ?pageid wikibase:apiOutput "@pageid" .
    ?ns wikibase:apiOutput "@ns".
  }
  FILTER (?ns = "14") # (sub)categories only
  BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?category)

  SERVICE wikibase:mwapi
  {
    bd:serviceParam wikibase:api "Generator" .
    bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
    bd:serviceParam mwapi:gcmtitle ?categoryName.
    bd:serviceParam mwapi:generator "categorymembers" .
    bd:serviceParam mwapi:gcmtype "file" .
    bd:serviceParam mwapi:gcmlimit "max" .
    ?title wikibase:apiOutput mwapi:title .
    ?pageid2 wikibase:apiOutput "@pageid" .
  }
  BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid2)) AS ?file)
} ORDER BY ?category ?title

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?category"):::projected v4("?categoryName"):::projected v7("?file"):::projected v3("?ns") v5("?pageid") v6("?pageid2") v2("?title"):::projected c13(["max"]):::literal c17(["@ns"]):::literal c9(["Category:Flora Batava - KB copy"]):::literal c11(["categorymembers"]):::literal c3(["bd:serviceParam"]):::iri c19(["file"]):::literal c15(["mwapi:title"]):::iri c7(["commons.wikimedia.org"]):::literal c16(["@pageid"]):::literal c5(["Generator"]):::literal f0[["?ns = '14'"]] f0 --> v3 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:gcmlimit"--> c13 v4 --"mwapi:apiOutput"--> c15 v5 --"mwapi:apiOutput"--> c16 v3 --"mwapi:apiOutput"--> c17 end bind1[/"concat('https://commons.wikimedia.org/entity/M',?pageid)"/] v5 --o bind1 bind1 --as--o v6 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c3 --"mwapi:api"--> c5 c3 --"mwapi:endpoint"--> c7 c3 --"mwapi:gcmtitle"--> v4 c3 --"mwapi:generator"--> c11 c3 --"mwapi:gcmtype"--> c19 c3 --"mwapi:gcmlimit"--> c13 v2 --"mwapi:apiOutput"--> c15 v6 --"mwapi:apiOutput"--> c16 end bind2[/"concat('https://commons.wikimedia.org/entity/M',?pageid2)"/] v6 --o bind2 bind2 --as--o v7