query-55b6a039e233ad7b9b28900cd03e4dfe

rq turtle/ttl

title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} } title: Find metadata like artist and license for an image SELECT ?image ?filename ?license ?artist ?licenseurl WHERE { wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property # The following line transforms the image to be used in the Commons API BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename) # Below is the call to the Wikimedia Commons API SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "commons.wikimedia.org"; wikibase:api "Generator"; mwapi:generator "allpages"; mwapi:prop "imageinfo"; mwapi:iiprop "extmetadata"; mwapi:gapfrom ?filename ; mwapi:gapto ?filename; mwapi:gapnamespace "6". ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" . ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" . ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .
} }

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#>
#title: Find metadata like artist and license for an image
SELECT ?image ?filename ?license ?artist ?licenseurl WHERE {
  wd:Q20 wdt:P948 ?image . # Change here to select any other image, by changing item and property
  # The following line transforms the image to be used in the Commons API
  BIND(wikibase:decodeUri(STRAFTER(STR(?image), "http://commons.wikimedia.org/wiki/Special:FilePath/")) AS ?filename)
  # Below is the call to the Wikimedia Commons API
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:endpoint "commons.wikimedia.org";
                    wikibase:api "Generator";
                    mwapi:generator "allpages";
                    mwapi:prop "imageinfo";
                    mwapi:iiprop "extmetadata";
                    mwapi:gapfrom ?filename ;
                    mwapi:gapto ?filename;
                    mwapi:gapnamespace "6".
    ?license wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseShortName/@value" .
    ?artist wikibase:apiOutput "imageinfo/ii/extmetadata/Artist/@value" .
    ?licenseurl wikibase:apiOutput "imageinfo/ii/extmetadata/LicenseUrl/@value" .                    
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?artist"):::projected v2("?filename"):::projected v1("?image"):::projected v3("?license"):::projected v5("?licenseurl"):::projected c14(["extmetadata"]):::literal c1(["wd:Q20"]):::iri c21(["imageinfo/ii/extmetadata/Artist/@value"]):::literal c22(["imageinfo/ii/extmetadata/LicenseUrl/@value"]):::literal c4(["bd:serviceParam"]):::iri c10(["allpages"]):::literal c20(["imageinfo/ii/extmetadata/LicenseShortName/@value"]):::literal c18(["6"]):::literal c12(["imageinfo"]):::literal c6(["commons.wikimedia.org"]):::literal c8(["Generator"]):::literal c1 --"wdt:P948"--> v1 bind0[/"http://wikiba.se/ontology#decodeUri(substring-after(str(?image),'http://commons.wikimedia.org/wiki/Special:FilePath/'))"/] v1 --o bind0 bind0 --as--o v2 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c4 --"mwapi:endpoint"--> c6 c4 --"mwapi:api"--> c8 c4 --"mwapi:generator"--> c10 c4 --"mwapi:prop"--> c12 c4 --"mwapi:iiprop"--> c14 c4 --"mwapi:gapfrom"--> v2 c4 --"mwapi:gapto"--> v2 c4 --"mwapi:gapnamespace"--> c18 v3 --"mwapi:apiOutput"--> c20 v4 --"mwapi:apiOutput"--> c21 v5 --"mwapi:apiOutput"--> c22 end