featureflagshq


Namefeatureflagshq JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/featureflagshq/python-sdk
SummaryA secure, high-performance Python SDK for FeatureFlagsHQ feature flag management
upload_time2025-08-17 22:56:30
maintainerNone
docs_urlNone
authorFeatureFlagsHQ
requires_python>=3.7
licenseMIT
keywords feature flags feature toggles experimentation a/b testing
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FeatureFlagsHQ Python SDK

[![PyPI version](https://badge.fury.io/py/featureflagshq.svg)](https://badge.fury.io/py/featureflagshq)
[![Python Support](https://img.shields.io/pypi/pyversions/featureflagshq.svg)](https://pypi.org/project/featureflagshq/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A secure, high-performance Python SDK for [FeatureFlagsHQ](https://featureflagshq.com) feature flag management with enterprise-grade security, offline support, and comprehensive analytics.

## ✨ Features

- 🔒 **Enterprise Security**: HMAC authentication, input validation, and security filtering
- ⚡ **High Performance**: Background polling, caching, and circuit breaker patterns
- 🌐 **Offline Support**: Works seamlessly without internet connectivity
- 📊 **Analytics & Metrics**: Comprehensive usage tracking and statistics
- 🎯 **User Segmentation**: Advanced targeting based on user attributes
- 🔄 **Real-time Updates**: Background flag synchronization with change callbacks
- 🛡️ **Production Ready**: Rate limiting, error handling, and graceful degradation

## 📦 Installation

```bash
pip install featureflagshq
```

## 🚀 Quick Start

```python
from featureflagshq import FeatureFlagsHQSDK

# Initialize the SDK
sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret",
    environment="production"  # or "staging", "development"
)

# Get a feature flag value
user_id = "user_123"
is_enabled = sdk.get_bool(user_id, "new_dashboard", default_value=False)

if is_enabled:
    print("New dashboard is enabled for this user!")
else:
    print("Using classic dashboard")

# Clean shutdown
sdk.shutdown()
```

## ⚙️ Configuration

### 🌍 Environment Variables

The SDK can be configured using environment variables:

```bash
export FEATUREFLAGSHQ_CLIENT_ID="your_client_id"
export FEATUREFLAGSHQ_CLIENT_SECRET="your_client_secret"
export FEATUREFLAGSHQ_ENVIRONMENT="production"
```

```python
# SDK will automatically use environment variables
sdk = FeatureFlagsHQSDK()
```

### 🔧 Advanced Configuration

```python
sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret",
    environment="production",
    api_base_url="https://api.featureflagshq.com",  # Custom API endpoint
    timeout=30,                                      # Request timeout
    max_retries=3,                                   # Number of retries
    offline_mode=False,                              # Enable offline mode
    enable_metrics=True,                             # Enable analytics
    on_flag_change=lambda name, old, new: print(f"Flag {name} changed!")
)
```

## 💻 Usage Examples

### 🎯 Basic Flag Evaluation

```python
from featureflagshq import FeatureFlagsHQSDK

sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

user_id = "user_123"

# Boolean flags
show_beta_feature = sdk.get_bool(user_id, "beta_feature", default_value=False)

# String flags
button_color = sdk.get_string(user_id, "button_color", default_value="blue")

# Integer flags
max_items = sdk.get_int(user_id, "max_items_per_page", default_value=10)

# Float flags
discount_rate = sdk.get_float(user_id, "discount_rate", default_value=0.0)

# JSON flags
config = sdk.get_json(user_id, "app_config", default_value={})
```

### 👥 User Segmentation

```python
# Define user segments for targeting
user_segments = {
    "country": "US",
    "subscription": "premium",
    "age": 25,
    "beta_user": True
}

# Evaluate flags with segments
is_premium_feature_enabled = sdk.get_bool(
    user_id="user_123",
    flag_name="premium_analytics",
    default_value=False,
    segments=user_segments
)
```

### 📊 Bulk Flag Evaluation

```python
# Get all flags for a user
all_flags = sdk.get_user_flags("user_123", segments=user_segments)
print(f"All flags for user: {all_flags}")

# Get specific flags only
specific_flags = sdk.get_user_flags(
    "user_123", 
    segments=user_segments,
    flag_keys=["feature_a", "feature_b", "feature_c"]
)
```

### 🔄 Context Manager Usage

```python
# Automatic cleanup with context manager
with FeatureFlagsHQSDK(client_id="...", client_secret="...") as sdk:
    is_enabled = sdk.get_bool("user_123", "new_feature")
    # SDK automatically shuts down when exiting the context
```

### 🏭 Production Setup

```python
from featureflagshq import create_production_client

# Create a production-ready client with security hardening
sdk = create_production_client(
    client_id="your_client_id",
    client_secret="your_client_secret",
    environment="production",
    timeout=30,
    max_retries=3
)
```

### 🌶️ Flask Integration

```python
from flask import Flask, request
from featureflagshq import FeatureFlagsHQSDK

app = Flask(__name__)

# Initialize SDK once
sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

@app.route('/dashboard')
def dashboard():
    user_id = request.user.id  # Get from your auth system
    
    # Check if new dashboard is enabled
    use_new_dashboard = sdk.get_bool(user_id, "new_dashboard_v2")
    
    if use_new_dashboard:
        return render_template('dashboard_v2.html')
    else:
        return render_template('dashboard_v1.html')

# Clean shutdown when app closes
@app.teardown_appcontext
def shutdown_sdk(exception):
    sdk.shutdown()
```

### 🎸 Django Integration

```python
# settings.py
FEATUREFLAGSHQ_CLIENT_ID = "your_client_id"
FEATUREFLAGSHQ_CLIENT_SECRET = "your_client_secret"
FEATUREFLAGSHQ_ENVIRONMENT = "production"

# utils.py
from django.conf import settings
from featureflagshq import FeatureFlagsHQSDK

_sdk_instance = None

def get_feature_flags_sdk():
    global _sdk_instance
    if _sdk_instance is None:
        _sdk_instance = FeatureFlagsHQSDK(
            client_id=settings.FEATUREFLAGSHQ_CLIENT_ID,
            client_secret=settings.FEATUREFLAGSHQ_CLIENT_SECRET,
            environment=settings.FEATUREFLAGSHQ_ENVIRONMENT
        )
    return _sdk_instance

# views.py
from django.shortcuts import render
from .utils import get_feature_flags_sdk

def my_view(request):
    sdk = get_feature_flags_sdk()
    user_id = str(request.user.id)
    
    show_new_feature = sdk.get_bool(user_id, "new_feature")
    
    return render(request, 'template.html', {
        'show_new_feature': show_new_feature
    })
```

## 🔬 Advanced Features

### 📞 Flag Change Callbacks

```python
def on_flag_changed(flag_name, old_value, new_value):
    print(f"Flag '{flag_name}' changed from {old_value} to {new_value}")
    # Trigger cache invalidation, send notifications, etc.

sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret",
    on_flag_change=on_flag_changed
)
```

### 🔄 Manual Refresh and Cache Control

```python
# Manually refresh flags from server
success = sdk.refresh_flags()
if success:
    print("Flags refreshed successfully")

# Get all cached flags
all_flags = sdk.get_all_flags()
print(f"Cached flags: {list(all_flags.keys())}")

# Force log upload
sdk.flush_logs()
```

### 📈 SDK Health and Statistics

```python
# Get SDK health status
health = sdk.get_health_check()
print(f"SDK Status: {health['status']}")
print(f"Cached Flags: {health['cached_flags_count']}")

# Get detailed usage statistics
stats = sdk.get_stats()
print(f"Total API calls: {stats['api_calls']['total']}")
print(f"Unique users: {stats['unique_users_count']}")
print(f"Circuit breaker state: {stats['circuit_breaker']['state']}")
```

### 🌐 Offline Mode

```python
# Enable offline mode for environments without internet
sdk = FeatureFlagsHQSDK(
    client_id="your_client_id",
    client_secret="your_client_secret",
    offline_mode=True
)

# All flag evaluations will use default values in offline mode
result = sdk.get_bool("user_123", "feature_flag", default_value=True)
```

## ⚠️ Error Handling

The SDK includes comprehensive error handling and graceful degradation:

```python
try:
    sdk = FeatureFlagsHQSDK(
        client_id="invalid_client_id",
        client_secret="invalid_secret"
    )
    
    # SDK will continue to work but use default values
    # Check health to see if there are authentication issues
    health = sdk.get_health_check()
    if health['status'] != 'healthy':
        print(f"SDK not healthy: {health}")
        
except ValueError as e:
    print(f"Configuration error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")
```

## ✅ Best Practices

### 1️⃣ Singleton Pattern
Create one SDK instance per application and reuse it:

```python
# Good
sdk = FeatureFlagsHQSDK(client_id="...", client_secret="...")
# Reuse sdk throughout your application

# Bad - creates multiple instances
def get_flag():
    sdk = FeatureFlagsHQSDK(client_id="...", client_secret="...")
    return sdk.get_bool("user", "flag")
```

### 2️⃣ Always Provide Default Values
```python
# Good - provides fallback behavior
is_enabled = sdk.get_bool("user_123", "new_feature", default_value=False)

# Risky - might return None in error cases
is_enabled = sdk.get_bool("user_123", "new_feature")
```

### 3️⃣ Use Context Managers for Short-lived Usage
```python
# For scripts or short-lived processes
with FeatureFlagsHQSDK(client_id="...", client_secret="...") as sdk:
    result = sdk.get_bool("user", "flag")
    # Automatic cleanup
```

### 4️⃣ Monitor SDK Health
```python
# Periodically check SDK health in production
health = sdk.get_health_check()
if health['status'] != 'healthy':
    # Alert your monitoring system
    logger.warning(f"FeatureFlags SDK unhealthy: {health}")
```

## 📚 API Reference

### 🎯 Main Methods

- `get(user_id, flag_name, default_value, segments)` - Get flag value with type inference
- `get_bool(user_id, flag_name, default_value, segments)` - Get boolean flag
- `get_string(user_id, flag_name, default_value, segments)` - Get string flag
- `get_int(user_id, flag_name, default_value, segments)` - Get integer flag
- `get_float(user_id, flag_name, default_value, segments)` - Get float flag
- `get_json(user_id, flag_name, default_value, segments)` - Get JSON flag
- `get_user_flags(user_id, segments, flag_keys)` - Get multiple flags for user
- `is_flag_enabled_for_user(user_id, flag_name, segments)` - Check if flag is enabled

### 🛠️ Management Methods

- `refresh_flags()` - Manually refresh flags from server
- `flush_logs()` - Upload pending analytics logs
- `get_all_flags()` - Get all cached flag definitions
- `get_stats()` - Get SDK usage statistics
- `get_health_check()` - Get SDK health status
- `shutdown()` - Clean shutdown of background threads

## 🔐 Security

The SDK implements multiple security layers:

- **HMAC Authentication**: All API requests are signed with HMAC-SHA256
- **Input Validation**: All inputs are validated and sanitized
- **Security Filtering**: Sensitive data is filtered from logs
- **Rate Limiting**: Per-user rate limiting prevents abuse
- **Circuit Breaker**: Automatic failure detection and recovery

## 🆘 Support

- **Documentation**: [Official docs](https://featureflagshq.com/documentation/)
- **Issues**: [GitHub Issues](https://github.com/featureflagshq/python-sdk/issues)
- **Email**: hello@featureflagshq.com

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📋 Changelog

See [CHANGELOG.md](CHANGELOG.md) for version history and updates.

---

**Built with ❤️ by the FeatureFlagsHQ Team**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/featureflagshq/python-sdk",
    "name": "featureflagshq",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "feature flags, feature toggles, experimentation, a/b testing",
    "author": "FeatureFlagsHQ",
    "author_email": "FeatureFlagsHQ <hello@featureflagshq.com>",
    "download_url": "https://files.pythonhosted.org/packages/12/91/70a234850538fc3695e498cc701c07f6e3fc4436fa0690bcff8b1b274560/featureflagshq-1.0.1.tar.gz",
    "platform": null,
    "description": "# FeatureFlagsHQ Python SDK\n\n[![PyPI version](https://badge.fury.io/py/featureflagshq.svg)](https://badge.fury.io/py/featureflagshq)\n[![Python Support](https://img.shields.io/pypi/pyversions/featureflagshq.svg)](https://pypi.org/project/featureflagshq/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA secure, high-performance Python SDK for [FeatureFlagsHQ](https://featureflagshq.com) feature flag management with enterprise-grade security, offline support, and comprehensive analytics.\n\n## \u2728 Features\n\n- \ud83d\udd12 **Enterprise Security**: HMAC authentication, input validation, and security filtering\n- \u26a1 **High Performance**: Background polling, caching, and circuit breaker patterns\n- \ud83c\udf10 **Offline Support**: Works seamlessly without internet connectivity\n- \ud83d\udcca **Analytics & Metrics**: Comprehensive usage tracking and statistics\n- \ud83c\udfaf **User Segmentation**: Advanced targeting based on user attributes\n- \ud83d\udd04 **Real-time Updates**: Background flag synchronization with change callbacks\n- \ud83d\udee1\ufe0f **Production Ready**: Rate limiting, error handling, and graceful degradation\n\n## \ud83d\udce6 Installation\n\n```bash\npip install featureflagshq\n```\n\n## \ud83d\ude80 Quick Start\n\n```python\nfrom featureflagshq import FeatureFlagsHQSDK\n\n# Initialize the SDK\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    environment=\"production\"  # or \"staging\", \"development\"\n)\n\n# Get a feature flag value\nuser_id = \"user_123\"\nis_enabled = sdk.get_bool(user_id, \"new_dashboard\", default_value=False)\n\nif is_enabled:\n    print(\"New dashboard is enabled for this user!\")\nelse:\n    print(\"Using classic dashboard\")\n\n# Clean shutdown\nsdk.shutdown()\n```\n\n## \u2699\ufe0f Configuration\n\n### \ud83c\udf0d Environment Variables\n\nThe SDK can be configured using environment variables:\n\n```bash\nexport FEATUREFLAGSHQ_CLIENT_ID=\"your_client_id\"\nexport FEATUREFLAGSHQ_CLIENT_SECRET=\"your_client_secret\"\nexport FEATUREFLAGSHQ_ENVIRONMENT=\"production\"\n```\n\n```python\n# SDK will automatically use environment variables\nsdk = FeatureFlagsHQSDK()\n```\n\n### \ud83d\udd27 Advanced Configuration\n\n```python\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    environment=\"production\",\n    api_base_url=\"https://api.featureflagshq.com\",  # Custom API endpoint\n    timeout=30,                                      # Request timeout\n    max_retries=3,                                   # Number of retries\n    offline_mode=False,                              # Enable offline mode\n    enable_metrics=True,                             # Enable analytics\n    on_flag_change=lambda name, old, new: print(f\"Flag {name} changed!\")\n)\n```\n\n## \ud83d\udcbb Usage Examples\n\n### \ud83c\udfaf Basic Flag Evaluation\n\n```python\nfrom featureflagshq import FeatureFlagsHQSDK\n\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\"\n)\n\nuser_id = \"user_123\"\n\n# Boolean flags\nshow_beta_feature = sdk.get_bool(user_id, \"beta_feature\", default_value=False)\n\n# String flags\nbutton_color = sdk.get_string(user_id, \"button_color\", default_value=\"blue\")\n\n# Integer flags\nmax_items = sdk.get_int(user_id, \"max_items_per_page\", default_value=10)\n\n# Float flags\ndiscount_rate = sdk.get_float(user_id, \"discount_rate\", default_value=0.0)\n\n# JSON flags\nconfig = sdk.get_json(user_id, \"app_config\", default_value={})\n```\n\n### \ud83d\udc65 User Segmentation\n\n```python\n# Define user segments for targeting\nuser_segments = {\n    \"country\": \"US\",\n    \"subscription\": \"premium\",\n    \"age\": 25,\n    \"beta_user\": True\n}\n\n# Evaluate flags with segments\nis_premium_feature_enabled = sdk.get_bool(\n    user_id=\"user_123\",\n    flag_name=\"premium_analytics\",\n    default_value=False,\n    segments=user_segments\n)\n```\n\n### \ud83d\udcca Bulk Flag Evaluation\n\n```python\n# Get all flags for a user\nall_flags = sdk.get_user_flags(\"user_123\", segments=user_segments)\nprint(f\"All flags for user: {all_flags}\")\n\n# Get specific flags only\nspecific_flags = sdk.get_user_flags(\n    \"user_123\", \n    segments=user_segments,\n    flag_keys=[\"feature_a\", \"feature_b\", \"feature_c\"]\n)\n```\n\n### \ud83d\udd04 Context Manager Usage\n\n```python\n# Automatic cleanup with context manager\nwith FeatureFlagsHQSDK(client_id=\"...\", client_secret=\"...\") as sdk:\n    is_enabled = sdk.get_bool(\"user_123\", \"new_feature\")\n    # SDK automatically shuts down when exiting the context\n```\n\n### \ud83c\udfed Production Setup\n\n```python\nfrom featureflagshq import create_production_client\n\n# Create a production-ready client with security hardening\nsdk = create_production_client(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    environment=\"production\",\n    timeout=30,\n    max_retries=3\n)\n```\n\n### \ud83c\udf36\ufe0f Flask Integration\n\n```python\nfrom flask import Flask, request\nfrom featureflagshq import FeatureFlagsHQSDK\n\napp = Flask(__name__)\n\n# Initialize SDK once\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\"\n)\n\n@app.route('/dashboard')\ndef dashboard():\n    user_id = request.user.id  # Get from your auth system\n    \n    # Check if new dashboard is enabled\n    use_new_dashboard = sdk.get_bool(user_id, \"new_dashboard_v2\")\n    \n    if use_new_dashboard:\n        return render_template('dashboard_v2.html')\n    else:\n        return render_template('dashboard_v1.html')\n\n# Clean shutdown when app closes\n@app.teardown_appcontext\ndef shutdown_sdk(exception):\n    sdk.shutdown()\n```\n\n### \ud83c\udfb8 Django Integration\n\n```python\n# settings.py\nFEATUREFLAGSHQ_CLIENT_ID = \"your_client_id\"\nFEATUREFLAGSHQ_CLIENT_SECRET = \"your_client_secret\"\nFEATUREFLAGSHQ_ENVIRONMENT = \"production\"\n\n# utils.py\nfrom django.conf import settings\nfrom featureflagshq import FeatureFlagsHQSDK\n\n_sdk_instance = None\n\ndef get_feature_flags_sdk():\n    global _sdk_instance\n    if _sdk_instance is None:\n        _sdk_instance = FeatureFlagsHQSDK(\n            client_id=settings.FEATUREFLAGSHQ_CLIENT_ID,\n            client_secret=settings.FEATUREFLAGSHQ_CLIENT_SECRET,\n            environment=settings.FEATUREFLAGSHQ_ENVIRONMENT\n        )\n    return _sdk_instance\n\n# views.py\nfrom django.shortcuts import render\nfrom .utils import get_feature_flags_sdk\n\ndef my_view(request):\n    sdk = get_feature_flags_sdk()\n    user_id = str(request.user.id)\n    \n    show_new_feature = sdk.get_bool(user_id, \"new_feature\")\n    \n    return render(request, 'template.html', {\n        'show_new_feature': show_new_feature\n    })\n```\n\n## \ud83d\udd2c Advanced Features\n\n### \ud83d\udcde Flag Change Callbacks\n\n```python\ndef on_flag_changed(flag_name, old_value, new_value):\n    print(f\"Flag '{flag_name}' changed from {old_value} to {new_value}\")\n    # Trigger cache invalidation, send notifications, etc.\n\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    on_flag_change=on_flag_changed\n)\n```\n\n### \ud83d\udd04 Manual Refresh and Cache Control\n\n```python\n# Manually refresh flags from server\nsuccess = sdk.refresh_flags()\nif success:\n    print(\"Flags refreshed successfully\")\n\n# Get all cached flags\nall_flags = sdk.get_all_flags()\nprint(f\"Cached flags: {list(all_flags.keys())}\")\n\n# Force log upload\nsdk.flush_logs()\n```\n\n### \ud83d\udcc8 SDK Health and Statistics\n\n```python\n# Get SDK health status\nhealth = sdk.get_health_check()\nprint(f\"SDK Status: {health['status']}\")\nprint(f\"Cached Flags: {health['cached_flags_count']}\")\n\n# Get detailed usage statistics\nstats = sdk.get_stats()\nprint(f\"Total API calls: {stats['api_calls']['total']}\")\nprint(f\"Unique users: {stats['unique_users_count']}\")\nprint(f\"Circuit breaker state: {stats['circuit_breaker']['state']}\")\n```\n\n### \ud83c\udf10 Offline Mode\n\n```python\n# Enable offline mode for environments without internet\nsdk = FeatureFlagsHQSDK(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    offline_mode=True\n)\n\n# All flag evaluations will use default values in offline mode\nresult = sdk.get_bool(\"user_123\", \"feature_flag\", default_value=True)\n```\n\n## \u26a0\ufe0f Error Handling\n\nThe SDK includes comprehensive error handling and graceful degradation:\n\n```python\ntry:\n    sdk = FeatureFlagsHQSDK(\n        client_id=\"invalid_client_id\",\n        client_secret=\"invalid_secret\"\n    )\n    \n    # SDK will continue to work but use default values\n    # Check health to see if there are authentication issues\n    health = sdk.get_health_check()\n    if health['status'] != 'healthy':\n        print(f\"SDK not healthy: {health}\")\n        \nexcept ValueError as e:\n    print(f\"Configuration error: {e}\")\nexcept Exception as e:\n    print(f\"Unexpected error: {e}\")\n```\n\n## \u2705 Best Practices\n\n### 1\ufe0f\u20e3 Singleton Pattern\nCreate one SDK instance per application and reuse it:\n\n```python\n# Good\nsdk = FeatureFlagsHQSDK(client_id=\"...\", client_secret=\"...\")\n# Reuse sdk throughout your application\n\n# Bad - creates multiple instances\ndef get_flag():\n    sdk = FeatureFlagsHQSDK(client_id=\"...\", client_secret=\"...\")\n    return sdk.get_bool(\"user\", \"flag\")\n```\n\n### 2\ufe0f\u20e3 Always Provide Default Values\n```python\n# Good - provides fallback behavior\nis_enabled = sdk.get_bool(\"user_123\", \"new_feature\", default_value=False)\n\n# Risky - might return None in error cases\nis_enabled = sdk.get_bool(\"user_123\", \"new_feature\")\n```\n\n### 3\ufe0f\u20e3 Use Context Managers for Short-lived Usage\n```python\n# For scripts or short-lived processes\nwith FeatureFlagsHQSDK(client_id=\"...\", client_secret=\"...\") as sdk:\n    result = sdk.get_bool(\"user\", \"flag\")\n    # Automatic cleanup\n```\n\n### 4\ufe0f\u20e3 Monitor SDK Health\n```python\n# Periodically check SDK health in production\nhealth = sdk.get_health_check()\nif health['status'] != 'healthy':\n    # Alert your monitoring system\n    logger.warning(f\"FeatureFlags SDK unhealthy: {health}\")\n```\n\n## \ud83d\udcda API Reference\n\n### \ud83c\udfaf Main Methods\n\n- `get(user_id, flag_name, default_value, segments)` - Get flag value with type inference\n- `get_bool(user_id, flag_name, default_value, segments)` - Get boolean flag\n- `get_string(user_id, flag_name, default_value, segments)` - Get string flag\n- `get_int(user_id, flag_name, default_value, segments)` - Get integer flag\n- `get_float(user_id, flag_name, default_value, segments)` - Get float flag\n- `get_json(user_id, flag_name, default_value, segments)` - Get JSON flag\n- `get_user_flags(user_id, segments, flag_keys)` - Get multiple flags for user\n- `is_flag_enabled_for_user(user_id, flag_name, segments)` - Check if flag is enabled\n\n### \ud83d\udee0\ufe0f Management Methods\n\n- `refresh_flags()` - Manually refresh flags from server\n- `flush_logs()` - Upload pending analytics logs\n- `get_all_flags()` - Get all cached flag definitions\n- `get_stats()` - Get SDK usage statistics\n- `get_health_check()` - Get SDK health status\n- `shutdown()` - Clean shutdown of background threads\n\n## \ud83d\udd10 Security\n\nThe SDK implements multiple security layers:\n\n- **HMAC Authentication**: All API requests are signed with HMAC-SHA256\n- **Input Validation**: All inputs are validated and sanitized\n- **Security Filtering**: Sensitive data is filtered from logs\n- **Rate Limiting**: Per-user rate limiting prevents abuse\n- **Circuit Breaker**: Automatic failure detection and recovery\n\n## \ud83c\udd98 Support\n\n- **Documentation**: [Official docs](https://featureflagshq.com/documentation/)\n- **Issues**: [GitHub Issues](https://github.com/featureflagshq/python-sdk/issues)\n- **Email**: hello@featureflagshq.com\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83e\udd1d Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## \ud83d\udccb Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for version history and updates.\n\n---\n\n**Built with \u2764\ufe0f by the FeatureFlagsHQ Team**\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A secure, high-performance Python SDK for FeatureFlagsHQ feature flag management",
    "version": "1.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/featureflagshq/python-sdk/issues",
        "Documentation": "https://featureflagshq.com/documentation/",
        "Homepage": "https://featureflagshq.com",
        "Repository": "https://github.com/featureflagshq/python-sdk"
    },
    "split_keywords": [
        "feature flags",
        " feature toggles",
        " experimentation",
        " a/b testing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c13a2282811e423643ddfc98df8886165d70846ecf24c32120c52b7519208645",
                "md5": "3094bd9012be1de004019b3e85b25451",
                "sha256": "e1d04a0e416f37440e02c041dd55e2ad87e67c484288fc43f5939a8b3b57fddd"
            },
            "downloads": -1,
            "filename": "featureflagshq-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3094bd9012be1de004019b3e85b25451",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17016,
            "upload_time": "2025-08-17T22:56:28",
            "upload_time_iso_8601": "2025-08-17T22:56:28.948456Z",
            "url": "https://files.pythonhosted.org/packages/c1/3a/2282811e423643ddfc98df8886165d70846ecf24c32120c52b7519208645/featureflagshq-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "129170a234850538fc3695e498cc701c07f6e3fc4436fa0690bcff8b1b274560",
                "md5": "cda91204dd82dee38d076914184c558c",
                "sha256": "889954f626c9fb27356822032d1bbead8d7699dbffb5e6bbcbbc42fdeb402d71"
            },
            "downloads": -1,
            "filename": "featureflagshq-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cda91204dd82dee38d076914184c558c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 64973,
            "upload_time": "2025-08-17T22:56:30",
            "upload_time_iso_8601": "2025-08-17T22:56:30.110382Z",
            "url": "https://files.pythonhosted.org/packages/12/91/70a234850538fc3695e498cc701c07f6e3fc4436fa0690bcff8b1b274560/featureflagshq-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-17 22:56:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "featureflagshq",
    "github_project": "python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.0"
                ]
            ]
        }
    ],
    "lcname": "featureflagshq"
}
        
Elapsed time: 0.93935s