Wikimedia Commons stores alt text in the form of WikibaseMediaInfo claims (see {T166094}). We don't want clients to access that directly because
# the Wikibase APIs are complex and not that developer-friendly;
# we want to provide stability guarantees for APIs and community-owned ontology makes that difficult;
# as much as possible we want to hide ontology changes and keep the API the same (e.g. if a migration happens because of {T325944});
# we want to make alt-text features available on developer setups and third-party MediaWiki setups without forcing a Wikibase / WikibaseMediaInfo dependency.
So, there should be an internal PHP API (presumably a core hook or service, maybe along the lines of the [[https://mediawiki.org/wiki/Manual:Hooks/GetExtendedMetadata|GetExtendedMetadata]] hook) that WikibaseMediaInfo implements by looking up the relevant Wikibase property, but other extensions can implement in different ways; and there should probably also be a web API exposing the same functionality. Probably even two web APIs, one in the action API for batching (this probably fits into the `imageinfo` API), and ont in the REST API for caching (maybe fits into the [[https://www.mediawiki.org/wiki/API:REST_API/Reference#Get_file|/file/{title}]] endpoint?).
There will probably be plenty of other similar use cases (e.g. get information about the license of the file) so probably we want an extensible mechanism where it's easy to add more kinds of data later.
Some other considerations:
* there should be a way to get the alt text for a specific file in a specific language (probably with language fallback?)
* there should be a way to get the alt text for all files on a page and/or a batch of images (for the [[https://www.mediawiki.org/wiki/InstantCommons|InstantCommons]] use case)
* is there a use case for getting all languages for a file?
* the web API should probably be cacheable for a short time