jeropbrenda
A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.
How to get captions from a file?


Chicocvenancio
It’s in the mediainfo slot of the revision. Not sure if there is (or should be) a more straightforward way, but a call to https://commons.wikimedia.org/w/api.php?action=query&prop=revisions&titles=File%3AStranieri_prato.png&rvprop=content&rvslots=mediainfo will get you what you need
IE: API:Revisions on rvslots=mediainfo
and desired title in titles=
.

jeropbrenda
This is perfect. Thanks:)

Tgr
You can use the wikibase API which is probably better than depending on the internal representation: action=wbgetentities&sites=commonswiki&titles=File%3AStranieri%20prato.png&props=labels&languages=it&languagefallback=1
Note that structured media info is in an early rollout phase and most images are probably not migrated yet.

jeropbrenda
Yeah this is neater. Thanks a bunch:)