Extension:WikibaseMediaInfo/Data Model/JSON

This document describes the canonical JSON format used to represent Mediainfo entities in the API. This format is currently unstable and subject to change.

For an explanation of the terms used in this document, please refer to the Wikibase Glossary. For a specification of the semantics of the data structures described here, see the MediaInfo Data Model.

Difference from Wikibase

edit

There are several difference between WikibaseMediaInfo and Wikibase JSON format. Note WikibaseMediaInfo JSON format is currently not a stable interface, so these may change in the future.

  • MediaInfo serialization uses "statements" as key instead of "claims" (phab:T149410); however, you need to use "claims" in wbeditentity
  • WikibaseMediaInfo serializes empty statements as empty array [] instead of empty object {} in JSON (phab:T222159)
  • In statements there is no datatype field (phab:T246809)

JSON Flavor

edit

WikibaseMediaInfo follows the same conventions as Wikibase, as described in Wikibase DataModel JSON Flavor.

Top Level Structure

edit
{
  "entities": {
    "M83198284": {
      "pageid": 83198284,
      "ns": 6,
      "title": "File:Straßenbahn Haltestelle Freizeit- und Erholungszentrum-3.jpg",
      "lastrevid": 371115009,
      "modified": "2019-10-19T08:16:04Z",
      "type": "mediainfo",
      "id": "M83198284",
      "labels": {
        "en": {
          "language": "en",
          "value": "Tram stop in Berlin, Germany"
        },
        "de": {
          "language": "de",
          "value": "Straßenbahn Haltestelle in Berlin"
        }
      },
      "descriptions": {},
      "statements": []
    }
  }
}

The JSON representation consists of the following fields in the top level structure:

pageid
The page id the entity is stored on
title
The title of the page the entity is stored on (this could also include namespace such as 'Item:Q60')
ns
The namespace id the entity is stored in
lastrevid
The JSON document's version (this is a MediaWiki revision ID).
modified
The JSON document's publication date (this is a MediaWiki revision timestamp).
type
The entity type identifier, "mediainfo" for MediaInfo entities.
id
The canonical ID of the entity.
labels
Contains the labels (also known as "captions") in different languages, see Labels below.
descriptions
This field is superseded; see [1] for more information.
statements
Contains any number of statements, grouped by property. See Statements below.

Labels

edit
{
  "labels": {
    "en": {
      "language": "en",
      "value": "Tram stop in Berlin, Germany"
    },
    "de": {
      "language": "de",
      "value": "Straßenbahn Haltestelle in Berlin"
    }
  },
}

For each language, there is a record using the following fields:

language
The language code.
value
The actual label.

Statements

edit
{
  "statements": {
      "P180": [
          {
              "mainsnak": {
                  "snaktype": "value",
                  "property": "P180",
                  "hash": "db55dd32d9ab75e7cc6a40f7217f4dab2e162ae7",
                  "datavalue": {
                      "value": {
                          "entity-type": "item",
                          "numeric-id": 158942,
                          "id": "Q158942"
                      },
                      "type": "wikibase-entityid"
                  }
              },
              "type": "statement",
              "qualifiers": {
                  "P1354": [
                      {
                          "snaktype": "value",
                          "property": "P1354",
                          "hash": "fc66de241219792376d16240f4305b4d7a140c83",
                          "datavalue": {
                              "value": {
                                  "entity-type": "item",
                                  "numeric-id": 4590598,
                                  "id": "Q4590598"
                              },
                              "type": "wikibase-entityid"
                          }
                      }
                  ]
              },
              "qualifiers-order": [
                  "P1354"
              ],
              "id": "M53735917$C95AE483-800F-4E34-A278-4F129A027099",
              "rank": "normal"
          }
      ],
      "P170": [
          {
              "mainsnak": {
                  "snaktype": "value",
                  "property": "P170",
                  "hash": "15b3ae706ad0e4de1fd911e2c108f422d290213a",
                  "datavalue": {
                      "value": {
                          "entity-type": "item",
                          "numeric-id": 34788025,
                          "id": "Q34788025"
                      },
                      "type": "wikibase-entityid"
                  }
              },
              "type": "statement",
              "id": "M53735917$DC230D2B-F11B-496B-8169-6CB713670AB1",
              "rank": "preferred"
          }
      ]
      "P6731": [
          {
              "mainsnak": {
                  "snaktype": "value",
                  "property": "P6731",
                  "hash": "caf86f67082da0e2d10079a79bedf327335b0459",
                  "datavalue": {
                      "value": {
                          "entity-type": "item",
                          "numeric-id": 63348069,
                          "id": "Q63348069"
                      },
                      "type": "wikibase-entityid"
                  }
              },
              "type": "statement",
              "id": "M53735917$9A2D4A40-7DAB-43B6-9252-FD0D72E1A064",
              "rank": "normal"
          },
          {
              "mainsnak": {
                  "snaktype": "value",
                  "property": "P6731",
                  "hash": "00effd845d313cc188e25302a8712c2d48647171",
                  "datavalue": {
                      "value": {
                          "entity-type": "item",
                          "numeric-id": 63348049,
                          "id": "Q63348049"
                      },
                      "type": "wikibase-entityid"
                  }
              },
              "type": "statement",
              "id": "M53735917$AAE1B58B-B553-4F46-A138-9F2FBA649423",
              "rank": "normal"
          }
      ]
  }
}

The JSON "statement" entry of a MediaInfo entity corresponds directly to the JSON "claim" entry of a Wikibase entity.

A Statement consists of a main Snak and a (possibly empty) list of qualifier Snaks.

Statements are described in full in the Statements section of the Wikibase DataModel JSON documentation, with three differences described above.

There are no restrictions on which properties can be used. WikibaseMediaInfo on production uses properties and Wikibase items federated from Wikidata.