py_alpaca_api.http.requests

Exceptions

APIRequestError

Raised when an API request fails.

Classes

Requests

Module Contents

exception py_alpaca_api.http.requests.APIRequestError(status_code: int | None = None, message: str = '')[source]

Bases: PyAlpacaAPIError

Raised when an API request fails.

class py_alpaca_api.http.requests.Requests[source]
request(method: str, url: str, headers: dict[str, str] | None = None, params: dict[str, str | bool | float | int] | None = None, json: dict[str, Any] | None = None, raw_response: bool = False)[source]

Execute HTTP request with retry logic.

Parameters:
  • method – A string representing the HTTP method to be used in the request.

  • url – A string representing the URL to send the request to.

  • headers – An optional dictionary containing the headers for the request.

  • params – An optional dictionary containing the query parameters for the request.

  • json – An optional dictionary containing the JSON payload for the request.

  • raw_response – If True, return the raw response object without status checks. Defaults to False.

Returns:

The response object returned by the server.

Raises:

APIRequestError – If the response status code is not one of the acceptable statuses (200, 204, 207) and raw_response is False.