From Wikidata
Jump to navigation Jump to search
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules

This module provides an as simple as possible infobox system based on Wikidata.

It is fully automated, does not require any configuration to be used and does not have any declination based on the type of entity (person, place...).

How does it work?[edit]

This module is the backend code of the Databox template.

It uses the Wikidata item linked to the current page or the item which id is filled into the item parameter to automatically build an infobox.

Its basic algorithm is:

  • Use the label of the item or, if none exists, the title of the page for the infobox title.
  • Use the value of image (P18) for the main image.
  • Use the value(s) of instance of (P31) for the data table title.
  • Take all the properties used by the item, sort them according to MediaWiki:Wikibase-SortedProperties, and for each one:
    • If the property has the datatype External identifier, Commons media file or Quantity[a 1], do not display anything.
    • If the property is in the property_blacklist array of the module, do not display anything (it is done in order to filter properties not very relevant for displaying in infoboxes).
    • If the property has more than 5 values do not display anything (to avoid long lists in the infobox).
    • Use default Wikibase rendering system to display the values that have the "best" rank (i.e. the values with the rank "preferred", if some exists, and, if not, the ones with the rank "normal").
  • If there is value for coordinate location (P625), then display a map using Kartographer.


  1. The current display of quantities by Wikibase is very limited, this filter should be removed after improvements

How to use it in your wiki?[edit]

  1. Copy the code of Module:Databox in a module page in your wiki named Module:Databox.
  2. Add the created module page to the sitelinks of Q53931871.
  3. Create Template:Databox in your wiki with the wikitext: {{#invoke:Databox|databox}}.
  4. Add the created template page to the sitelinks of Q20702632.
  5. At this point if you add {{Databox}} to an existing article connected to a Wikidata item it should work.
  6. Write an help page in your language


Popularity of name Lucy.svg
female given name
Part ofLucy Edit
Native labelLucy Edit
Language of work or nameEnglish, Dutch Edit
Writing systemLatin script Edit
IPA transcriptionˈluːsi Edit
SoundexL200 Edit
Cologne phonetics58 Edit
CaverphoneLS1111 Edit
Name dayDecember 13 Edit
Family name identical to this given nameLucy Edit
Given name version for other genderLucius Edit
Attested infrequency of first names in the Netherlands, 2010 Edit
chemical compound, Class IB flammable liquid, medication, alkanol
Has effectethanol exposure, intoxication Edit
Conjugate baseethoxide Edit
Chemical formulaC₂H₆O Edit
Canonical SMILESCCO Edit
Crystal systemmonoclinic crystal system Edit
Point groupmonoclinic-domatic Edit
Space groupspace group 7 Edit
Safety classification and labellingNFPA 704: Standard System for the Identification of the Hazards of Materials for Emergency Response, Regulation (EC) No. 1272/2008 Edit
UN class3 Edit
UN packaging groupII Edit
Found in taxonHomo sapiens, Malus domestica Edit
Physically interacts with5-hydroxytryptamine (serotonin) receptor 3A, Potassium inwardly-rectifying channel, subfamily J, member 3, Potassium inwardly-rectifying channel, subfamily J, member 5 Edit
Usepolar protic solvent Edit
Has qualityhygroscopy Edit
Subject has rolesolvent, local anti-infective agent, depressant Edit
World Health Organisation International Nonproprietary NameAlcohol, Rubbing Edit
NCI Thesaurus IDC2190 Edit
NIOSH Pocket Guide ID0262 Edit
Hubble Space Telescope
Hubble 01.jpg
space observatory
Part ofGoddard Space Flight Center Edit
Native labelHubble Space Telescope Edit
Named afterEdwin Hubble Edit
Significant eventrocket launch, atmospheric entry Edit
Start pointKennedy Space Center Launch Complex 39 Edit
VehicleDiscovery Edit
OperatorNASA, European Space Agency Edit
UTC date of spacecraft launch24 April 1990 Edit
Time of spacecraft orbit decay2030 Edit
Parent astronomical bodyEarth Edit
Type of orbitlow Earth orbit Edit
ManufacturerPerkinElmer, Lockheed Missiles and Space Company Edit
Official website Edit
Source of energysolar panels on spacecraft Edit
4 Vesta
Named afterVesta Edit
Follows3 Juno Edit
Followed by5 Astraea Edit
Significant eventnaming Edit
Discoverer or inventorHeinrich Wilhelm Olbers Edit
Time of discovery or invention29 March 1807 Edit
Site of astronomical discoveryBremen Edit
Minor planet groupasteroid belt Edit
Parent astronomical bodySun Edit
Asteroid familyVesta family Edit
Asteroid spectral typeV-type asteroid Edit
Unicode character Edit
Ephesians 2,12 - Greek atheos.jpg
world view, philosophical movement
Subclass ofirreligion Edit
Has qualityunbelief Edit
Opposite oftheism Edit
Practiced byatheist Edit
LEM IDLEM201001042 Edit
Iron Man
TitleIron Man Edit
Based onIron Man Edit
Part of the seriesIron Man film series, Marvel Cinematic Universe, Marvel Cinematic Universe Phase One: Avengers Assembled, Marvel Cinematic Universe: The Infinity Saga Edit
Genreaction film, science fiction film, adventure film, superhero film Edit
Has edition or translationIron Man Edit
PerformerLauren Scyphers, Stacy Stas Hurst Edit
Country of originUnited States of America Edit
Original language of film or TV showEnglish Edit
Publication date2 May 2008, 30 April 2008, 30 April 2008, 1 May 2008 Edit
Significant eventprincipal photography, première Edit
DirectorJon Favreau Edit
ScreenwriterMark Fergus, Hawk Ostby, Art Marcum, Matt Holloway Edit
Director of photographyMatthew Libatique Edit
Film editorDan Lebental Edit
Production designerJ. Michael Riva Edit
Costume designerLaura Jean Shannon, Rebecca Bentjen Edit
ComposerRamin Djawadi Edit
ProducerAvi Arad, Kevin Feige Edit
Production companyMarvel Studios, Fairview Entertainment Edit
Distributed byParamount Pictures, UIP-Dunafilm, Sony Pictures Edit
Soundtrack releaseIron Man Edit
Narrative locationAfghanistan, Los Angeles, Kunar Edit
Aspect ratio2.39:1 Edit
Colorcolor Edit
Review score94%, 79/100 Edit
Takes place in fictional universeMarvel Cinematic Universe Edit
CharactersPhil Coulson Edit
BBFC rating12A certificate Edit
ClassInd category12 Edit
CNC film rating (France)no age restriction (U) Edit
Filmiroda ratingCategory II Edit
FSK film ratingFSK 12 Edit
ICAA ratingNot recommended for children under 7 Edit
JMK film ratingfree from 12 years Edit
Kijkwijzer rating12 Edit
MPAA film ratingPG-13 Edit
RTC film ratingB Edit
Official website Edit
Has qualityfails the Bechdel Test, passes the reverse Bechdel Test Edit
Described at URL Edit
RCQ classificationG Edit
Medierådet ratingFor ages 11 and up Edit
Airbus basic
Airbus Lagardère - Aéroconstellation.jpg
aerospace manufacturer, business, enterprise
Part ofCAC 40, EURO STOXX 50, MDAX Edit
Industryaerospace industry, arms industry, aviation industry, Q56314771 Edit
Inception18 December 1969 Edit
Official nameAirbus SE Edit
Founded byRoger Béteille, Felix Kracht, Henri Ziegler, Franz Josef Strauß Edit
Chief executive officerTom Enders Edit
Director / managerGuillaume Faury Edit
Motto textWe make it fly Edit
CountryFrance, Germany, United Kingdom Edit
Member ofAerospace Valley, GIFAS, Linux Foundation, CVE Numbering Authorities Edit
Legal formSocietas Europaea, Société par actions simplifiée Edit
Location of formationFrance Edit
Parent organizationAirbus Group Edit
Owner ofAtlas Elektronik, Airbus Military, Airbus Corporate Jets, Airbus Training Centre Europe Edit
Headquarters locationBlagnac, Toulouse Edit
IPv6 routing prefix2a00:6fc0:10::/44, 2a00:6fc0:690::/44, 2a00:6fc0:c010::/44 Edit
Official website Edit
History of topicHistory of Airbus Edit
planned language, international auxiliary language, agglutinative language, a posteriori language, constructed language, modern language
Inception26 July 1887 Edit
Native labelEsperanto Edit
Named afterDoktoro Esperanto Edit
MovementEsperanto movement Edit
AnthemLa Espero Edit
CultureEsperanto culture Edit
Location of formationWarsaw Edit
Studied byEsperantology, interlinguistics Edit
Foundational textUnua Libro Edit
FollowsProto-Esperanto Edit
ReplacesVolapük Edit
CreatorL. L. Zamenhof Edit
Country of originRussian Empire, Poland Edit
Significant eventWorld Esperanto Congress 1905, World Esperanto Congress 1987 Edit
Linguistic typologyfree-order language, nominative–accusative language, agglutinative language, isolating language, subject–verb–object Edit
Has grammatical caseaccusative case, nominative case Edit
Has tensepresent tense, past tense, future tense Edit
Has grammatical moodinfinitive, conditional, jussive mood Edit
Writing systemLatin script Edit
Language regulatory bodyAcademy of Esperanto Edit
Signed formSignuno Edit
Ethnologue language status3 Wider Communication Edit
IPA transcriptiones.peˈ Edit
Discoverer or inventorL. L. Zamenhof Edit
Usesecond language, lingua franca Edit
HashtagEsperanto Edit
Flagflag of Esperanto Edit
Used byEsperantist Edit
History of topichistory of Esperanto Edit
IRC channelirc:// Edit
LEM IDLEM201200583 Edit
ISOCAT id659 Edit
Wikimedia language codeeo Edit
Stack Exchange site Edit
Related categoryCategory:Esperanto pronunciation Edit
Category for mapsCategory:Maps in Esperanto Edit
Cityscape Berlin.jpg
state of Germany
Part ofBerlin/Brandenburg Metropolitan Region, agglomeration of Berlin Edit
Inception1237 Edit
Official nameBerlin Edit
Native labelBerlin Edit
Short nameB Edit
Official languageGerman Edit
CountryGermany Edit
Capital ofGermany Edit
Located in the administrative territorial entityGermany Edit
Enclave withinBrandenburg Edit
Coordinate location52°31′0″N 13°23′0″E Edit
Highest pointArkenberge Edit
Office held by head of governmentGoverning Mayor of Berlin Edit
Head of governmentMichael Müller Edit
Legislative bodyAbgeordnetenhaus of Berlin Edit
Highest judicial authorityConstitutional Court of the State of Berlin Edit
Member ofClimate Alliance, Mayors for Peace, IT-Planungsrat Edit
Public holidayInternational Women's Day Edit
Located in time zoneEurope/Berlin Edit
Archives atLandesarchiv Berlin Edit
ReplacesAlt-Berlin, East Berlin Edit
Significant eventQ821430, Fall of the Berlin Wall, Battle of Berlin, Soviet Airstrike Against Berlin in 1941 Edit
Award receivedPrincess of Asturias Award for Concord Edit
IPA transcriptionbɛɐ̯ˈliːn Edit
Connects withEuropean route E55 Edit
Postal code10115–14199 Edit
Official website Edit
Flagflag of Berlin Edit
Coat of armscoat of arms of Berlin Edit
Geography of topicgeography of Berlin Edit
History of topichistory of Berlin Edit
Time of earliest written record1237, 1244 Edit
Local dialing code030 Edit
Licence plate codeB Edit
Open Data portalBerlin Open Data, Berlin Open Data Edit
Category for mapsCategory:Maps of Berlin Edit
Douglas Adams
Douglas adams portrait cropped.jpg
Sex or gendermale Edit
Country of citizenshipUnited Kingdom Edit
Name in native languageDouglas Adams Edit
Birth nameDouglas Noël Adams Edit
Given nameDouglas Edit
Family nameAdams Edit
Date of birth11 March 1952 Edit
Place of birthCambridge Edit
Date of death11 May 2001 Edit
Place of deathSanta Barbara Edit
Manner of deathnatural causes Edit
Cause of deathmyocardial infarction Edit
Place of burialHighgate Cemetery Edit
FatherChristopher Douglas Adams Edit
MotherJanet Adams Edit
SiblingSusan Adams Edit
SpouseJane Belson Edit
ChildPolly Adams Edit
Native languageBritish English Edit
Languages spoken, written or signedBritish English Edit
Writing languagesEnglish Edit
EmployerBritish Broadcasting Corporation Edit
Member ofFootlights Edit
Educated atSt John's College, Brentwood School Edit
ResidenceLondon, Brentwood Edit
Ethnic groupEnglish people Edit
Instrumentguitar Edit
Archives atSt John's College Library Edit
Genrescience fiction, comedy, satire Edit
Nominated forHugo Award for Best Dramatic Presentation, Locus Award for Best Science Fiction Novel Edit
Official website Edit
Interested inaquatic ape hypothesis Edit

See also[edit]


local property_blacklist = {
    'P360', --is a list of
    'P4224', --category contains
    'P935', -- Commons gallery
    'P1472', -- Commons Creator page
    'P1612', -- Commons Institution page
    'P373', -- Commons category
    'P3722', -- Commons maps category
    'P1151', -- topic's main Wikimedia portal
    'P1424', -- topic's main template
    'P910', -- topic's main category
    'P1200', -- bodies of water basin category
    'P1792', -- category of associated people
    'P1464', -- category for people born here
    'P1465', -- category for people who died here
    'P1791', -- category of people buried here
    'P1740', -- category for films shot at this location
    'P2033', -- Category for pictures taken with camera
    'P2517', -- category for recipients of this award
    'P4195', -- category for employees of the organization
    'P1754', -- category related to list
    'P301', -- category's main topic
    'P971', -- category combines topics
    'P3876', -- category for alumni of educational institution
    'P1753', -- list related to category
    'P3921', -- Wikidata SPARQL query equivalent
    'P1204', -- Wikimedia portal's main topic
    'P1423', -- template's main topic
    'P1709', -- equivalent class
    'P3950', -- narrower external class
    'P2888', -- exact match
    'P1382', -- coincident with
    'P527', -- has part
    'P2670', -- has parts of the class
    'P3113', -- does not have part
    'P2737', -- union of
    'P2738', -- disjoint union of
    'P2445', -- metasubclass of
    'P1963', -- properties for this type
    'P3176', -- uses property
    'P1889', -- different from
    'P460', -- said to be the same as
    'P2959', -- permanent duplicated item
    'P2860', -- cites
    'P5125', -- wikimedia outline
    'P5008', -- on focus list of Wikimedia project
    'P2559', -- Wikidata usage instructions
    'P1343', -- described by source
    'P972', --  catalogu
    'P1282', -- OSM tag or key
    'P4839', -- Wolfram Language entity code
    'P6104', -- Maintained by Wikiproject
    'P5996' -- Category for films in this language

function valuesToKeys(array)
	local result = {}
	for _, v in pairs(array) do
		result[v] = true
	return result

local p = {}

function p.databox(frame)
    local args = frame:getParent().args
    local itemId = nil
    if args.item then
        itemId = args.item
    local lang = mw.language.getContentLanguage()
    local item = mw.wikibase.getEntity(itemId)
    if item == nil then
        mw.addWarning("Wikidata item not found")
        return ""
    local databoxRoot = mw.html.create('div')
            float = 'right',
            border = '1px solid #aaa',
            ['max-width'] = '300px',
            padding = '0 0.4em',
            margin = '0 0 0.4em 0.4em',

            ['text-align'] = 'center',
            ['background-color'] = '#f5f5f5',
            padding = '0.5em 0',
            margin = '0.5em 0',
            ['font-size'] = '120%',
            ['font-weight'] = 'bold',
        :wikitext(item:getLabel() or mw.title.getCurrentTitle().text)

    local images = item:getBestStatements('P18')
    if #images == 1 then
            :wikitext('[[File:' .. images[1].mainsnak.datavalue.value .. '|frameless|300px]]')

    local dataTable = databoxRoot
            ['text-align'] = 'left',
            ['font-size'] = '90%',
            ['word-break'] = 'break-word',
            ['width'] = '100%',
            ['table-layout'] = 'fixed',
             	['background-color'] = '#f5f5f5',
             	['font-weight'] = 'bold',
             	['margin-top'] = '0.2em',
    local properties = mw.wikibase.orderProperties(item:getProperties())
    local property_blacklist_hash = valuesToKeys(property_blacklist)
    property_blacklist_hash['P31'] = true --Special property

	local edit_message ='vector-view-edit'):plain()
    for _, property in pairs(properties) do
        local datatype =[property][1].mainsnak.datatype
        if datatype ~= 'commonsMedia' and datatype ~= 'external-id' and datatype ~= 'quantity' and datatype ~= 'wikibase-property' and datatype ~= 'geo-shape' and datatype ~= 'tabular-data' and not property_blacklist_hash[property] and #item:getBestStatements(property) <= 5 then
            local propertyValue = item:formatStatements(property)
                    :attr('scope', 'row')
                    :wikitext('&nbsp;[[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=' .. .. '#' .. property .. ']]')
    local coordinates_statements = item:getBestStatements('P625')
    if #coordinates_statements == 1 and coordinates_statements[1].mainsnak.datavalue and coordinates_statements[1].mainsnak.datavalue.value.globe == '' then
        --We build the call to mapframe
        local latitude = coordinates_statements[1].mainsnak.datavalue.value.latitude
        local longitude = coordinates_statements[1].mainsnak.datavalue.value.longitude
        local geojson = {
            type = 'Feature',
            geometry = {
                type = 'Point',
                coordinates = { longitude, latitude }
            properties = {
                title = item:getLabel() or mw.title.getCurrentTitle().text,
                ['marker-symbol'] = 'marker',
                ['marker-color'] =  '#224422',
        databoxRoot:wikitext(frame:extensionTag('mapframe', mw.text.jsonEncode(geojson), {
            height = 300,
            width = 300,
            frameless = 'frameless',
            align = 'center',
            latitude = latitude,
            longitude = longitude,
            zoom = zoom
     return tostring(databoxRoot)

return p