Extension:Wikibase Client/Lua

Wikibase Client provides a Lua Scribunto interface that, if activated, can be used to access data from the Wikibase repository.

mw.wikibase
In  general Lua functionality for working with Wikibase data can be found.

mw.wikibase.getEntityObject
Gets a mw.wikibase.entity table with data of the Wikibase item requested by id. If no id was given, the item connected to the current page will be returned.

An example call might look like this:

mw.wikibase.label
Takes an item ID and returns the label in the language of the local Wiki.

An example call might look like this:

mw.wikibase.sitelink
Takes an item ID and returns the title of the corresponding page title on the local Wiki. This page title can be used to link to the given page.

An example call might look like this:

mw.wikibase.getEntity
Gets entity data of the Wikidata item connected with the current page. The returned object will have a legacy format, where tables are 0-based rather than 1-based. Also they will hold claims with both upper an lower case property ids (lower key property ids are deprecated).

Deprecated: Please use

mw.wikibase.entity
represents a Wikibase entity in Lua. A  table for the item which is linked with the current page can be obtained with.

Functions documented as  are available on the global   table; functions documented as   are methods of an   object (see  ).

mw.wikibase.entity:getLabel
Returns the label of the entity in the language given as  or in the Wiki's content language.

An example call might look like this:

mw.wikibase.entity:getSitelink
Get the title the entity is linked with in the current Wiki. If  is given, the title the item is linked with in the given Wiki will be returned.

An example call might look like this:

mw.wikibase.entity:getProperties
Get a table with all property ids attached to the item.

An example call might look like this:

mw.wikibase.entity:formatPropertyValues
Get the formatted value of the claims with the given property id. Per default only the best claims will be returned. Alternatively a table with acceptable ranks can be given as second parameter (a mapping table with all ranks can be found in ).

An example call might look like this:

mw.wikibase.entity.claimRanks
The  table contains a map of all available claim ranks.

The available ranks are:
 * 1) RANK_TRUTH
 * 2) RANK_PREFERRED
 * 3) RANK_NORMAL
 * 4) RANK_DEPRECATED

This can for example be used like this:

mw.wikibase.entity.create
Creates a new  object for the given entity data table. This function is only used for internal calls in the current state of the Lua integration.