FastAPI integration for the Bella Baxter secret management SDK
Project description
bella-baxter-fastapi
FastAPI integration for the Bella Baxter secrets management platform.
Provides a BellaDepends dependency annotation for injecting a BaxterClient into route handlers.
Installation
pip install bella-baxter-fastapi
Quickstart
from contextlib import asynccontextmanager
from fastapi import FastAPI
from bella_baxter_fastapi import init_bella, BellaDepends
@asynccontextmanager
async def lifespan(app: FastAPI):
init_bella(api_key="bax-...")
yield
app = FastAPI(lifespan=lifespan)
@app.get("/health")
async def health(bella: BellaDepends):
secrets = await bella.get_all_secrets_async()
return {"database": secrets.secrets.get("DATABASE_URL")}
init_bella()
Call once at startup (inside a lifespan handler or module level) to initialise the shared client:
from bella_baxter_fastapi import init_bella
init_bella(
api_key="bax-...",
baxter_url="https://api.bella-baxter.io", # optional
)
BellaDepends
A typed Annotated dependency that injects the shared BaxterClient:
from bella_baxter_fastapi import BellaDepends
@app.get("/secrets")
async def get_secrets(bella: BellaDepends):
resp = await bella.get_all_secrets_async()
return resp.secrets
Configuration via environment variables
import os
from bella_baxter_fastapi import init_bella
init_bella(
api_key=os.environ["BELLA_BAXTER_API_KEY"],
baxter_url=os.environ.get("BELLA_BAXTER_URL", "https://api.bella-baxter.io"),
)
Authentication
Generate an API key via the CLI or the Bella WebApp:
bella api-keys create --env production --name "FastAPI Production"
Using secrets at startup (before first request)
@asynccontextmanager
async def lifespan(app: FastAPI):
init_bella(api_key=os.environ["BELLA_BAXTER_API_KEY"])
# Pre-fetch secrets to warm the cache
from bella_baxter_fastapi import _get_bella_client
client = _get_bella_client()
secrets = await client.get_all_secrets_async()
app.state.db_url = secrets.secrets["DATABASE_URL"]
yield
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bella_baxter_fastapi-0.1.1rc58.tar.gz.
File metadata
- Download URL: bella_baxter_fastapi-0.1.1rc58.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4623de0b109207c099b0bd539359e582530cca0d1934a8990f6e1010c6f1cdb9
|
|
| MD5 |
99d6b0c0ea6af1fa40f318825148fb0c
|
|
| BLAKE2b-256 |
aa2b49fa5393d908687797274c4d0d5593c149fa44da64c2b0fd856c97952506
|
Provenance
The following attestation bundles were made for bella_baxter_fastapi-0.1.1rc58.tar.gz:
Publisher:
publish.yml on Cosmic-Chimps/bella-baxter-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bella_baxter_fastapi-0.1.1rc58.tar.gz -
Subject digest:
4623de0b109207c099b0bd539359e582530cca0d1934a8990f6e1010c6f1cdb9 - Sigstore transparency entry: 1385656163
- Sigstore integration time:
-
Permalink:
Cosmic-Chimps/bella-baxter-python@6b9d4fd2bd3a62ab8df4da2fb47175a5ecb6be61 -
Branch / Tag:
refs/tags/v0.1.1-preview.58 - Owner: https://github.com/Cosmic-Chimps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6b9d4fd2bd3a62ab8df4da2fb47175a5ecb6be61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bella_baxter_fastapi-0.1.1rc58-py3-none-any.whl.
File metadata
- Download URL: bella_baxter_fastapi-0.1.1rc58-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66991e975e2bf9302598fce42f659287d903f979798281df88cbac51341d6368
|
|
| MD5 |
4f635cc7d5016d18b411ba0ef0cba83f
|
|
| BLAKE2b-256 |
a29ad0f6ef7879e7ab5b2de62f2804c51377925c5e969ef1f6cfe2f06792d4ac
|
Provenance
The following attestation bundles were made for bella_baxter_fastapi-0.1.1rc58-py3-none-any.whl:
Publisher:
publish.yml on Cosmic-Chimps/bella-baxter-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bella_baxter_fastapi-0.1.1rc58-py3-none-any.whl -
Subject digest:
66991e975e2bf9302598fce42f659287d903f979798281df88cbac51341d6368 - Sigstore transparency entry: 1385656195
- Sigstore integration time:
-
Permalink:
Cosmic-Chimps/bella-baxter-python@6b9d4fd2bd3a62ab8df4da2fb47175a5ecb6be61 -
Branch / Tag:
refs/tags/v0.1.1-preview.58 - Owner: https://github.com/Cosmic-Chimps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6b9d4fd2bd3a62ab8df4da2fb47175a5ecb6be61 -
Trigger Event:
push
-
Statement type: