As a Wikidata data reuser I want to get statement data in a simple format so that I can access the necessary data easily
As a Wikidata data reuser I want to get statement data without redundant data so that I do not need to process data I do not need.
Responses containing statement data should use the intended structure.
Requests containing statement data (POST, PUT, also PATCH) should use the intended structure.
Changes:
- mainsnak object is removed, its fields are raised one level in the hierarchy
- value top-level field is added, consisting of two fields:
- content (string or JSON object) - capturing the value of the statement (previously mainsnak.datavalue.value)
- type accepting values novalue, somevalue, value -- previously mainsnak.snaktype
- content field is omitted if the value is known to not be possible to be defined (type: novalue) or known to be unknown (type: somevalue)
- values of reference and qualifier objects ("snaks") are also represented using a value object
- introduce a top level object property holding both the id and previous mainsnak.datatype as data-type (note: NOT datatype)
- mainsnak.hash field is removed
- datavalue.type is removed
- qualifiers is turned from a map of lists of snak objects into a list of snak objects
- qualifiers-order is removed
- references.snaks is renamed to references.parts and turned from a map of lists of snak objects into a list of snak objects
- references.snaks-order is removed
Not included in this story (will be addressed separately)
- remove altitude from globe-coordinate values
- remove timezone, before, after from time values
Intended structure/representation (pseudo JSON - might contain mistakes/typos; ask if spotted something unexpected)
{ "P92": [ { "property": { "id": "P92", "data-type": "string" }, "value": { "content": "TEXT", "type": "value" }. "id": "Q11$6403c562-401a-2b26-85cc-8327801145e1", "rank": "normal", "references": [ { "hash": "b25ff4bd5398ca646c621e114e4498e2bd608fd4", "parts": [ { "property": { "id": "P711", "data-type": "string" }, "value": { "content": "My message to video game databases: We(kidata) come in peace", "type": "value" } } ] } ], "qualifiers": [ { "property": { "id": "P92", "data-type": "string" }, "value": { "content": "TEXT", "type": "value" } } ] } ], "P694": [ { "property": { "id": "P694", "data-type": "wikibase-item" }, "value": { "content": { "id": "Q123", "entity-type": "item", "numeric-id": 123 }, "type": "value" }. "id": "Q11$6403c562-401a-2b26-85cc-8327801145e1", "rank": "normal", "references": [], "qualifiers": [] } ], "P476": [ { "property": { "id": "P476", "data-type": "time" }, "value": { "content'; { "time": "+2021-09-17T00:00:00Z", "precision": "11", "calendar-model": "http://www.wikidata.org/entity/Q1985727" }, "type": "value" }, "id": "Q11$350e511c-48f9-caaa-72db-2ec8822f4432", "rank": "normal", "references": [], "qualifiers": [] } ], "P937": [ { "property": { "id": "P937", "data-type": "quantity" }, "value": { "content": { "amount": "+14.23", "unit": "1", "lowerBound": "+24.23", "upperBound": "+4.23" }, "type": "value" }, "id": "Q11$350e511c-48f9-caaa-72db-2ec8822f4432", "rank": "normal", "references": [], "qualifiers": [] } ], "P5": [ { "property": { "id": "P5", "data-type": "globe-coordinate" }, "value": { "content": { "latitude": "52.52", "longitude": "13.405", "precision": "0.001", "globe": "http://www.wikidata.org/entity/Q2" }, "type": "value" }, "id": "Q11$350e511c-48f9-caaa-72db-2ec8822f4432", "rank": "normal", "references": [], "qualifiers": [] } ], "P123": [ { "property": { "id": "P123", "data-type": "string" }, "value": { 'type": "novalue" }. "id": "Q11$6403c562-401a-2b26-85cc-8327801145e1", "rank": "normal", "references": [], "qualifiers": [] } ], "P124": [ { "property": { "id": "P124", "data-type": "string" }, "value": { 'type": "somevalue" }. "id": "Q11$6403c562-401a-2b26-85cc-8327801145e7", "rank": "normal", "references": [], "qualifiers": [] } ] }
Further differences between the current structure inherited from "Action API" etc are documented for the WMDE team in the internal document: https://docs.google.com/spreadsheets/d/1yAxIaUodJNvsY_eWRvBTySMF4ytkfbu5hGEkNrBnvto/edit#gid=1820649401
Acceptance criteria:
- Responses to GET, POST, PUT and PATCH requests that contain statement data use the intended structure
- PUT, POST requests use the intended structure when validating/processing the input
- PATCH request assume intended structure to be relevant for patch operations
- Differences between the intended structure and the statement data representation in "Action API" responses/requests have been documented in the internal documentation