mediawiki_api_call_helper#

wikibaseintegrator.wbi_helpers.mediawiki_api_call_helper(data, login=None, mediawiki_api_url=None, user_agent=None, allow_anonymous=False, max_retries=20, retry_after=60, maxlag=5, is_bot=False, **kwargs)[source]#

A simplified function to call the MediaWiki API. Pass the data, as a dictionary, related to the action you want to call, all commons options will be automatically managed.

Parameters:
  • data (dict[str, Any]) – A dictionary containing the JSON data to send to the API

  • login (_Login | None, default: None) – A wbi_login._Login instance

  • mediawiki_api_url (str | None, default: None) – The URL to the MediaWiki API (default Wikidata)

  • user_agent (str | None, default: None) – The user agent (Recommended for Wikimedia Foundation instances)

  • allow_anonymous (bool, default: False) – Allow an unidentified edit to the MediaWiki API (default False)

  • max_retries (int, default: 20) – The maximum number of tries of the request, see mediawiki_api_call()

  • retry_after (int, default: 60) – The maximum wait between two tries, see mediawiki_api_call()

  • maxlag (int, default: 5) – If applicable, the maximum lag allowed for the replication (An lower number reduce the load on the replicated database)

  • is_bot (bool, default: False) – Flag the edit as a bot

  • kwargs (Any) – Any additional keyword arguments to pass to requests.request

Return type:

dict

Returns:

The data returned by the API as a dictionary