asynctradier.utils.webutils module

class asynctradier.utils.webutils.WebUtil(base_url: str, token: str)[source]

Bases: object

A utility class for making asynchronous HTTP requests.

async delete(path: str)[source]

Makes an asynchronous DELETE request.

Parameters:

path (str) – The path for the request.

Returns:

The JSON response from the request.

Return type:

dict

Raises:

BadRequestException – If the request fails or returns an error.

async get(path: str, params: dict = None)[source]

Makes an asynchronous GET request.

Parameters:
  • path (str) – The path for the request.

  • params (dict, optional) – The query parameters for the request. Defaults to None.

Returns:

The JSON response from the request.

Return type:

dict

Raises:

BadRequestException – If the request fails or returns an error.

async make_request(url: str, method: str, params: dict = None, data: dict = None)[source]

Makes an asynchronous HTTP request.

Parameters:
  • url (str) – The URL for the request.

  • method (str) – The HTTP method for the request.

  • params (dict, optional) – The query parameters for the request. Defaults to None.

  • data (dict, optional) – The request payload. Defaults to None.

Returns:

The JSON response from the request.

Return type:

dict

Raises:

BadRequestException – If the request fails or returns an error.

async post(path: str, data: dict = None)[source]

Makes an asynchronous POST request.

Parameters:
  • path (str) – The path for the request.

  • data (dict, optional) – The request payload. Defaults to None.

Returns:

The JSON response from the request.

Return type:

dict

Raises:

BadRequestException – If the request fails or returns an error.

async put(path: str, data: dict = None)[source]

Makes an asynchronous PUT request.

Parameters:
  • path (str) – The path for the request.

  • data (dict, optional) – The request payload. Defaults to None.

Returns:

The JSON response from the request.

Return type:

dict

Raises:

BadRequestException – If the request fails or returns an error.