import mwapi
session = mwapi.Session('https://test.wikidata.org')
print(session.get(action='query', meta='userinfo'))
{'query': {'userinfo': {'anon': '', 'name': 'Jtmorgan', 'id': 0}},
 'batchcomplete': ''}