qwikidata.snak module

Module for Wikidata Snaks.

class WikidataSnak(snak_dict)[source]

Bases: object

A Wikidata snak.


snak_dict (dict) – A dictionary representing a Wikidata snak. See the wikibase JSON data model docs for a description of the format.

  • snaktype (str) – One of [“value”, “somevalue”, “novalue”]. “value” indicates that a known value exists, “somevalue” indicates that an unknown value exists, and “novalue” indicates that no value exists.

  • property_id (str) – A Wikidata property id (e.g. “P551”)

  • snak_datatype (str or None) – The snak data type (SDT). Must be one of [“commonsMedia”, “external-id”, “geo-shape”, “globe-coordinate”, “math”, “monolingualtext”, “quantity”, “string”, “tabular-data”, “time”, “url”, “wikibase-item”, “wikibase-property”, None]. Will be None if snaktype is not “value”.

  • value_datatype (str or None) – The value data type (VDT). Must be one of [“globecoordinate”, “monolingualtext”, “quantity”, “string”, “time”, “wikibase-entityid”, None]. Will be None if snaktype is not “value”.

  • datavalue (WikidataDataValue or None) – The datavalue object for this snak. Has datatype and value attributes. (this data type is the same as VDT above).


There are two related data types here, the snak data type (SDT) and the value data type (VDT). The SDT is derived from the data type of the property referenced by property_id and is stored in the snak_datatype attribute. The VDT defines the structure of the value attribute of WikidataDataValue. The VDT does not allow for interpretation of the datavalue, only for processing of the raw structure. As an example, a link to a web page may have SDT=”url”, but have VDT=”string”.