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%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",
            }
        },
    }
]

Event Timeline

dbarratt created this task.Nov 1 2018, 4:33 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptNov 1 2018, 4:33 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

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

dbarratt updated the task description. (Show Details)Nov 1 2018, 4:34 PM
dbarratt updated the task description. (Show Details)Nov 1 2018, 4:42 PM
dbarratt updated the task description. (Show Details)
dbarratt updated the task description. (Show Details)Nov 1 2018, 4:44 PM
dbarratt updated the task description. (Show Details)Nov 1 2018, 5:36 PM
Abbe98 added a subscriber: Abbe98.Jan 11 2019, 10:55 PM
Addshore moved this task from incoming to monitoring on the Wikidata board.Dec 7 2019, 4:12 PM
Restricted Application added a project: Core Platform Team. · View Herald TranscriptDec 7 2019, 4:12 PM
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 added a subscriber: Anomie.

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 closed this task as Resolved.Thu, Jan 2, 2:16 PM
dbarratt claimed this task.
dbarratt removed dbarratt as the assignee of this task.