In [6]:
import pywikibot
site = pywikibot.Site('wikidata', 'wikidata')  # any site will work, this is just an example

repo = site.data_repository()  # this is a DataSite object
item = pywikibot.ItemPage(repo, 'Q219')  # This will be functionally the same as the other item we defined
item.get()  # you need to call it to access any data.
sitelinks = item.sitelinks
aliases = item.aliases
if 'en' in item.labels:
    print('The label in English is: ' + item.labels['en'])
    if 'P2131' in # instance of
        print(['P2131'][0].sources)  # let's just assume it has sources.
The label in English is: Bulgaria
    "amount": "+19870000000",
    "lowerBound": null,
    "unit": "",
    "upperBound": null
[OrderedDict([('P854', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P854', 'datatype': 'url', 'datavalue': {'value': '', 'type': 'string'}, 'hash': '039ceb988a097547a41a49cc732d1f19635d72c3'})]), ('P813', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P813', 'datatype': 'time', 'datavalue': {'value': {'time': '+00000002018-10-21T00:00:00Z', 'precision': 11, 'after': 0, 'before': 0, 'timezone': 0, 'calendarmodel': ''}, 'type': 'time'}, 'hash': '039ceb988a097547a41a49cc732d1f19635d72c3'})]), ('P248', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P248', 'datatype': 'wikibase-item', 'datavalue': {'value': {'entity-type': 'item', 'numeric-id': 21540096}, 'type': 'wikibase-entityid'}, 'hash': '039ceb988a097547a41a49cc732d1f19635d72c3'})]), ('P275', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P275', 'datatype': 'wikibase-item', 'datavalue': {'value': {'entity-type': 'item', 'numeric-id': 20007257}, 'type': 'wikibase-entityid'}, 'hash': '039ceb988a097547a41a49cc732d1f19635d72c3'})])])]
In [ ]:
In [ ]: