Skip to main content

stitchdb

The official Python client for StitchDB: Postgres database, auth, storage, realtime and Edge Functions. Sync and async.

pip install stitchdb

Python 3.9+. To install the latest code from this repository instead: pip install "git+https://github.com/stitchdb/stitchdb-python".

import os
from stitchdb import create_client

stitchdb = create_client(os.environ["STITCHDB_URL"], os.environ["STITCHDB_KEY"])

# Database (respects Row Level Security)
rows = stitchdb.table("todos").select("id, task").eq("is_complete", False).limit(10).execute().data
stitchdb.table("todos").insert({"task": "Ship it"}).execute()
stitchdb.rpc("search_todos", {"term": "ship"}).execute()

# Auth
stitchdb.auth.sign_in_with_password({"email": "ada@example.com", "password": "..."})
user = stitchdb.auth.get_user()

# Storage
stitchdb.storage.from_("avatars").upload("user-1/avatar.png", open("avatar.png", "rb").read())
url = stitchdb.storage.from_("avatars").create_signed_url("user-1/avatar.png", 60)

# Edge Functions
stitchdb.functions.invoke("hello-world", {"body": {"name": "Ada"}})

Async: from stitchdb import acreate_client and stitchdb = await acreate_client(url, key). Realtime needs the async client.

App services

The same client reaches StitchDB's app services (turn each on in Studio first). Errors raise a subclass of stitchdb.StitchDBAppsError (.status, .code, .message).

stitchdb.flags.load(attributes={"app_version": "2.4.1"})
if stitchdb.flags.is_on("new-checkout"): ...

stitchdb.analytics.track("purchase", {"plan": "pro"}); stitchdb.analytics.flush()
stitchdb.crashes.start(release="2.4.1")          # reports uncaught exceptions
stitchdb.push.register({"platform": "android", "token": fcm_token})
stitchdb.purchases.has_entitlement("pro")
stitchdb.search("articles", "postgres backups", mode="hybrid")
stitchdb.orgs.create("Acme")
offline = stitchdb.offline(["todos"], path="todos.json"); offline.sync()

# Server side, with the service key
stitchdb.jobs.start("send-invoice", {"order": 42}, idempotency_key="order-42")
stitchdb.metering.record("api_calls", 1, customer="acme")

Also: links (deep links), collab (collaborative documents), history (realtime message history and replay), heartbeat (job monitoring), status_page, graphql(), and in stitchdb.auth: sign_in_with_web3, passkey, oauth (consent), mfa.recovery_codes.

Standalone helpers:

from stitchdb import create_sql, verify_webhook, AgentClient

sql = create_sql(os.environ["STITCHDB_SQL_URL"])            # SQL over HTTP: https://<sql key>@<host>
rows = sql.query("select * from orders where id = $1", [42])

event = verify_webhook(request_body, request_headers, secret=WEBHOOK_SECRET)  # raises if not genuine

agent = AgentClient(os.environ["STITCHDB_AGENT_KEY"])        # sdb_agt_ keys for AI agents
agent.sql("select count(*) from orders", session="task-1")

Find your project URL and keys in the dashboard under Settings → API keys. Use the service_role key only on servers you control.

Documentation: https://stitchdb.com/docs/sdk/python

Metadata

Release files for stitchdb 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stitchdb 2.1.0
File Size Uploaded Provenance Actions
stitchdb-2.1.0.tar.gz 148.7 kB Without provenance Details for stitchdb-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stitchdb 2.1.0
File Interpreter ABI Platform Actions
stitchdb-2.1.0-py3-none-any.whl Python 3 none any Details for stitchdb-2.1.0-py3-none-any.whl

Total release size: 370.3 kB

Release files / stitchdb-2.1.0.tar.gz

Download URL stitchdb-2.1.0.tar.gz
Size 148.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c810453c5dcf758f8417005051cf1046c33fecfbfff651d07974c44fd070e929
BLAKE2b-256 checksum
How to use checksums
d5f78e4379eb904d7ae9139a269dd27369c7fdca76d04ef263aa1bfa62405440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / stitchdb-2.1.0-py3-none-any.whl

Download URL stitchdb-2.1.0-py3-none-any.whl
Size 221.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64a64dc86ad2287c0a426377313facbb6cfe0dd9036c769ee4287c1214519908
BLAKE2b-256 checksum
How to use checksums
69e9e3b7efbcc46a580f48be045829414f95af40eed4e03685956f0ede696764
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for stitchdb 2.1.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page