WikidataData

WikidataData[item,property]

gives the values of the specified property for the given item.

WikidataData[{item1,item2,},property]

gives values for each of the itemi.

WikidataData[item,{property1,property2,}]

gives values for each of the propertyi.

WikidataData[items,properties]

gives values for each of the properties for each of the items.

Details and Options

  • WikidataData retrieves data from Wikidata's SPARQL endpoint.
  • Each item and property can be specified as an ExternalIdentifier object, a URL or a raw Wikidata identifier like "Q15241057" or "P31".
  • Raw Wikidata identifiers are conventionally of the form "Qnnn" for items and "Pnnn" for properties.
  • The following properties are also supported:
  • "Label"the label of the item
    "Description"the description of the item
    "AlternativeLabels"alternate labels of the item
    "WikidataID"the ExternalIdentifier["WikidataID",] object corresponding to the item
    "Entity"entities corresponding to the item
  • Any type from $ExternalIdentifierTypes can be used as a property to request an ExternalIdentifier object of the specified type.
  • WikidataData[item,"Properties"] gives a list of all available properties for the specified item. Named subsets of available properties can be obtained with WikidataData[item,"sname"]. Possible values for "sname" include:
  • "IdentifierProperties"external identifier properties
    "NonIdentifierProperties"all properties excluding external identifier properties
  • An item can also be specified as Entity[].
  • An implicit list of items can be specified as EntityClass[type,{prop1vspec1,}], where type is an entity type or an ExternalIdentifier object, the propi are EntityProperty or ExternalIdentifier objects, and the vspeci are values or Boolean operators.
  • Supported Boolean operators include:
  • EqualTo[x]the value is equal to x
    UnequalTo[x]the value is unequal to x
    GreaterThan[x]the value is greater than x
    GreaterEqualThan[x]the value is greater than or equal to x
    LessThan[x]the value is less than x
    LessEqualThan[x]the value is less than or equal to x
    Between[{min,max}]the value is between min and max
    MissingQthere is no value for this property
    Not@*MissingQthere is a value for this property
  • EntityClass[type,rules] containing a single rule of the form propTakeLargest[n] or propTakeSmallest[n] is also supported.
  • WikidataData[itemspec,propspec] returns lists for each value, one additional level if itemspec is a list or is list-like and one additional level if propspec is a list or is list-like.
  • WikidataData[itemspec,propspec,"format"] can be used to modify the result format. Possible values for "format" include:
  • "Dataset"a Dataset in which the lowest level keys are the specified items and the second-lowest level keys are the specified properties
    "Association"a nested association in which the lowest level keys are the specified items and the selcond-lowest level keys are the specified properties
  • WikidataData[itemspec,pclass,"format"] includes all available properties from the specified property class pclass for each specified item. Possible value for pclass include:
  • Allall properties
    "IdentifierProperties"external identifier properties
    "NonIdentifierProperties"all properties excluding external identifier properties
  • The short form WikidataData[itemspec,"format"] is equivalent to WikidataData[itemspec,All,"format"].
  • The following options can be given:
  • Language $Languagewhat language to use
    Method Automaticwhich statements to select and which information to include in each statement
  • The setting for Language affects the "Label" and "Description" values of returned ExternalIdentifier objects.
  • In Method{opt1val1,}, the following suboptions opti can be given:
  • "StatementFormat""Value"what infromation to include for each statement
    "StatementRank""Best"which statements to include
  • Settings for "StatementFormat" include:
  • "Value"the value (default)
    "Association"an association including the value, qualifiers and references
    "Dataset"a Dataset including the value, qualifiers and references
    {"format","opt1"val1,}suboptions controlling what to include in an association or a dataset
    Allan association including the value, qualifiers and references
  • The following suboptions can be given:
  • "IncludeQualifiers"Automaticwhether to include qualifiers
    "IncludeReferences"Automaticwhether to include references
  • Settings for "StatementRank" include:
  • "Best"either normal-rank statements, if no preferred statement is available, or preferred statements otherwise (default)
    "Preferred"preferred statements
    "Normal"normal-rank statements
    "Deprecated"deprecated statements
    "NonDeprecated"normal-rank or preferred statements
    Allall statements

Examples

open allclose all

Basic Examples  (3)

Look up the mass of the Moon according to Wikidata:

Look up properties available for an item:

Retrieve values for multiple properties:

Retrieve all data available for an Entity and make a Dataset:

Scope  (2)

Look up data about a book specified by an ISBN:

Specify a class of lakes using an implicit EntityClass:

Retrieve the surface area for each lake:

Options  (3)

Language  (1)

Look up the label and description of a Wikidata item in the default language:

The default language is given by $Language:

Look up the label and description in Spanish:

Method  (2)

Look up the visitors per year of the Smithsonian:

Return an association including qualifiers and excluding references:

By default, only values of best rank are returned:

Include any non-deprecated value:

Include all values, including deprecated ones:

Applications  (1)

Retrieve life expectancy data, including references and date qualifiers:

Create TimeSeries objects for values claimed by UNESCO:

Plot the time series:

Wolfram Research (2020), WikidataData, Wolfram Language function, https://reference.wolfram.com/language/ref/WikidataData.html.

Text

Wolfram Research (2020), WikidataData, Wolfram Language function, https://reference.wolfram.com/language/ref/WikidataData.html.

CMS

Wolfram Language. 2020. "WikidataData." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WikidataData.html.

APA

Wolfram Language. (2020). WikidataData. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WikidataData.html

BibTeX

@misc{reference.wolfram_2023_wikidatadata, author="Wolfram Research", title="{WikidataData}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/WikidataData.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_wikidatadata, organization={Wolfram Research}, title={WikidataData}, year={2020}, url={https://reference.wolfram.com/language/ref/WikidataData.html}, note=[Accessed: 19-March-2024 ]}