Page MenuHomePhabricator

Wikibase should add a property to the page response object that indicates the embeded entities
Open, Needs TriagePublic

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 entitiy 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