Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ConfigBee Server Side SDK for Python

ConfigBee Server SDK is a Python client library for integrating your application with ConfigBee, a feature flags and configuration management service. This library allows you to dynamically manage feature flags and configuration settings in your application.

Features

  • 🚀 Real-time Updates: Automatic configuration updates with live streaming
  • 🔧 Multiple Data Types: Support for boolean flags, text, numbers, and JSON configurations
  • 🎯 Hyper Availability: Intelligent fallback across multiple cloud endpoints
  • 🔄 Async/Await Support: Full async support with thread-safe synchronous methods
  • 📦 Lightweight: Minimal dependencies with efficient caching
  • 🛡️ Error Handling: Robust error handling and automatic retries

Installation

pip install configbee-server-sdk

Quick Start

Basic Usage

import configbee

# Initialize client
client = configbee.get_client(
    account_id="your_account_id",
    project_id="your_project_id", 
    environment_id="your_environment_id"
)

# Wait for initial load
client.wait_to_load()

# Get feature flags
is_feature_enabled = client.get_flag("new_feature")
if is_feature_enabled:
    print("New feature is enabled!")

# Get other configuration types
api_endpoint = client.get_text("api_endpoint")
max_retries = client.get_number("max_retries")
config_data = client.get_json("app_config")

Async Usage

import asyncio
import configbee

async def main():
    client = configbee.get_client(
        account_id="your_account_id",
        project_id="your_project_id",
        environment_id="your_environment_id"
    )
    
    # Wait for initial load (async)
    await client.await_to_load()
    
    # Use configurations
    feature_enabled = client.get_flag("beta_feature")
    print(f"Beta feature enabled: {feature_enabled}")

asyncio.run(main())

API Reference

Client Initialization

configbee.get_client(account_id, project_id, environment_id, logger=None)

Creates or returns an existing ConfigBee client instance.

Parameters:

  • account_id (str): Your ConfigBee account ID
  • project_id (str): Your ConfigBee project ID
  • environment_id (str): Your ConfigBee environment ID
  • logger (logging.Logger, optional): Custom logger instance

Returns: ConfigbeeClient instance

Configuration Retrieval Methods

get_flag(key) → Optional[bool]

Retrieves a boolean feature flag value.

enabled = client.get_flag("feature_toggle")

get_text(key) → Optional[str]

Retrieves a text configuration value.

api_url = client.get_text("api_endpoint")

get_number(key) → Optional[float]

Retrieves a numeric configuration value.

timeout = client.get_number("request_timeout")

get_json(key) → Optional[object]

Retrieves a JSON configuration value.

config = client.get_json("app_settings")

Bulk Retrieval Methods

get_all_flags() → Optional[Dict[str, bool]]

Retrieves all feature flags.

all_flags = client.get_all_flags()
# Returns: {"feature_a": True, "feature_b": False, ...}

get_all_texts() → Optional[Dict[str, str]]

Retrieves all text configurations.

get_all_numbers() → Optional[Dict[str, float]]

Retrieves all numeric configurations.

get_all_jsons() → Optional[Dict[str, object]]

Retrieves all JSON configurations.

Loading and Status Methods

wait_to_load(timeout=40)

Blocks until the client is loaded or timeout occurs.

Parameters:

  • timeout (int): Maximum seconds to wait (default: 40)

Raises: Exception if loading fails or times out

await_to_load(timeout=40)

Async version of wait_to_load().

status → ConfigbeeStatus

Returns the current client status:

  • INITIALIZING: Client is loading initial configuration
  • ACTIVE: Client is ready and receiving updates
  • DEACTIVE: Client is inactive
  • ERROR: Client encountered an error

Error Handling

The SDK includes comprehensive error handling:

import configbee
import logging

# Set up logging to see error details
logging.basicConfig(level=logging.INFO)

try:
    client = configbee.get_client("account", "project", "environment")
    client.wait_to_load(timeout=30)
    
    # Safe configuration access
    feature_enabled = client.get_flag("my_feature")
    if feature_enabled is None:
        print("Feature flag not found or client not ready")
    
except Exception as e:
    print(f"ConfigBee initialization failed: {e}")

Configuration Types

ConfigBee supports four configuration types:

Type Method Python Type Use Case
FLAG get_flag() bool Feature toggles, A/B testing
TEXT get_text() str API endpoints, messages
NUMBER get_number() float Timeouts, limits, percentages
JSON get_json() object Complex configurations

Advanced Usage

Custom Logging

import logging
import configbee

# Create custom logger
logger = logging.getLogger("my_app.configbee")
logger.setLevel(logging.DEBUG)

client = configbee.get_client(
    account_id="account_id",
    project_id="project_id", 
    environment_id="env_id",
    logger=logger
)

Multiple Environments

import configbee

# Development environment
dev_client = configbee.get_client("account", "project", "dev")

# Production environment  
prod_client = configbee.get_client("account", "project", "prod")

# Clients are automatically cached and reused

FastAPI Integration

ConfigBee works seamlessly with FastAPI applications. Here's how to integrate it:

from fastapi import FastAPI, HTTPException
from contextlib import asynccontextmanager
import configbee

# Global client instance
cb_client = None

@asynccontextmanager
async def lifespan(app: FastAPI):
    global cb_client
    # Initialize ConfigBee client on startup
    cb_client = configbee.get_client(
        account_id="your_account_id",
        project_id="your_project_id",
        environment_id="your_environment_id"
    )
    
    # Wait for initial configuration load
    await cb_client.await_to_load()
    print("ConfigBee client initialized")
    
    yield
    
    # Cleanup on shutdown (if needed)
    print("Shutting down ConfigBee client")

app = FastAPI(lifespan=lifespan)

@app.get("/")
async def read_root():
    # Use feature flags in your endpoints
    if cb_client.get_flag("maintenance_mode"):
        raise HTTPException(status_code=503, detail="Service under maintenance")
    
    return {"message": "Hello World"}

@app.get("/config")
async def get_config():
    # Return current configuration
    return {
        "api_version": cb_client.get_text("api_version"),
        "max_requests": cb_client.get_number("max_requests"),
        "features": cb_client.get_all_flags()
    }

@app.get("/users/{user_id}")
async def get_user(user_id: int):
    # Use configuration for business logic
    max_user_limit = cb_client.get_number("max_user_limit")
    if user_id > max_user_limit:
        raise HTTPException(status_code=400, detail="User ID exceeds limit")
    
    # Check if new user features are enabled
    enhanced_profile = cb_client.get_flag("enhanced_user_profile")
    
    return {
        "user_id": user_id,
        "enhanced_profile": enhanced_profile
    }

Dependency Injection Pattern

For better organization, you can use FastAPI's dependency injection:

from fastapi import FastAPI, Depends, HTTPException
import configbee

cb_client = None

async def get_configbee_client():
    global cb_client
    if cb_client is None:
        raise HTTPException(status_code=500, detail="ConfigBee client not initialized")
    return cb_client

@app.get("/feature-status")
async def feature_status(client: configbee.ConfigbeeClient = Depends(get_configbee_client)):
    return {
        "beta_features": client.get_flag("beta_features"),
        "new_ui": client.get_flag("new_ui_enabled")
    }

Real-time Updates

ConfigBee automatically receives real-time updates with live streaming. No additional code is required - your configuration values will be updated automatically.

import time
import configbee

client = configbee.get_client("account", "project", "env")
client.wait_to_load()

# This will automatically reflect updates made in ConfigBee dashboard
while True:
    current_limit = client.get_number("rate_limit")
    print(f"Current rate limit: {current_limit}")
    time.sleep(5)

Resources

Contributing

[Add contribution guidelines here]

Metadata

Release files for configbee-server-sdk 0.0.1a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for configbee-server-sdk 0.0.1a1
File Size Uploaded Provenance Actions
configbee_server_sdk-0.0.1a1.tar.gz 15.8 kB Without provenance Details for configbee_server_sdk-0.0.1a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for configbee-server-sdk 0.0.1a1
File Interpreter ABI Platform Actions
configbee_server_sdk-0.0.1a1-py3-none-any.whl Python 3 none any Details for configbee_server_sdk-0.0.1a1-py3-none-any.whl

Total release size: 28.5 kB

Release files / configbee_server_sdk-0.0.1a1.tar.gz

Download URL configbee_server_sdk-0.0.1a1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fa136aafe726692a834adcb9937f8143e063d1598b353aedfbe54606f605dea0
BLAKE2b-256 checksum
How to use checksums
d8d5ce0454e7b7019324ff4a6ef1d9e253d12339ba25f79f4a8322b5f8dea3cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Release files / configbee_server_sdk-0.0.1a1-py3-none-any.whl

Download URL configbee_server_sdk-0.0.1a1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0953076998a5c6cfc67b229c38667de3c9e7436097e55ceba95f697c9b4efe3d
BLAKE2b-256 checksum
How to use checksums
411015489694da37f0248f95dce901d6592d18ac1c574106d397423c812dad5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.13

Security for configbee-server-sdk 0.0.1a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page