Problem
On a page response object like this:
https://www.wikidata.org/w/api.php?action=query&format=json&prop=info&titles=Q2&formatversion=2
the entity id is obvious as it's the same as the title.
This response is slightly more complicated
https://www.wikidata.org/w/api.php?action=query&format=json&prop=info&titles=Property%3AP18&formatversion=2
however, it's easy to determine the entity id (the title, sans namespace)
However, a request like this:
https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&prop=info&titles=File%3ARedsq.png&formatversion=2
it can be impossible to know that the entity id is M59928
Solution
Wikibase should add a new property to the page response object that will return a collection of embedded entity ids on a page organized by slot. It should look at each slot to determine if any are wikibase entities and return the id for that entity. The API should not return related entities (i.e. on Lexemes) since those can be retrieved on the entity endpoints. Slots that are not wikibase entities should not be included in the collection.
Example
{ "wbentity": { "mediainfo": "M59928" } }
Alternatively, it could go in the revision object under slots:
"revisions": [ { "revid": 105192, "parentid": 105190, "minor": false, "timestamp": "2018-10-30T16:08:57Z", "slots": { "main": { "contentmodel": "wikitext", }, "mediainfo": { "contentmodel": "wikibase-mediainfo", "wbentityid": "M59928", } }, } ]