apikee · Python
API key plugin for Python — FastAPI, Flask, and Starlette.
Install
pip install apikee # local mode, zero deps
pip install "apikee[fastapi]" # + FastAPI middleware
pip install "apikee[server]" # + encrypted server channel (apikee.dev)
pip install "apikee[all]" # everything
Configure (set 1 env var)
export APIKEE_SECRET=$(openssl rand -hex 32)
# Optional — enables server mode (usage tracking, rate limits, fraud detection)
export APIKEE_SERVER_KEY=sk_live_...
export APIKEE_PROJECT_ENV=my-api-production
FastAPI
from apikee.fastapi import SecuredFastAPI, ApikeeDepends, require_scope
from apikee import ApikeeClaims
from fastapi import Depends
app = SecuredFastAPI() # reads APIKEE_SECRET — done
@app.post("/keys") # public endpoint — issue keys to customers
def create_key(tenant: str, scopes: str = "read,write"):
key = app.apikee.create(tenant, scopes=scopes.split(","))
return {"key": key} # store it — returned once
@app.get("/data")
def get_data(claims: ApikeeClaims = ApikeeDepends()):
return {"tenant": claims.tenant, "scopes": claims.scopes}
@app.delete("/admin", dependencies=[Depends(require_scope("admin"))])
def admin_action(): ...
Open /docs — every endpoint shows the 🔒 lock. Click Authorize, paste a key.
Flask
from flask import Flask
from apikee.flask import init_apikee, apikee_required, require_scope, get_claims
app = Flask(__name__)
init_apikee(app) # reads APIKEE_SECRET — done
@app.get("/data")
@apikee_required
def data():
return {"tenant": get_claims().tenant}
@app.delete("/admin")
@require_scope("admin")
def admin(): ...
Any ASGI
from apikee import Apikee
apikee = Apikee()
app.add_middleware(apikee.middleware) # claims at request.state.apikee
# Or inline, no middleware:
claims = apikee.protect(request.headers.get("x-api-key"))
Key rotation (zero downtime)
export APIKEE_SECRET=new-secret # new keys signed with this
# Old keys still validate during the rotation window — pass both to Apikee():
apikee = Apikee(secrets=["new-secret", "old-secret"])
Workflows
| Workflow | Trigger | Action |
|---|---|---|
ci.yml |
push / PR | Lint + test matrix (Python 3.10–3.12 × 3 OS) |
release.yml |
tag v*.*.* or manual |
Build → PyPI → GitHub Release |
version-bump.yml |
PR label or manual | Bump version, commit, push tag |
hotfix.yml |
manual | Fast-track patch from main |
Release: git tag v1.2.3 && git push --tags
Secrets needed (repo → Settings → Secrets → Actions):
| Secret | Notes |
|---|---|
| PyPI trusted publishing | Configure at pypi.org/manage/account/publishing — no token needed |
PYPI_API_TOKEN |
Alternative to OIDC — uncomment in release.yml |
Docs
Metadata
Release files for apikee 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| apikee-0.1.2.tar.gz | 21.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apikee-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / apikee-0.1.2.tar.gz
| Download URL | apikee-0.1.2.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
faad6606eeab287541299f3eefd8f58654df888182d0aedb6be858e1e3b51894
|
|
BLAKE2b-256 checksum How to use checksums |
6c22277f0430ca3c21540569df9e1bc785107f8212cd24f8e913cb86c7741c56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / apikee-0.1.2-py3-none-any.whl
| Download URL | apikee-0.1.2-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d1b1c94a4f3e59ea8a5370a92e6c06197af866a5babdde990c96b93f4873ef0
|
|
BLAKE2b-256 checksum How to use checksums |
d811db896e2946bfeb4923156c333471055bf6fd40886e64504957011d3c8815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|