query-13e40fa41e62d0c5c2a1f0df7c210bad
title:Q-ID from a Wikipedia article ID SELECT ?pageid ?qid ?itemLabel { VALUES ?wiki { "en.wikipedia.org" } VALUES ?pageid { "53658238" } SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Generator" . bd:serviceParam wikibase:endpoint ?wiki . bd:serviceParam mwapi:generator "revisions" . bd:serviceParam mwapi:pageids ?pageid . ?item wikibase:apiOutputItem mwapi:item .} FILTER(BOUND(?item)) BIND(SUBSTR(STR(?item), 32) AS ?qid) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Q-ID from a Wikipedia article ID
SELECT ?pageid ?qid ?itemLabel {
VALUES ?wiki { "en.wikipedia.org" }
VALUES ?pageid { "53658238" }
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint ?wiki .
bd:serviceParam mwapi:generator "revisions" .
bd:serviceParam mwapi:pageids ?pageid .
?item wikibase:apiOutputItem mwapi:item .}
FILTER(BOUND(?item))
BIND(SUBSTR(STR(?item), 32) AS ?qid)
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;
v1("?item")
v3("?pageid"):::projected
v4("?qid"):::projected
v2("?wiki")
c10(["mwapi:item"]):::iri
c2(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["revisions"]):::literal
c4(["Generator"]):::literal
f0[["bound(?item)"]]
f0 --> v1
bind1[/VALUES ?wiki/]
bind1-->v2
bind10(["en.wikipedia.org"])
bind10 --> bind1
bind2[/VALUES ?pageid/]
bind2-->v3
bind20(["53658238"])
bind20 --> bind2
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c2 --"mwapi:api"--> c4
c2 --"mwapi:endpoint"--> v2
c2 --"mwapi:generator"--> c7
c2 --"mwapi:pageids"--> v3
v1 --"mwapi:apiOutputItem"--> c10
end
bind3[/"substring(str(?item),'32^^xsd:integer')"/]
v1 --o bind3
bind3 --as--o v4
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c2 --"mwapi:language"--> c13
end