mwclient/client.py
def api(self, action, *args, **kwargs):
        """
        Perform a generic API call and handle errors. All arguments will be passed on.

        Example:
            To get coordinates from the GeoData MediaWiki extension at English Wikipedia:

            >>> site = Site('en.wikipedia.org')
            >>> result = site.api('query', prop='coordinates', titles='Oslo|Copenhagen')
            >>> for page in result['query']['pages'].values():
            ...     if 'coordinates' in page:
            ...         print page['title'], page['coordinates'][0]['lat'], page['coordinates'][0]['lon']
            Oslo 59.95 10.75
            Copenhagen 55.6761 12.5683

        Returns:
            The raw response from the API call, as a dictionary.
        """
        kwargs.update(args)

        if 'continue' not in kwargs:
            kwargs['continue'] = ''
        if action == 'query':
            if 'meta' in kwargs:
                kwargs['meta'] += '|userinfo'
            else:
                kwargs['meta'] = 'userinfo'
            if 'uiprop' in kwargs:
                kwargs['uiprop'] += '|blockinfo|hasmsg'
            else:
                kwargs['uiprop'] = 'blockinfo|hasmsg'

        token = self.wait_token()
        while True:
            info = self.raw_api(action, **kwargs)
            if not info:
                info = {}
            res = self.handle_api_result(info, token=token)
            if res:
                return info

        Perform a generic API call and handle errors. All arguments will be passed on.

        Example:
            To get coordinates from the GeoData MediaWiki extension at English Wikipedia:

            >>> site = Site('en.wikipedia.org')
            >>> result = site.api('query', prop='coordinates', titles='Oslo|Copenhagen')
            >>> for page in result['query']['pages'].values():
            ...     if 'coordinates' in page:
            ...         print page['title'], page['coordinates'][0]['lat'], page['coordinates'][0]['lon']
            Oslo 59.95 10.75
            Copenhagen 55.6761 12.5683

        Returns:
            The raw response from the API call, as a dictionary.
        
Perform a generic API call and handle errors. All arguments will be passed on.
Perform a generic API call and handle errors . All arguments will be passed on .
def api(self, action, *args, **kwargs):
        kwargs.update(args)
        if 'continue' not in kwargs:
            kwargs['continue'] = ''
        if action == 'query':
            if 'meta' in kwargs:
                kwargs['meta'] += '|userinfo'
            else:
                kwargs['meta'] = 'userinfo'
            if 'uiprop' in kwargs:
                kwargs['uiprop'] += '|blockinfo|hasmsg'
            else:
                kwargs['uiprop'] = 'blockinfo|hasmsg'
        token = self.wait_token()
        while True:
            info = self.raw_api(action, **kwargs)
            if not info:
                info = {}
            res = self.handle_api_result(info, token=token)
            if res:
                return info
def api ( self , action , * args , ** kwargs ) : kwargs . update ( args ) if 'continue' not in kwargs : kwargs [ 'continue' ] = '' if action == 'query' : if 'meta' in kwargs : kwargs [ 'meta' ] += '|userinfo' else : kwargs [ 'meta' ] = 'userinfo' if 'uiprop' in kwargs : kwargs [ 'uiprop' ] += '|blockinfo|hasmsg' else : kwargs [ 'uiprop' ] = 'blockinfo|hasmsg' token = self . wait_token ( ) while True : info = self . raw_api ( action , ** kwargs ) if not info : info = { } res = self . handle_api_result ( info , token = token ) if res : return info
Perform a generic API call and handle errors.
Perform a generic API call and handle errors .
"""
        Perform a generic API call and handle errors. All arguments will be passed on.

        Example:
            To get coordinates from the GeoData MediaWiki extension at English Wikipedia:

            >>> site = Site('en.wikipedia.org')
            >>> result = site.api('query', prop='coordinates', titles='Oslo|Copenhagen')
            >>> for page in result['query']['pages'].values():
            ...     if 'coordinates' in page:
            ...         print page['title'], page['coordinates'][0]['lat'], page['coordinates'][0]['lon']
            Oslo 59.95 10.75
            Copenhagen 55.6761 12.5683

        Returns:
            The raw response from the API call, as a dictionary.
        """
The raw response from the API call, as a dictionary.
The raw response from the API call as a dictionary .
self
action
examples
To get coordinates from the GeoData MediaWiki extension at English Wikipedia.

>>> site = Site('en.wikipedia.org')
>>> result = site.api('query', prop='coordinates', titles='Oslo|Copenhagen')
>>> for page in result['query']['pages'].values():
if 'coordinates' in page:
print page['title'], page['coordinates'][0]['lat'], page['coordinates'][0]['lon']
Oslo 59.95 10.75
Copenhagen 55.6761 12.5683
To get coordinates from the GeoData MediaWiki extension at English Wikipedia . >>> site = Site ( ' en . wikipedia . org ' ) >>> result = site . api ( ' query ' prop = ' coordinates ' titles = ' Oslo|Copenhagen ' ) >>> for page in result [ ' query ' ] [ ' pages ' ] . values () : if ' coordinates ' in page : print page [ ' title ' ] page [ ' coordinates ' ] [ 0 ] [ ' lat ' ] page [ ' coordinates ' ] [ 0 ] [ ' lon ' ] Oslo 59 . 95 10 . 75 Copenhagen 55 . 6761 12 . 5683