query-9e02d08d0f450c8eff7c3aba6beb5428
Query Commons files and structured dataI'm able to return the files within a category, but I would like to return some structured data as well. I got this far but i'm unsuccessful with the later part.
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#>
SELECT ?file ?url ?title
WHERE {
VALUES ?categories {
"Category:Vidéos LSF par Laura Jauvert"
}
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" ;
wikibase:endpoint "commons.wikimedia.org" ;
mwapi:gcmtitle ?categories ;
mwapi:generator "categorymembers" ;
mwapi:gcmtype "file" ;
# mwapi:prop "P407" ; # I have no clue how to query strucured data P407
mwapi:gcmlimit "max" .
?title wikibase:apiOutput mwapi:title .
?pageid wikibase:apiOutput "@pageid" .
#?lang wikibase:apiOutput mwapi:prop.
}
BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
BIND (URI(CONCAT('https://commons.wikimedia.org/wiki/', ?title)) AS ?url)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?categories")
v4("?file"):::projected
v3("?pageid")
v2("?title"):::projected
v5("?url"):::projected
c13(["max"]):::literal
c9(["categorymembers"]):::literal
c2(["bd:serviceParam"]):::iri
c11(["file"]):::literal
c15(["mwapi:title"]):::iri
c6(["commons.wikimedia.org"]):::literal
c16(["@pageid"]):::literal
c4(["Generator"]):::literal
bind0[/VALUES ?categories/]
bind0-->v1
bind00(["Category:Vidéos LSF par Laura Jauvert"])
bind00 --> bind0
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c2 --"mwapi:api"--> c4
c2 --"mwapi:endpoint"--> c6
c2 --"mwapi:gcmtitle"--> v1
c2 --"mwapi:generator"--> c9
c2 --"mwapi:gcmtype"--> c11
c2 --"mwapi:gcmlimit"--> c13
v2 --"mwapi:apiOutput"--> c15
v3 --"mwapi:apiOutput"--> c16
end
bind1[/"concat('https://commons.wikimedia.org/entity/M',?pageid)"/]
v3 --o bind1
bind1 --as--o v4
bind2[/"concat('https://commons.wikimedia.org/wiki/',?title)"/]
v2 --o bind2
bind2 --as--o v5