This directory contains examples demonstrating how to use the Lumen Python SDK in various scenarios.
- Install the SDK:
pip install lumen-python-sdk- Set your API key:
export LUMEN_API_KEY="your_api_key_here"Get your API key from https://getlumen.dev/developer/apikeys
Demonstrates core SDK functionality:
- Checking subscription status
- Tracking events
- Checking feature entitlements
- Managing seats
Run:
python basic_usage.pyShows how to integrate Lumen with FastAPI for secure API proxying.
Install dependencies:
pip install lumen-python-sdk[fastapi] uvicornRun:
python fastapi_example.pyThen test with:
curl -H "X-User-ID: user_123" http://localhost:8000/api/lumen/customers/subscription-statusShows how to integrate Lumen with Flask for secure API proxying.
Install dependencies:
pip install lumen-python-sdk[flask]Run:
python flask_example.pyThen test with:
curl -H "X-User-ID: user_123" http://localhost:5000/api/lumen/customers/subscription-statusAll framework examples follow the same pattern:
- Define a
get_user_idfunction that extracts the user ID from the request - Create a handler using the framework-specific Lumen handler
- Mount the handler at a route (typically
/api/lumen/)
This provides a secure way to access Lumen APIs from your frontend without exposing your API key.
When deploying to production:
- Never hardcode API keys - use environment variables
- Implement proper authentication - validate JWT tokens, sessions, etc.
- Add rate limiting - protect your API endpoints
- Enable HTTPS - always use secure connections
- Monitor errors - log and track API failures
- Handle errors gracefully - provide meaningful error messages to users
- 📖 Full Documentation
- 💬 Discord Community
- 📧 Email: hello@getlumen.dev