diff --git a/mwclient/client.py b/mwclient/client.py index 2dd5c516fbaf5df028975eb79ca9cc7d0b3dcf52..be4457b628e2d13bc2066a891e7bc69934454717 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -161,7 +161,23 @@ class Site(object): return "<Site object '%s%s'>" % (self.host, self.path) def api(self, action, *args, **kwargs): - """ An API call. Handles errors and returns dict object. """ + """ + 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 action == 'query': if 'meta' in kwargs: