AsyncHttp

Handle asynchronous http requests.
Request to PS2 api: use api_request_and_retry().
Standard HTTP request: use request_code().
exception ApiNotReachable(url: str)

Bases: Exception

Custom API request exception.

Parameters

url – Url which led to the error.

async request_code(url: str)int

Get the url requested.

Parameters

url – URL to get.

Returns

HTTP code returned.

async api_request_and_retry(url: str, retries: int = 3)dict

Try to query Planetside2 API.

Parameters
  • retries – (Optional, default: 3) Number of retries.

  • url – URL to get.

Returns

Json dictionary returned by the API.

Raises

ApiNotReachable – if the request failed.