Python SDK Quickstart
Instrument a Python service with registration, heartbeats, structured logs, config, and optional databases.
Package: mpratyush54-sdk · Examples: sdk-python/examples
Installation
pip install mpratyush54-sdk
Basic usage
from platform_sdk import PlatformClient
client = PlatformClient()
client.init(
project_name="my-python-service",
platform_url=os.environ["PLATFORM_URL"],
sdk_token=os.environ["PLATFORM_SDK_TOKEN"], # sdk_live_... from Project -> Tokens
environment_name="development",
)
client.log("INFO", "ready")
print(client.config("FEATURE_X"))
client.shutdown()
Or use the module singleton:
from platform_sdk import platform
# sdk_token defaults to $PLATFORM_SDK_TOKEN
platform.init(project_name="my-service", platform_url="https://api.example.sslip.io")
platform.log("INFO", "hello")
Databases
client.init(
project_name="my-service",
platform_url=os.environ["PLATFORM_URL"],
sdk_token=os.environ["PLATFORM_SDK_TOKEN"],
databases=["postgres", "mongo", "redis"],
)
# Postgres needs PLATFORM_PG_PASSWORD (there is no default password).
rows = client.db["postgres"].execute("SELECT 1")
Managers live under client.db["postgres" | "mongo" | "redis"]. Connection failures are logged and non-blocking.
Logging & storage
client.log("WARN", "high latency", {"route": "/api/users", "ms": 900})
client.storage_upload("/tmp/report.bin", "uploads")
Flask / FastAPI
The SDK does not ship framework middleware yet. Time requests yourself and call client.log(...) — see:
Parameters
| Parameter | Default | Description |
|---|---|---|
project_name |
— | Required |
platform_url |
— | Required API base |
environment_name |
development |
Env label |
version / branch / commit_sha |
— | Build metadata |
databases |
[] |
postgres · mongo · redis |
More examples
| Path | Topic |
|---|---|
01_basic.py |
Init + log + config |
02_with_databases.py |
DB managers |
03_flask_manual_metrics.py |
Flask timing |
04_fastapi_manual_metrics.py |
FastAPI timing |
API reference
PlatformClient · Postgres · Mongo · Redis