The Bloomy SDK provides flexible configuration options to suit different use cases and deployment scenarios.
The simplest method - pass your API key directly to the client:
from bloomy import Client
client = Client(api_key="your-api-key-here")Best for: Scripts, notebooks, and testing
Set the BG_API_KEY environment variable:
# Linux/macOS
export BG_API_KEY="your-api-key-here"
# Windows
set BG_API_KEY=your-api-key-hereThen initialize the client without parameters:
from bloomy import Client
client = Client() # Automatically uses BG_API_KEYBest for: Production applications, CI/CD pipelines
The SDK can store credentials in a local configuration file:
from bloomy import Configuration
# Initial setup - fetches and saves API key
config = Configuration()
config.configure_api_key(
username="your-email@example.com",
password="your-password",
store_key=True
)
# Future usage - automatically loads saved API key
from bloomy import Client
client = Client()The configuration is stored in ~/.bloomy/config.yaml:
api_key: your-api-key-hereBest for: Development environments, personal use
When initializing a client, the SDK checks for credentials in this order:
- Direct
api_keyparameter BG_API_KEYenvironment variable- Configuration file (
~/.bloomy/config.yaml)
The first valid API key found is used.
from bloomy import Configuration
config = Configuration()
print(f"Has API key: {config.api_key is not None}")from bloomy import Configuration
# Update with new credentials
config = Configuration()
config.configure_api_key(
username="new-email@example.com",
password="new-password",
store_key=True
)!!! note "Using API Key Directly"
If you want to use an API key directly without storing it, pass it to the client:
python from bloomy import Client client = Client(api_key="your-api-key")
# Remove stored credentials
rm ~/.bloomy/config.yaml- Never commit API keys to version control
- Use environment variables in production
- Restrict file permissions on config files:
chmod 600 ~/.bloomy/config.yaml - Rotate API keys regularly
- Use separate keys for development and production
If you see BloomyError: No API key provided, check:
- Spelling of environment variable (
BG_API_KEY) - Configuration file exists at
~/.bloomy/config.yaml - API key is properly formatted
If authentication fails:
- Verify API key is correct and active
- Check if your account has API access enabled
- Ensure your API key is valid
To reset configuration:
rm -rf ~/.bloomyThen reconfigure using the Configuration class.