Wikidata:How to use data on Wikimedia projects

From Wikidata
(Redirected from Wikidata:Arbitrary access)
Jump to: navigation, search

Other languages:
English • ‎français • ‎Bahasa Indonesia • ‎italiano • ‎日本語 • ‎русский

Data from Wikidata can be directly displayed on Wikimedia projects, with different methods. With the parser function or Lua code, it is possible to display labels, descriptions, values, references, and a lot of other information stored on Wikidata.

On this page, you will learn how to use Wikidata data on your wiki. You can also learn more about what is Wikidata, how the information is organized, or browse the glossary.


Can I access Wikidata data from my wiki?[edit]

The two main client functionalities, parser function and access via Lua, can be enabled together on the wikis of the Wikimedia projects. This is the case for almost all Wikimedia projects now.

To check if these functionalities are activated on a wiki, you can access the page Special:Version. In the section "parser functions", if "statements" appears in the list, that means that you can use it on this wiki.

The access to Wikidata data is currently restricted to the Wikimedia projects, because of technical limitations. If you have your own instance of Mediawiki, you can't use Wikidata data's using these features. However you can set up your own Wikibase instance and use data from there in the same way.

Parser function[edit]

The first way to access data is to use the #statements parser function. This function will allow you to display the value of any statement included in an item.

Diagram of a Wikidata datamodel.

Direct access[edit]

On a page that is connected to a Wikidata item via the interwikilinks, you can use the function by adding the label of the property you want in your language or the P-number of the property. The code has to be added in the wikicode.

Examples:

  • {{#statements:member of political party}} or {{#statements:P102}} will return the "member of political party" value.
  • {{#statements:discoverer or inventor}} or {{#statements:P61}} will return the "discoverer or inventor" value.
  • On :en:w:Douglas Adams, the code {{#statements:country of citizenship}} will display "United Kingdom".


Arbitrary access[edit]

You can also display data from an item that is not connected via an interwikilink. For this, you use the same function, adding a parameter from= followed by the Q-id of the item.

Examples:

  • {{#statements:birth name|from=Q42}} will display "Douglas Noel Adams"
  • {{#statements:country of citizenship|from=Q42}} will display "United Kingdom".
  • {{#statements:P1476|from=Q191380}} will display "Notre-Dame de Paris"
  • {{#statements:author|from=Q191380}} will display "Victor Hugo"
  • {{#statements:publication date|from=Q191380}} will display "14 January 1831"


Multiple values[edit]

When a statements has multiple values, the parser function will show the "best" value, which means:

Example: {{#statements:occupation|from=Q42}} displays "playwright, screenwriter, novelist, children's writer, science fiction writer, comedian" (there are other occupations in Douglas Adams (Q42) but only some are preferred)


Formatted values[edit]

For some properties, the #statements parser function will display the value in a specific format.


Commons images

The parser function displays a thumbnail preview of the image, resizing it to 200 pixels. It links to the Wikimedia Commons file description page.

{{#statements:image|from=Q42}} displays

Douglas adams portrait cropped.jpg


Geo coordinates

The parser function displays the coordinates in degree-minute-second format.

{{#statements:coordinate location|from=Q243}} displays 48°51'28.8"N, 2°17'43.1"E


Monolingual text

The parser function displays the string, annotated with the language.

{{#statements:motto text|from=Q95}} displays "Do the right thing".


Date

The date value will be formatted in day-month-year format.

{{#statements:date of birth|from=Q42}} displays 11 March 1952


Links

The links are clickable.

{{#statements:official website|from=Q243}} displays http://www.toureiffel.paris


External IDs

An external ID will provide a direct link to the external website.

{{#statements:IMDb ID|from=Q42}} displays nm0010930

Items


Modules[edit]

Data can also be accessed with Lua modules, which are much more flexible. For more information on using modules, please see w:Module:Wikidata#Usage.

There are two kinds of Wikidata modules which are able to deal with Wikidata: take a look at Module:Wikidata (Q12069631) and Module:Wikidata2 (Q25936424). Your home wiki may have a module in one of these two lists.


Templates[edit]

Some templates use modules to access Wikidata data. They are as simple to use as regular templates. Moreover, using Wikidata, some parameters become unnecessary. For instance, some infoboxes are able to retrieve data from Wikidata, so you just have to insert the template and all the data will magically appear (if the needed information is present on the Wikidata item, of course). For templates using Wikidata see Category:Templates using data from Wikidata (Q11985372).

If you want to create a template on your wiki, check your documentation page about Module:Wikidata and already existing templates.


Lists[edit]

Regularly updated lists[edit]

Daily updated lists based on SPARQL queries can be configured using Template:Wikidata list (Q19860885). Content is replaced daily.

There are essentially two uses:

  • Work lists: lists with topics to be covered in project namespace. Results can be limited to topics that don't exist.
  • Reference list: lists for a specific topic in article namespace.

This is currently the most efficient way of doing lists.


Dynamic lists[edit]

Content is displayed from various items based on a selection done in a LUA module.


Manual lists[edit]

A series of items are selected and their properties displayed in an article. Content from Wikidata can be completed with locally edited text.


Examples of use cases[edit]

Magic infobox[edit]

Commons[edit]

Commons creator template uses Wikidata with arbitrary access to provide information about the creators of the works.


Graph[edit]

Authority model[edit]

Wikisource[edit]

How to find help ?[edit]

You will find contributors on the Wikidata project chat which exists in different languages. Moreover, some wikis have projects dedicated to Wikidata : see Wikipedia:WikiProject Wikidata (Q20855878).