I'd like to get the file usage on other wikis for a given image on Wikimedia Commons through API.
For example the image https://commons.wikimedia.org/wiki/File:2015_Finland_opinion_polls.png is used in:
Usage on da.wikipedia.org
- Rigsdagsvalget i Finland 2015
Usage on en.wikipedia.org
2015 Finnish parliamentary election
Opinion polling for the 2015 Finnish parliamentary election
Usage on fr.wikipedia.org
- Élections législatives finlandaises de 2015
Usage on it.wikipedia.org
- Elezioni parlamentari in Finlandia del 2015
Usage on no.wikipedia.org
- Riksdagsvalget i Finland 2015
How can i get this information using API? I tried both the wikimedia commons API and the Mediawiki Image API but without luck.
You need the Globalusage API call.
For your example the URL would be:
https://www.mediawiki.org/w/api.php?action=query&prop=globalusage&titles=File:2015_Finland_opinion_polls.png