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