mpratyush54-sdk
Official Python SDK for Platform — registration, heartbeats, logging, config, storage helpers, and managed DB connections.
Requires Python ≥ 3.10. Package: mpratyush54-sdk
Install
pip install mpratyush54-sdk
Optional DB drivers are declared as package dependencies (psycopg2-binary, pymongo, redis).
Quick start
import os
from platform_sdk import PlatformClient # or: from platform_sdk import platform
client = PlatformClient()
client.init(
project_name="my-python-service",
platform_url="https://api.example.sslip.io",
sdk_token=os.environ["PLATFORM_SDK_TOKEN"], # sdk_live_... / sdk_test_... (Project -> Tokens)
environment_name="development",
databases=["postgres", "mongo", "redis"], # optional
)
client.log("INFO", "service ready", {"pid": 1})
flag = client.config("FEATURE_X")
# After init with databases=...
rows = client.db["postgres"].execute("SELECT 1")
client.shutdown()
Singleton style:
from platform_sdk import platform
# sdk_token defaults to the PLATFORM_SDK_TOKEN environment variable
platform.init(project_name="my-service", platform_url="https://api.example.sslip.io")
platform.log("INFO", "hello")
Every Platform API call sends Authorization: Bearer <sdk_token>. Without a token the API rejects
registration, heartbeats, logs and config (an error is logged). Postgres has no default password: set
PLATFORM_PG_PASSWORD (or pass a config with password) or connect() raises.
What init() does
- Registers with
POST /api/sdk/register - Starts a daemon heartbeat thread (every 15s)
- Connects any of
postgres/mongo/redislisted indatabases(non-blocking on failure)
Project Redis credentials
When databases includes redis, initialization fetches /api/sdk/db-credentials with the
SDK token, project and environment. The returned ACL username, password and keyPrefix
are used automatically. If the request is unavailable, the manager falls back to environment
configuration. An explicit Redis provisioning error leaves the manager registered at
client.db["redis"] but disconnected (helpers return None / no-op).
# After client.init(..., databases=["redis"])
r = client.db["redis"]
r.set("ping", "1", ttl=60)
assert r.get("ping") == "1"
assert r.get(r.prefixed("ping")) == "1" # already-prefixed keys stay unchanged
r.delete("ping")
get, set (including TTL) and delete transparently prepend the project's key prefix
once. The Redis ACL enforces access to that prefix on the server. Raw r.client calls
do not prepend it: use r.client.incr(r.prefixed("counter")) and apply prefixed() to
every key argument for multi-key commands. Prefixing is a convenience; Redis ACLs provide
the access boundary.
For a standalone manager, pass RedisManager({"host": "localhost", "port": 6379, "username": "project-user", "password": "...", "key_prefix": "project:"})
from platform_sdk.db.redis. Alternatively set PLATFORM_REDIS_HOST, PLATFORM_REDIS_PORT,
PLATFORM_REDIS_PASSWORD, PLATFORM_REDIS_USERNAME and PLATFORM_REDIS_KEY_PREFIX.
Explicit username and key_prefix config values override their environment values.
Without a username or prefix, existing default-user, unprefixed connections still work.
For TLS, pass url="rediss://host:port/db" (or set PLATFORM_REDIS_URL), or set ssl=True
(PLATFORM_REDIS_TLS=true). PLATFORM_REDIS_DB selects the database. Other redis-py keyword
arguments in the config dict are passed through.
Run examples/05_redis_acl.py with PLATFORM_URL,
PLATFORM_SDK_TOKEN and PROJECT_NAME set (optionally ENVIRONMENT_NAME) to exercise
the project credentials and verify that Redis refuses a read outside the prefix.
For provisioning acceptance, run it against a fresh Ubuntu 24.04
installation created with sudo platformctl provision, with Redis enabled for the project.
An operator can verify the ACL username via CLIENT LIST and the stored key prefix
using administrative Redis access. The SDK token and Redis password should not be printed.
API surface
| Method / prop | Purpose |
|---|---|
init(...) |
Configure + register + optional DBs |
config(key) |
Fetch remote config value (GET /api/sdk/config) |
log(level, message, metadata?) |
Ship a log line |
storage_upload(path, bucket) |
Request an upload URL |
db |
Dict of connected managers (postgres / mongo / redis) |
shutdown() |
Disconnect DBs |
There is no built-in Flask/Django middleware yet — record metrics yourself or put a reverse proxy in front. See examples for manual timing patterns.
Examples
| File | Topic |
|---|---|
examples/01_basic.py |
Init + log + config |
examples/02_with_databases.py |
Postgres / Mongo / Redis |
examples/03_flask_manual_metrics.py |
Flask + timed requests |
examples/04_fastapi_manual_metrics.py |
FastAPI + middleware timing |
examples/05_redis_acl.py |
Project Redis ACL user + key prefix |
Docs: Python quickstart · API
License
MIT
Metadata
Release files for mpratyush54-sdk 2.0.1
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 |
|---|---|---|---|---|
| mpratyush54_sdk-2.0.1.tar.gz | 13.0 kB | With provenance | Details for mpratyush54_sdk-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mpratyush54_sdk-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for mpratyush54_sdk-2.0.1-py3-none-any.whl |
Total release size: 22.6 kB
Release files / mpratyush54_sdk-2.0.1.tar.gz
| Download URL | mpratyush54_sdk-2.0.1.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22f4cbec7e9a2b29175b820f8859aa5b32a3689127bb684acb442743ce0d9c26
|
|
BLAKE2b-256 checksum How to use checksums |
0db2431efa5ee9642e345bb3e4810bbce1d9cef0ce83bbbe093f9b846b5bb2c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 8, 2026.
Transparency logRelease files / mpratyush54_sdk-2.0.1-py3-none-any.whl
| Download URL | mpratyush54_sdk-2.0.1-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a088e29d6498efb7f5805871cfdd8caf031bda76964361a21fc6e6c6590aadc9
|
|
BLAKE2b-256 checksum How to use checksums |
df0ce712a884a30e7f165658b71c60cf2df7d124695c64f367e85ec8e488584a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 8, 2026.
Transparency logSecurity for mpratyush54-sdk 2.0.1
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.
Attestation for mpratyush54_sdk-2.0.1.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 8, 2026.
Transparency logA 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.