Skip to content

Client

The main entry point for interacting with the Bloomy API.

Client

Client(api_key: str | None = None, base_url: str = 'https://app.bloomgrowth.com/api/v1', timeout: float = 30.0)

The Client class is the main entry point for interacting with the Bloomy API.

It provides methods for managing Bloom Growth features.

Example
from bloomy import Client
client = Client()
client.meeting.list()
client.user.details()
client.meeting.delete(123)
client.scorecard.list()
client.issue.list()
client.headline.list()

Initialize a new Client instance.

Parameters:

  • api_key (str | None, default: None ) –

    The API key to use. If not provided, will attempt to load from environment variable (BG_API_KEY) or configuration file.

  • base_url (str, default: 'https://app.bloomgrowth.com/api/v1' ) –

    The base URL for the API. Defaults to the production API URL.

  • timeout (float, default: 30.0 ) –

    The timeout in seconds for HTTP requests. Defaults to 30.0.

Raises:

Methods:

  • __enter__

    Context manager entry.

  • __exit__

    Context manager exit - close the HTTP client.

  • close

    Close the HTTP client connection.

Source code in src/bloomy/client.py
def __init__(
    self,
    api_key: str | None = None,
    base_url: str = "https://app.bloomgrowth.com/api/v1",
    timeout: float = 30.0,
) -> None:
    """Initialize a new Client instance.

    Args:
        api_key: The API key to use. If not provided, will attempt to
                 load from environment variable (BG_API_KEY) or configuration file.
        base_url: The base URL for the API. Defaults to the production API URL.
        timeout: The timeout in seconds for HTTP requests. Defaults to 30.0.

    Raises:
        ConfigurationError: If no API key is provided or found in configuration.

    """
    # Use Configuration class which handles priority:
    # 1. Explicit api_key parameter
    # 2. BG_API_KEY environment variable
    # 3. Configuration file (~/.bloomy/config.yaml)
    self.configuration = Configuration(api_key)

    if not self.configuration.api_key:
        raise ConfigurationError(
            "No API key provided. Set it explicitly, via BG_API_KEY "
            "environment variable, or in ~/.bloomy/config.yaml configuration file."
        )

    self._api_key = self.configuration.api_key
    self._base_url = base_url

    # Initialize HTTP client
    self._client = httpx.Client(
        base_url=base_url,
        headers={
            "Accept": "*/*",
            "Content-Type": "application/json",
            "Authorization": f"Bearer {self._api_key}",
        },
        timeout=timeout,
    )

    # Initialize operation classes
    self.user = UserOperations(self._client)
    self.todo = TodoOperations(self._client)
    self.meeting = MeetingOperations(self._client)
    self.goal = GoalOperations(self._client)
    self.scorecard = ScorecardOperations(self._client)
    self.issue = IssueOperations(self._client)
    self.headline = HeadlineOperations(self._client)

Functions

__enter__

__enter__() -> Client

Context manager entry.

Returns:

  • Client

    The client instance.

Source code in src/bloomy/client.py
def __enter__(self) -> Client:
    """Context manager entry.

    Returns:
        The client instance.

    """
    return self

__exit__

__exit__(*args: Any) -> None

Context manager exit - close the HTTP client.

Source code in src/bloomy/client.py
def __exit__(self, *args: Any) -> None:
    """Context manager exit - close the HTTP client."""
    self._client.close()

close

close() -> None

Close the HTTP client connection.

Source code in src/bloomy/client.py
def close(self) -> None:
    """Close the HTTP client connection."""
    self._client.close()

Basic Usage

from bloomy import Client, ConfigurationError

# Initialize with API key
client = Client(api_key="your-api-key")

# Custom base URL (for testing/staging)
client = Client(
    api_key="your-api-key",
    base_url="https://staging.example.com/api/v1"
)

# Custom timeout (in seconds)
client = Client(api_key="your-api-key", timeout=60.0)

# Handle missing API key
try:
    client = Client()
except ConfigurationError as e:
    print(f"Configuration error: {e}")

Parameters

  • api_key (str, optional): Your Bloom Growth API key. If not provided, will attempt to load from BG_API_KEY environment variable or ~/.bloomy/config.yaml
  • base_url (str, optional): Custom API endpoint. Defaults to "https://app.bloomgrowth.com/api/v1"
  • timeout (float, optional): Request timeout in seconds. Defaults to 30.0

Exceptions

  • ConfigurationError: Raised when no API key can be found from any source

Context Manager

The Client supports context manager protocol for automatic resource cleanup:

with Client(api_key="your-api-key") as client:
    users = client.user.list()
    # Client automatically closes when exiting the context