Skip to main content

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 --pre 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

An API key belongs to one environment. In the Bella WebApp, open the project, choose the Environments tab, open the environment, choose its API Keys tab, then choose Create API Key. The key (bax-<keyId>-<secret>) is shown once, when it is created.

The bella api-keys commands are planned and are not in the CLI yet.

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

Metadata

Release files for bella-baxter-fastapi 0.2.0

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

Source distribution (sdist)

Source distribution for bella-baxter-fastapi 0.2.0
File Size Uploaded Provenance Actions
bella_baxter_fastapi-0.2.0.tar.gz 3.3 kB With provenance Details for bella_baxter_fastapi-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bella-baxter-fastapi 0.2.0
File Interpreter ABI Platform Actions
bella_baxter_fastapi-0.2.0-py3-none-any.whl Python 3 none any Details for bella_baxter_fastapi-0.2.0-py3-none-any.whl

Total release size: 6.8 kB

Release files / bella_baxter_fastapi-0.2.0.tar.gz

Download URL bella_baxter_fastapi-0.2.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
734d75604f309bb9f8645f12c139f5632d6092f3ef32c997d79a144650036bf7
BLAKE2b-256 checksum
How to use checksums
3eaeddb63d45d7a76dcec5702893863ef8140ebb38ded28f062f6baf2cb9bea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / bella_baxter_fastapi-0.2.0-py3-none-any.whl

Download URL bella_baxter_fastapi-0.2.0-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c092f200af4b567a6da341637511b395bcdae42d0239abc9b5da2154707361e8
BLAKE2b-256 checksum
How to use checksums
a58e94c5a6ceeead5c748dfbd00f5411475b4fe9203d734d513019dc80961221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for bella-baxter-fastapi 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bella_baxter_fastapi-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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

0.2.0 This release

2 release files Full provenance

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