Habify BaseHabify Base
SDKs & AI Tooling

Python & FastAPI SDK (habify-sdk)

Guide for AsyncHabifyClient, HabifyClient, JWKS verification (10-minute cache), dual-secret webhook HMAC helpers, and FastAPI dependency injections.

Last updated: 2026-11-24

1. Install & Configure FastAPI Dependencies

habify-sdk ships synchronous and async httpx clients, 600-second cached JWKS verification (blocking alg=none), and typed FastAPI route dependencies.

py
from fastapi import Depends, FastAPI
from habify_sdk import AsyncHabifyClient, HabifyUser, HabifyWebhookEvent
from habify_sdk.fastapi import (
    configure_habify,
    get_habify_user,
    require_habify_webhook,
)

app = FastAPI()
configure_habify(
    app,
    jwks_url="https://auth.habifyhub.com/api/v1/oauth/jwks",
    issuer="https://auth.habifyhub.com",
    audience="my-project-client-id",
    webhook_secret="whsec_live_current",
    webhook_previous_secret="whsec_live_prev_24h",
)

habify = AsyncHabifyClient(
    base_url="https://my-app.habifybase.app",
    api_key="hb_sk_live_...",
)

@app.get("/orders")
async def list_orders(user: HabifyUser = Depends(get_habify_user)):
    return await (
        habify.db.table("orders")
        .with_user_token(user.raw_token or "")
        .eq("user_id", user.sub)
        .limit(25)
        .execute()
    )