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, graphql_url: str | None = None)
The Client class is the main entry point for interacting with the Bloomy API.
It provides methods for managing Bloom Growth features.
client.v1 groups the REST API operations (user, todo, meeting,
goal, scorecard, issue, headline); the top-level attributes below
are aliases of client.v1.*, kept for backward compatibility.
client.v2 groups the GraphQL API operations (user, meeting,
issue, ...).
Example
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.
-
graphql_url(str | None, default:None) –The absolute URL of the v2 GraphQL endpoint. Defaults to the scheme and host of
base_urlplus/graphql/.
Raises:
-
ConfigurationError–If no API key is provided or found in configuration.
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
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_KEYenvironment 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: