investfly.api.InvestflyApiClient

High-level authenticated entry point for the public Investfly REST API.

class InvestflyApiClient:

Group the public endpoint clients behind one authenticated session.

Call login() before using endpoint clients that require authentication, then use marketApi, portfolioApi, strategyApi, or indicatorApi for typed operations.

InvestflyApiClient( baseUrl: str = 'https://api.investfly.com', logEnabled: bool = False, verifyTls: bool | str = True, timeout: float = 10.0)

Create an API client.

Arguments:
  • baseUrl: Investfly REST API root URL.
  • logEnabled: Log sanitized request and response metadata when true.
  • verifyTls: Requests-compatible TLS certificate verification setting.
  • timeout: Per-request timeout in seconds.
restApiClient

Low-level HTTP transport shared by all endpoint clients.

marketApi

Market data and symbol endpoint client.

portfolioApi

Portfolio and brokerage-account endpoint client.

strategyApi

Trading strategy and backtest endpoint client.

indicatorApi

Custom and standard indicator endpoint client.

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

Login to investfly backend.

Arguments:
  • username: Username for authentication.
  • password: Password for authentication.
Returns:

Session object representing authenticated session.

def logout(self):

End the server session and remove locally stored session headers.

def isLoggedIn(self) -> bool:

Return whether this client currently holds Investfly session headers.

def getSession(self) -> investfly.models.common.Session:

Return the authenticated user's current session details.

def enableLogging(self, enable: bool = True):

Enable or disable HTTP request/response logging for this client.

Note: Logging configuration should be done separately by the application using standard Python logging.

Arguments:
  • enable: Whether to enable logging.