Page MenuHomePhabricator

Should Wikibase add a property to the page response object that indicates the embedded entities?
Closed, ResolvedPublic

Description

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:P18&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:Redsq.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",
            }
        },
    }
]

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Adding MediaWiki-Action-API so they are aware, feel free to remove the tag. :)

dbarratt updated the task description. (Show Details)
dbarratt renamed this task from Wikibase should add a property to the page response object that indicates the embeded entities to Should Wikibase add a property to the page response object that indicates the embedded entities?.Dec 8 2019, 12:45 AM
dbarratt updated the task description. (Show Details)
Anomie subscribed.

According to https://www.mediawiki.org/wiki/Extension:WikibaseMediaInfo#MediaInfo_Entity, the entity ID is "in the form Mxxx, where xxx is the id of the associated wiki page". So you can look at the pageid field in the response and prepend "M".

I note that T205417 seems to have been done specifically because that mapping is canonical for MediaInfo.

dbarratt claimed this task.
dbarratt removed dbarratt as the assignee of this task.