import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
site = pywikibot.Site('en', 'wikipedia')  # any site will work, this is just an example
page = pywikibot.Page(site, 'Douglas Adams')
item = pywikibot.ItemPage.fromPage(page)  # this can be used for any page object
# you can also define an item like this
repo = site.data_repository()  # this is a DataSite object
item = pywikibot.ItemPage(repo, 'Q42')  # 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 item.claims:
    if 'P31' in item.claims: # instance of
        print(item.claims['P31'][0].getTarget())
        print(item.claims['P31'][0].sources[0])  # let's just assume it has sources.
The label in English is: Douglas Adams
[[wikidata:Q5]]
OrderedDict([('P248', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P248', 'datatype': 'wikibase-item', 'datavalue': {'value': {'entity-type': 'item', 'numeric-id': 54919}, 'type': 'wikibase-entityid'}, 'hash': '2b369d0a4f1d4b801e734fe84a0b217e13dd2930'})]), ('P214', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P214', 'datatype': 'external-id', 'datavalue': {'value': '113230702', 'type': 'string'}, 'hash': '2b369d0a4f1d4b801e734fe84a0b217e13dd2930'})]), ('P813', [Claim.fromJSON(DataSite("wikidata", "wikidata"), {'snaktype': 'value', 'property': 'P813', 'datatype': 'time', 'datavalue': {'value': {'time': '+00000002013-12-07T00:00:00Z', 'precision': 11, 'after': 0, 'before': 0, 'timezone': 0, 'calendarmodel': 'http://www.wikidata.org/entity/Q1985727'}, 'type': 'time'}, 'hash': '2b369d0a4f1d4b801e734fe84a0b217e13dd2930'})])])