ApiDeck Python SDK
Lightweight API Usage, Performance & Latency Tracking SDK for Python (FastAPI & Flask)
Track API requests, monitor response times, and analyze endpoint performance — effortlessly in Python.
✨ Features
- ⚡ Zero Blocking Overhead: Dispatches tracking payloads asynchronously in a background daemon thread.
- 📊 Automatic Latency & Status Tracking: Accurately measures response durations in milliseconds.
- 🚀 Dual Framework Support: Native integration for FastAPI / Starlette (ASGI) and Flask (WSGI).
- 🛡️ Fail-Safe: Tracker network drops or timeouts never interrupt or crash your user-facing API routes.
- 📦 Zero Required Dependencies: Built entirely on top of Python's standard library.
🚀 Installation
Install from PyPI:
pip install apideck-tracker
Or for local development:
pip install -e .
🔑 Get Your API Key
- Go to https://apideck.site/ and sign in or create an account.
- Go to your dashboard to view your unique
apikey. - Use your
apikeyin your application middleware configuration.
🔧 Quick Start
1. FastAPI / Starlette
from fastapi import FastAPI
from apideck import ApiDeckMiddleware
app = FastAPI()
app.add_middleware(
ApiDeckMiddleware,
apikey="YOUR_API_KEY",
tracker_url="https://apideck.site" # Optional, defaults to https://apideck.site
)
@app.get("/")
def read_root():
return {"message": "Hello from FastAPI!"}
2. Flask
from flask import Flask
from apideck import ApiDeck
app = Flask(__name__)
# Basic Initialization
ApiDeck(
app,
apikey="YOUR_API_KEY",
tracker_url="https://apideck.site" # Optional, defaults to https://apideck.site
)
@app.route("/")
def read_root():
return {"message": "Hello from Flask!"}
Alternative: Flask Application Factory Pattern
from flask import Flask
from apideck import ApiDeck
tracker = ApiDeck()
def create_app():
app = Flask(__name__)
app.config["APIDECK_API_KEY"] = "YOUR_API_KEY"
app.config["APIDECK_TRACKER_URL"] = "https://apideck.site"
tracker.init_app(app)
return app
📖 Configuration Reference
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
apikey |
str |
Yes | — | Your unique ApiDeck API key. |
tracker_url |
str |
No | "https://apideck.site" |
The base URL of your ApiDeck backend. |
📊 Tracked Data Payload
Every request processed by the middleware sends the following JSON payload to /api/usage/log:
{
"apikey": "your_api_key",
"endpoint": "/api/users",
"method": "GET",
"status_code": 200,
"is_success": true,
"response_time_ms": 34,
"ip": "127.0.0.1"
}
🧪 Testing Locally
Check out the included examples in the examples/ directory:
# FastAPI Example
python examples/fastapi_demo.py
# Flask Example
python examples/flask_demo.py
🚢 Publishing to PyPI
When you're ready to publish the SDK to the official Python Package Index:
-
Install build and twine:
pip install build twine
-
Build distribution packages:
python -m build
-
Upload to PyPI:
python -m twine upload dist/*
📄 License
MIT © Aman Kishor
Metadata
Release files for apideck-tracker 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apideck_tracker-1.0.0.tar.gz | 5.8 kB | Without provenance | Details for apideck_tracker-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apideck_tracker-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for apideck_tracker-1.0.0-py3-none-any.whl |
Total release size: 12.2 kB
Release files / apideck_tracker-1.0.0.tar.gz
| Download URL | apideck_tracker-1.0.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
feb8a9dcc5c170895018a9f9357fec35486cd6a711c38d6ed6ab8e7529830a0e
|
|
BLAKE2b-256 checksum How to use checksums |
7aa4756dfc04386795c398da23be7f8f7296df29c89aba4e3260f3199970763e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Release files / apideck_tracker-1.0.0-py3-none-any.whl
| Download URL | apideck_tracker-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46ad8f1b4338df754b20266a487539396afb9e447620d200cdca7bfb5c21d094
|
|
BLAKE2b-256 checksum How to use checksums |
a0419fe9a3a969de8288584a268870294f2384b007dde4b709f195cf28c9d617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Security for apideck-tracker 1.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.