query-3980b593bbfad20a6cc1e222eec2f10d

rq turtle/ttl

Swichersupported services

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?wiki ?wikiLabel ?endpoint ?articles ?users ?activeusers WHERE
{
   {
  # Wikimedia content project subclasses (Wikipedia, Wikisorces, Wiktionary, etc language edition)
  SELECT ?wikitype WHERE { ?wikitype wdt:P279 wd:Q33120876 . }
}  ?wiki wdt:P31 ?wikitype.
  ?wiki wdt:P856 ?website.

  # This triple will remove wikis that don't exist anymore and thus avoid MWAPI errors ("404 Not Found") 
  ?website wikibase:wikiGroup ?wikigroup.

  FILTER (?wikigroup = "wiktionary") # Limit to wiktionaries to avoid timeout

  BIND (STRBEFORE(STRAFTER(STR(?website), "https://"), "/") AS ?endpoint)
  OPTIONAL
  {
    SERVICE wikibase:mwapi
    {
      bd:serviceParam wikibase:endpoint ?endpoint .
      bd:serviceParam wikibase:limitContinuations "0".

      # None of the 4 available API services give site statistics, but it is necessary to select one.
      # Here we do a page list limited to 1 page without retrieving the result.
      bd:serviceParam wikibase:api "Generator" .
      bd:serviceParam mwapi:generator "allpages" .
      bd:serviceParam mwapi:gaplimit "1" .

      # Also add site statistics to the API call:
      bd:serviceParam mwapi:meta "siteinfo" .
      bd:serviceParam mwapi:siprop "statistics" .
      ?articles wikibase:apiOutput "//api/query/statistics/@articles" .
      ?users wikibase:apiOutput "//api/query/statistics/@users" .
      ?activeusers wikibase:apiOutput "//api/query/statistics/@activeusers" .
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?activeusers"):::projected v6("?articles"):::projected v5("?endpoint"):::projected v7("?users"):::projected v4("?website") v3("?wiki"):::projected v1("?wikigroup") v2("?wikitype") c23(["//api/query/statistics/@articles"]):::literal c8(["bd:serviceParam"]):::iri c15(["allpages"]):::literal c24(["//api/query/statistics/@users"]):::literal c25(["//api/query/statistics/@activeusers"]):::literal c11(["0"]):::literal c17(["1"]):::literal c28(["#91;AUTO_LANGUAGE#93;,en"]):::literal c19(["siteinfo"]):::literal c3(["wd:Q33120876"]):::iri c13(["Generator"]):::literal c21(["statistics"]):::literal f0[["?wikigroup = 'wiktionary'"]] f0 --> v1 v2 --"wdt:P279"--> c3 v3 --"wdt:P31"--> v2 v3 --"wdt:P856"--> v4 v4 --"mwapi:wikiGroup"--> v1 bind1[/"substring-before(substring-after(str(?website),'https://'),'/')"/] v4 --o bind1 bind1 --as--o v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c8 -."mwapi:endpoint".-> v5 c8 --"mwapi:limitContinuations"--> c11 c8 --"mwapi:api"--> c13 c8 --"mwapi:generator"--> c15 c8 --"mwapi:gaplimit"--> c17 c8 --"mwapi:meta"--> c19 c8 --"mwapi:siprop"--> c21 v6 --"mwapi:apiOutput"--> c23 v7 --"mwapi:apiOutput"--> c24 v8 --"mwapi:apiOutput"--> c25 end end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c8 --"mwapi:language"--> c28 end