query-8a84515fe4ca81f3da5a04b45c0aa6cb
Elaborate MWAPI example - UK passenger ships
APIs: Search, Categories, EntitySearch, Generator
See also: https://github.com/wikimedia/wikidata-query-deploy/blob/master/mwservices.json
SELECT ?item ?title ?pageid ?uri (round(?length/1024) AS ?kiB) ?touched ?lastrevid ?ordinal ?user WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "en.wikipedia.org"; wikibase:api "Generator" ; wikibase:limit 500 ; mwapi:generator "categorymembers" ; mwapi:gcmtitle "Category:Passenger_ships_of_the_United_Kingdom" ; mwapi:gcmnamespace "0" ; mwapi:gcmlimit "max" ; mwapi:prop "info|pageprops|revisions" ; mwapi:ppprop "wikibase_item" ; mwapi:inprop "url" ; mwapi:rvprop "user" .
?ordinal wikibase:apiOrdinal true.
?item wikibase:apiOutputItem mwapi:item.
?title wikibase:apiOutput mwapi:title.
?pageid wikibase:apiOutput mwapi:pageid.
?timestamp wikibase:apiOutput mwapi:timestamp.
?lastrevid wikibase:apiOutput mwapi:lastrevid.
?uri wikibase:apiOutputURI "@fullurl".
?length_ wikibase:apiOutput "@length".
?user wikibase:apiOutput "revisions/rev/@user".
} BIND(xsd:integer(?length_) AS ?length) BIND(xsd:dateTime(?timestamp) AS ?touched) } ORDER BY DESC(?length)
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Elaborate MWAPI example - UK passenger ships
# APIs: Search, Categories, EntitySearch, Generator
# See also: https://github.com/wikimedia/wikidata-query-deploy/blob/master/mwservices.json
SELECT
?item ?title ?pageid ?uri (round(?length/1024) AS ?kiB) ?touched
?lastrevid ?ordinal ?user
WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "en.wikipedia.org";
wikibase:api "Generator" ;
wikibase:limit 500 ;
mwapi:generator "categorymembers" ;
mwapi:gcmtitle "Category:Passenger_ships_of_the_United_Kingdom" ;
mwapi:gcmnamespace "0" ;
mwapi:gcmlimit "max" ;
mwapi:prop "info|pageprops|revisions" ;
mwapi:ppprop "wikibase_item" ;
mwapi:inprop "url" ;
mwapi:rvprop "user" .
?ordinal wikibase:apiOrdinal true.
?item wikibase:apiOutputItem mwapi:item.
?title wikibase:apiOutput mwapi:title.
?pageid wikibase:apiOutput mwapi:pageid.
?timestamp wikibase:apiOutput mwapi:timestamp.
?lastrevid wikibase:apiOutput mwapi:lastrevid.
?uri wikibase:apiOutputURI "@fullurl".
?length_ wikibase:apiOutput "@length".
?user wikibase:apiOutput "revisions/rev/@user".
}
BIND(xsd:integer(?length_) AS ?length)
BIND(xsd:dateTime(?timestamp) AS ?touched)
}
ORDER BY DESC(?length)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?item"):::projected
v12("?kiB")
v7("?lastrevid"):::projected
v11("?length"):::projected
v9("?length_")
v2("?ordinal"):::projected
v5("?pageid"):::projected
v6("?timestamp")
v4("?title"):::projected
v11("?touched"):::projected
v8("?uri"):::projected
v10("?user"):::projected
c28(["mwapi:item"]):::iri
c31(["mwapi:pageid"]):::iri
c18(["info|pageprops|revisions"]):::literal
c4(["en.wikipedia.org"]):::literal
c35(["@fullurl"]):::literal
c2(["bd:serviceParam"]):::iri
c12(["Category:Passenger_ships_of_the_United_Kingdom"]):::literal
c37(["revisions/rev/@user"]):::literal
c33(["mwapi:lastrevid"]):::iri
c20(["wikibase_item"]):::literal
c16(["max"]):::literal
c32(["mwapi:timestamp"]):::iri
c22(["url"]):::literal
c10(["categorymembers"]):::literal
c14(["0"]):::literal
c8(["500^^xsd:integer"]):::literal
c26(["true^^xsd:boolean"]):::literal
c36(["@length"]):::literal
c30(["mwapi:title"]):::iri
c24(["user"]):::literal
c6(["Generator"]):::literal
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c2 --"mwapi:endpoint"--> c4
c2 --"mwapi:api"--> c6
c2 --"mwapi:limit"--> c8
c2 --"mwapi:generator"--> c10
c2 --"mwapi:gcmtitle"--> c12
c2 --"mwapi:gcmnamespace"--> c14
c2 --"mwapi:gcmlimit"--> c16
c2 --"mwapi:prop"--> c18
c2 --"mwapi:ppprop"--> c20
c2 --"mwapi:inprop"--> c22
c2 --"mwapi:rvprop"--> c24
v2 --"mwapi:apiOrdinal"--> c26
v3 --"mwapi:apiOutputItem"--> c28
v4 --"mwapi:apiOutput"--> c30
v5 --"mwapi:apiOutput"--> c31
v6 --"mwapi:apiOutput"--> c32
v7 --"mwapi:apiOutput"--> c33
v8 --"mwapi:apiOutputURI"--> c35
v9 --"mwapi:apiOutput"--> c36
v10 --"mwapi:apiOutput"--> c37
end
bind0[/"http://www.w3.org/2001/XMLSchema#integer(?length_)"/]
v9 --o bind0
bind0 --as--o v11
bind1[/"http://www.w3.org/2001/XMLSchema#dateTime(?timestamp)"/]
v6 --o bind1
bind1 --as--o v11
bind2[/"numeric-round(?length / '1024^^xsd:integer')"/]
v11 --o bind2
bind2 --as--o v12