---
title: "WikidataData"
language: "en"
type: "Symbol"
summary: "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."
canonical_url: "https://reference.wolfram.com/language/ref/WikidataData.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "People & History"
    link: "https://reference.wolfram.com/language/guide/PeopleAndHistory.en.md"
  - 
    title: "Knowledge Representation & Access"
    link: "https://reference.wolfram.com/language/guide/KnowledgeRepresentationAndAccess.en.md"
  - 
    title: "Listing of Supported External Services"
    link: "https://reference.wolfram.com/language/guide/ListingOfSupportedExternalServices.en.md"
related_functions: 
  - 
    title: "WikidataSearch"
    link: "https://reference.wolfram.com/language/ref/WikidataSearch.en.md"
  - 
    title: "ExternalIdentifier"
    link: "https://reference.wolfram.com/language/ref/ExternalIdentifier.en.md"
  - 
    title: "EntityValue"
    link: "https://reference.wolfram.com/language/ref/EntityValue.en.md"
  - 
    title: "Entity"
    link: "https://reference.wolfram.com/language/ref/Entity.en.md"
  - 
    title: "EntityProperty"
    link: "https://reference.wolfram.com/language/ref/EntityProperty.en.md"
  - 
    title: "WikipediaData"
    link: "https://reference.wolfram.com/language/ref/WikipediaData.en.md"
---
[EXPERIMENTAL]

# 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, {prop1 -> vspec1, …}]``, 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        |
| MissingQ            | there is no value for this property     |
| Not @* MissingQ     | there is a value for this property      |

* ``EntityClass[type, rules]`` containing a single rule of the form ``prop -> TakeLargest[n]`` or ``prop -> TakeSmallest[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:

|                           |                                                         |
| ------------------------- | ------------------------------------------------------- |
| All                       | all 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  | \$Language | what language to use                                                          |
| Method    | Automatic  | which 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 -> {opt1 -> val1, …}``, 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","Subscript[opt, 1]"->Subscript[val, 1],\[Ellipsis]}	suboptions controlling what to include in an association or a dataset
      	All	an association including the value, qualifiers and references

* The following suboptions can be given:

|                     |           |                               |
| ------------------- | --------- | ----------------------------- |
| "IncludeQualifiers" | Automatic | whether to include qualifiers |
| "IncludeReferences" | Automatic | whether 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 |
| All | all statements |

---

## Examples (9)

### Basic Examples (3)

Look up the mass of the Moon according to Wikidata:

```wl
In[1]:= WikidataData[ExternalIdentifier["WikidataID", "Q405", <|"Label" -> "Moon", "Description" -> "only natural satellite of Earth"|>], ExternalIdentifier["WikidataID", "P2067", <|"Label" -> "mass", "Description" -> "mass (in colloquial usage also known as weight) of the item"|>]]

Out[1]= {Quantity[73.4766999999999939064`4.04660570740846, "Yottagrams"]}
```

---

Look up properties available for an item:

```wl
In[1]:= WikidataData[ExternalIdentifier["WikidataID", "Q937", <|"Label" -> "Albert Einstein", "Description" -> "German-born physicist and founder of the theory of relativity"|>], "NonIdentifierProperties"]//Shallow

Out[1]//Shallow= {ExternalIdentifier["WikidataID", "P19", <|"Label" -> "place of birth", "Description" -> "most specific known (e.g. city instead of country, or hospital instead of city) birth location of a person, animal or fictional character"|>], ExternalIdentif ... arent\" (P3448)"|>], ExternalIdentifier["WikidataID", "P26", <|"Label" -> "spouse", "Description" -> "the subject has the object as their spouse (husband, wife, partner, etc.). Use \"unmarried partner\" (P451) for non-married companions"|>], «56»}
```

Retrieve values for multiple properties:

```wl
In[2]:= WikidataData[ExternalIdentifier["WikidataID", "Q937", <|"Label" -> "Albert Einstein", "Description" -> "German-born physicist and founder of the theory of relativity"|>], {ExternalIdentifier["WikidataID", "P1066", <|"Label" -> "student of", "Description" -> "person who has taught this person"|>], ExternalIdentifier["WikidataID", "P19", <|"Label" -> "place of birth", "Description" -> "most specific known (e.g. city instead of country, or hospital instead of city) birth location of a person, animal or fictional character"|>]}]

Out[2]= {{ExternalIdentifier["WikidataID", "Q116635", <|"Label" -> "Heinrich Friedrich Weber", "Description" -> "physicist (1843-1912)"|>]}, {ExternalIdentifier["WikidataID", "Q3012", <|"Label" -> "Ulm", "Description" -> "city in Baden-Württemberg"|>]}}
```

---

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

```wl
In[1]:= WikidataData[Entity["City", {"Munich", "Bavaria", "Germany"}], "Dataset"]

Out[1]= Dataset[«1»]
```

### Scope (2)

Look up data about a book specified by an ISBN:

```wl
In[1]:= WikidataData[ExternalIdentifier["ISBN10", "0-7167-0344-0"], {ExternalIdentifier["WikidataID", "P1476", <|"Label" -> "title", "Description" -> "published title of a work, such as a newspaper article, a literary work, a website, or a performance work"|>], ExternalIdentifier["WikidataID", "P50", <|"Label" -> "author", "Description" -> "main creator(s) of a written work (use on works, not humans); use P2093 when Wikidata item is unknown or does not exist"|>], ExternalIdentifier["WikidataID", "P577", <|"Label" -> "publication date", "Description" -> "date or point in time when a work was first published or released"|>], ExternalIdentifier["WikidataID", "P921", <|"Label" -> "main subject", "Description" -> "primary topic of a work (see also P180: depicts)"|>]}, "Association"]

Out[1]= <|ExternalIdentifier["WikidataID", "P1476", <|"Label" -> "title", "Description" -> "published title of a work, such as a newspaper article, a literary work, a website, or a performance work"|>] -> {"Gravitation"}, ExternalIdentifier["WikidataID", " ... escription" -> "primary topic of a work (see also P180: depicts)"|>] -> {ExternalIdentifier["WikidataID", "Q413", <|"Label" -> "physics", "Description" -> "study of matter and its motion, along with related concepts such as energy and force"|>]}|>
```

---

Specify a class of lakes using an implicit ``EntityClass`` :

```wl
In[1]:= lakes = EntityClass["Lake", {EntityProperty["Lake", "Countries"] -> Entity["Country", "Germany"], EntityProperty["Lake", "SurfaceArea"] -> TakeLargest[5]}];
```

Retrieve the surface area for each lake:

```wl
In[2]:= Median /@ WikidataData[lakes, EntityProperty["Lake", "SurfaceArea"], "Association"]

Out[2]= <|ExternalIdentifier["WikidataID", "Q161385", <|"Label" -> "Szczecin Lagoon", "Description" -> "estuary on the Polish-German border"|>] -> Quantity[903., "Kilometers"^2], ExternalIdentifier["WikidataID", "Q319041", <|"Label" -> "Obersee", "Descript ...  in Mecklenburg-Vorpommern, Germany"|>] -> Quantity[112.6, "Kilometers"^2], ExternalIdentifier["WikidataID", "Q4127", <|"Label" -> "Lake Constance", "Description" -> "lake in Germany, Switzerland and Austria"|>] -> Quantity[536., "Kilometers"^2]|>
```

### Options (3)

#### Language (1)

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

```wl
In[1]:= WikidataData["Q25269", {"Label", "Description"}]

Out[1]= {{"joule"}, {"derived unit of energy, work, or amount of heat in the International System of Units"}}
```

The default language is given by ``\$Language`` :

```wl
In[2]:= $Language

Out[2]= "English"
```

Look up the label and description in Spanish:

```wl
In[3]:= WikidataData["Q25269", {"Label", "Description"}, Language -> Entity["Language", "Spanish::77gfp"]]

Out[3]= {{"julio"}, {"unidad de energía, trabajo y calor del Sistema Internacional de Unidades"}}
```

#### Method (2)

Look up the visitors per year of the Smithsonian:

```wl
In[1]:= WikidataData[ExternalIdentifier["WikidataID", "Q131626", <|"Label" -> "Smithsonian Institution", "Description" -> "group of museums and research centers administered by the United States government"|>], ExternalIdentifier["WikidataID", "P1174", <|"Label" -> "visitors per year", "Description" -> "number of people visiting a location or an event each year"|>]]

Out[1]= {3.*^7}
```

Return an association including qualifiers and excluding references:

```wl
In[2]:= WikidataData[ExternalIdentifier["WikidataID", "Q131626", <|"Label" -> "Smithsonian Institution", "Description" -> "group of museums and research centers administered by the United States government"|>], ExternalIdentifier["WikidataID", "P1174", <|"Label" -> "visitors per year", "Description" -> "number of people visiting a location or an event each year"|>], Method -> {"StatementFormat" -> {"Association", "IncludeQualifiers" -> True, "IncludeReferences" -> False}}]

Out[2]= {<|"Value" -> 3.*^7, ExternalIdentifier["WikidataID", "P585", <|"Label" -> "point in time", "Description" -> "time and date something took place, existed or a statement was true"|>] -> {DateObject[{2012}, "Year", "Gregorian", 0.]}|>}
```

---

By default, only values of best rank are returned:

```wl
In[1]:= WikidataData[ExternalIdentifier["WikidataID", "Q1", <|"Label" -> "Universe", "Description" -> "totality consisting of space, time, mass and energy"|>], ExternalIdentifier["WikidataID", "P1419", <|"Label" -> "shape", "Description" -> "shape of an object"|>]]

Out[1]= {Missing["UnknownValue"]}
```

Include any non-deprecated value:

```wl
In[2]:= WikidataData[ExternalIdentifier["WikidataID", "Q1", <|"Label" -> "Universe", "Description" -> "totality consisting of space, time, mass and energy"|>], ExternalIdentifier["WikidataID", "P1419", <|"Label" -> "shape", "Description" -> "shape of an object"|>], Method -> {"StatementRank" -> "NonDeprecated"}]

Out[2]= {ExternalIdentifier["WikidataID", "Q5457948", <|"Label" -> "flatness", "Description" -> "in cosmology, an absence of curvature of space"|>], Missing["UnknownValue"]}
```

Include all values, including deprecated ones:

```wl
In[3]:= WikidataData[ExternalIdentifier["WikidataID", "Q1", <|"Label" -> "Universe", "Description" -> "totality consisting of space, time, mass and energy"|>], ExternalIdentifier["WikidataID", "P1419", <|"Label" -> "shape", "Description" -> "shape of an object"|>], Method -> {"StatementRank" -> All}]

Out[3]= {Missing["UnknownValue"], ExternalIdentifier["WikidataID", "Q209306", <|"Label" -> "hyperbolic geometry", "Description" -> "non-Euclidean geometry"|>], ExternalIdentifier["WikidataID", "Q326905", <|"Label" -> "spherical geometry", "Description" -> "geometry of the two-dimensional surface of a sphere"|>], ExternalIdentifier["WikidataID", "Q5457948", <|"Label" -> "flatness", "Description" -> "in cosmology, an absence of curvature of space"|>]}
```

### Applications (1)

Retrieve life expectancy data, including references and date qualifiers:

```wl
In[1]:= lifeExp = WikidataData[{ExternalIdentifier["WikidataID", "Q298", <|"Label" -> "Chile", "Description" -> "republic in South America"|>], ExternalIdentifier["WikidataID", "Q414", <|"Label" -> "Argentina", "Description" -> "federal republic in South America"|>], ExternalIdentifier["WikidataID", "Q77", <|"Label" -> "Uruguay", "Description" -> "republic in South America"|>]}, ExternalIdentifier["WikidataID", "P2250", <|"Label" -> "life expectancy", "Description" -> "life expectancy for this group or species"|>], "Association", Method -> {"StatementRank" -> "NonDeprecated", "StatementFormat" -> All}];
```

Create ``TimeSeries`` objects for values claimed by UNESCO:

```wl
In[2]:=
TimeSeries /@ Cases[KeyValuePattern[{
	"References" -> _ ? (MemberQ[
	KeyValuePattern[ExternalIdentifier["WikidataID", "P248", <|"Label" -> "stated in", "Description" -> "to be used in the references field to refer to the information document or database in which a claim is made; for qualifiers use P805; for the type of document in which a claim is made use P3865"|>] -> {ExternalIdentifier["WikidataID", "Q3152127", <|"Label" -> "UNESCO Institute for Statistics", "Description" -> "international organization"|>]}]]), 
	ExternalIdentifier["WikidataID", "P585", <|"Label" -> "point in time", "Description" -> "date something took place, existed or a statement was true; for providing time use the \"refine date\" property (P4241)"|>] -> {date_}, 
	"Value" -> value_
	}] :> {date, value}] /@ lifeExp

Out[2]=
<|ExternalIdentifier["WikidataID", "Q298", <|"Label" -> "Chile", "Description" -> "republic in South America"|>] -> TemporalData[TimeSeries, 
 {{QuantityArray[StructuredArray`StructuredData[{18}, 
     {{76.533, 76.793, 77.034, 77.255, 77.453, 77.6 ...   {TemporalData`DateSpecification[{1999, 1, 1, 1, 0, 0}, {2016, 1, 1, 1, 0, 0}, {1, "Year"}]}, 1, 
  {"Continuous", 1}, {"Discrete", 1}, 1, 
  {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, ValueDimensions -> 1}}, True, 
 14.1]|>
```

Plot the time series:

```wl
In[3]:= DateListPlot[%]

Out[3]= [image]
```

## See Also

* [`WikidataSearch`](https://reference.wolfram.com/language/ref/WikidataSearch.en.md)
* [`ExternalIdentifier`](https://reference.wolfram.com/language/ref/ExternalIdentifier.en.md)
* [`EntityValue`](https://reference.wolfram.com/language/ref/EntityValue.en.md)
* [`Entity`](https://reference.wolfram.com/language/ref/Entity.en.md)
* [`EntityProperty`](https://reference.wolfram.com/language/ref/EntityProperty.en.md)
* [`WikipediaData`](https://reference.wolfram.com/language/ref/WikipediaData.en.md)

## Related Guides

* [People & History](https://reference.wolfram.com/language/guide/PeopleAndHistory.en.md)
* [Knowledge Representation & Access](https://reference.wolfram.com/language/guide/KnowledgeRepresentationAndAccess.en.md)
* [Listing of Supported External Services](https://reference.wolfram.com/language/guide/ListingOfSupportedExternalServices.en.md)

## History

* [Introduced in 2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md)