In T223746 and T223796 I build some proof of concepts to edit the structured data on Commons. These proof of concepts are hacks bypassing the site object. We should properly implement it so we can start building scripts on top of it.
Wikidata uses the Wikibase extension. The Wikibase extension is providing the api functions starting with "wb". The same extension is now also installed on Commons. So all the same api functions are available, see for example https://commons.wikimedia.org/w/api.php?action=wbgetentities&format=json&ids=M7902 . Instead of Q123, M is used (media info). The integer is actually the pageid. Commons is a federated Wikibase instance which uses the properties and entities from Wikidata, see for example https://commons.wikimedia.org/w/index.php?title=File:Christoph_Unterberger_-_Der_heilige_Johannes_von_Nepomuk_empf%C3%A4ngt_von_Maria_den_Sternenkranz_-_2173_-_%C3%96sterreichische_Galerie_Belvedere.jpg&diff=prev&oldid=351075792 . The media info objects get created on the fly when a user does an edit.
I guess we have to implement a new site class which implements two parts (so maybe two classes):
- Federation: We're using the remote P and Q's
- Media info: We have local structured data with the M id's, which are tied to files