aiowowapi.api module

class aiowowapi.api.API(client_id: str, client_secret: str, client_region: Union[APIRegion, str], *, max_parallel_requests: Optional[int] = None, max_request_retries: Optional[int] = None, request_retry_delay: Optional[int] = None, request_debugging: Optional[bool] = None)

Bases: object

async get_access_token() str

Returns and / or generates an API access token using the provided credentials in the class constructor

Raises

RequestException – Raised when we encounter an issue when making an aiohttp request.

Returns

A Battle.net OAuth Access Token

Return type

str

get_hostname() str

Returns the current region’s hostname for Game API requests

Returns

The current region’s hostname for Game API requests

Return type

str

get_locale() str

Returns the current locale being used for API requests

Returns

The current locale being used for API requests

Return type

str

get_oauth_hostname() str

Returns the current region’s hostname for OAuth API requests

Returns

The current region’s hostname for OAuth API requests

Return type

str

get_region() str

Returns the current region being used for API requests

Returns

The current region being used for API requests

Return type

str

async get_resource(hostname: str, api_endpoint: str, params: Optional[dict] = None, auth: Optional[BasicAuth] = None, method: Optional[str] = 'GET') Optional[dict]

Make an API request and return the response as a JSON dictionary

Parameters
  • hostname (str) – The hostname to make the request to

  • api_endpoint (str) – The API endpoint following the regional hostname we wish to send a request to.

  • params (dict, optional) – The additional arguments/parameters we need to send with the request, defaults to None

  • auth (aiohttp.BasicAuth, optional) – The aiohttp BasicAuth object to use for authentication, defaults to None

  • method (str, optional) – The HTTP method to use for the request, defaults to “GET”

Raises
Returns

The response from the API as a JSON dictionary

Return type

dict, none

async static multi_request(requests: list) Optional[Union[tuple, list]]

Make several API requests asynchronously

Parameters

requests (list) – A list of API request coroutines

Returns

The API responses as a list of dicts

Return type

list

set_locale(locale: str) str

Sets the locale we’ll use for API requests

Parameters

locale (str) – The desired locale to be used for API requests.

Raises

InvalidLocaleException – Raised the input doesn’t match any of the current region’s supported locales

Returns

The current locale being used for API requests

Return type

str

set_region(region: Union[APIRegion, str]) APIRegion

Sets the region to be used for API requests

Parameters

region (str, APIRegion) – The desired region to be used for API requests

Raises

InvalidRegionException – Raised when the provided region isn’t supported/found

Returns

The API object

Return type

API

exception aiowowapi.api.AccessTokenException(message: str = 'An error was encountered retrieving an API access token')

Bases: ApiException

Exception thrown when a null access token is provided

Parameters

message (str, optional) – Description of the occurring error

exception aiowowapi.api.ApiException(message: str = 'An error was encountered in the API class.')

Bases: Exception

Generic exception type for our API

Parameters

message (str, optional) – Description of the occurring error

exception aiowowapi.api.InvalidLocaleException(message: str = 'Invalid API Locale')

Bases: ApiException

Exception thrown when an invalid/unsupported API Locale is provided

Parameters

message (str, optional) – Description of the occurring error

exception aiowowapi.api.InvalidRegionException(message: str = 'Invalid API Region')

Bases: ApiException

Exception thrown when an invalid/unsupported API Region is provided

Parameters

message (str, optional) – Description of the occurring error

exception aiowowapi.api.RequestException(message: str = 'Error making API request')

Bases: ApiException

Exception thrown when something goes wrong with an HTTP API request

Parameters

message (str, optional) – Description of the occurring error

exception aiowowapi.api.RequestMethodException(message: str = 'Invalid request method')

Bases: ApiException

Exception thrown when an invalid request method is given

Parameters

message (str, optional) – Description of the occurring error