investfly.api.RestApiClient

HTTP transport and error type used by the public endpoint clients.

class InvestflyApiError(builtins.Exception):

Describe a non-successful Investfly REST response.

Attributes:
  • statusCode: HTTP response status.
  • responseBody: Parsed JSON or text returned by the server, when available.
InvestflyApiError(statusCode: int, message: str, responseBody: Any = None)

Create an API error from an HTTP status, message, and optional response body.

class RestApiClient:

Shared HTTP transport used by the endpoint-specific clients.

Most users should start with InvestflyApiClient. Use this class directly when a supported endpoint does not yet have a typed convenience method.

RestApiClient( baseUrl: str, logEnabled: bool = False, verifyTls: bool | str = True, timeout: float = 10.0, session: requests.sessions.Session | None = None)

Create a transport for one Investfly API root.

def login( self, username: str, password: str) -> investfly.models.common.Session:

Authenticate and retain the returned Investfly session headers.

def logout(self) -> None:

End the server session and always clear local session headers.

def doGet(self, url: str) -> Any:

Send a GET request to a path relative to baseUrl.

def doDelete(self, url: str) -> Any:

Send a DELETE request to a path relative to baseUrl.

def doPost(self, url: str, obj: Any) -> Any:

POST a JSON-compatible value to a path relative to baseUrl.

def doPostCode(self, url: str, code: str) -> Any:

POST Python source text to a path relative to baseUrl.