Skip to main content

rafikidb

Typed Python client for RafikiDB - data, auth, realtime, storage, environment variables, secrets, webhooks, edge functions and payments.

  • Zero required dependencies (stdlib HTTP)
  • Optional websockets for the WebSocket realtime transport
  • Same envelope and error model as the REST API
  • Python 3.10+

Install

pip install rafikidb            # core
pip install rafikidb[realtime]  # with WebSocket realtime

Quick start

from rafikidb import create_client

db = create_client(
    project_id="5c73dab0-...",
    api_key="raf_live_...",
    base_url="https://api.rafikidb.com/api/v1",  # optional
)

Every call returns an Envelope:

rows = db.from_("profiles").select("id, nationality").eq("nationality", "Tanzania").limit(25).execute()
rows.success      # True
rows.data         # list of dicts
rows.message      # "Request was successful"

Failures raise RafikiDBError with message, status, code and errors.

Data

# Filters: eq, neq, gt, gte, lt, lte, like, ilike, is_null, is_not_null, in_
db.from_("profiles").eq("nationality", "Tanzania").is_not_null("user_id")

# Ordering and pagination
db.from_("profiles").order("created_at", ascending=False).limit(50).offset(100)

# Keyset pagination (O(1) per page on large tables)
db.from_("logs").select("id").limit(100).cursor(last_id)

# Joins (column-based, no SQL)
from rafikidb import JoinSpec
rows = (
    db.from_("messages")
    .select("id as message_id, message, users.full_name as full_name")
    .join(JoinSpec(table="users", from_column="user_id", to_column="id"))
    .limit(20)
).execute()
# rows.data[i]["full_name"]

# Row operations
db.from_("profiles").get(record_id)
db.from_("profiles").single()
db.from_("profiles").head()              # {"count": n}
db.from_("profiles").insert({...})       # single or list
db.from_("profiles").update({...}).eq("id", record_id)
db.from_("profiles").delete().eq("id", record_id)

Auth

session = db.auth.signup(
    email="user@example.com", password="strong-pass1",
    full_name="Asha Mwinyi", phone="+255712345678",
)
session = db.auth.login(email="user@example.com", password="strong-pass1")

# The session is stored on the client and sent with every request,
# so RLS sees the logged-in user.
db.client.access_token     # the project-user JWT

db.auth.sign_out()

# OTP
db.auth.otp_request("+255712345678")
db.auth.otp_verify(phone="+255712345678", code="123456", full_name="Asha Mwinyi")

# Password reset
db.auth.reset_password("user@example.com")
db.auth.confirm_reset_password(email="user@example.com", code="123456", new_password="brand-new-pass1")

Realtime

def on_event(event):
    print(event.type, event.table, event.record)

sub = db.realtime.subscribe("messages", on_event, events=["INSERT", "DELETE"])

# Stop listening (or sub.wait() to block)
sub.close()

Default transport: WebSocket when websockets is installed, SSE otherwise.

db.realtime.subscribe("messages", on_event, transport="sse")
db.realtime.subscribe("messages", on_event, transport="websocket")

Storage / env / secrets / webhooks / functions / payments

db.storage.create_bucket(name="Avatars", slug="avatars", is_public=True)
db.storage.signed_upload_url(bucket_id=..., object_name="user-1.png")

db.env.set("STRIPE_KEY", "sk_test_123", environment="production")
db.env.bulk_set("development", {"DEBUG": "true"})

db.secrets.set(key="API_SECRET", value="s3cr3t")
db.secrets.reveal(secret_id)

db.webhooks.create(name="order.created", url="https://myapp.com/hooks/orders", events=["order.created"])
db.webhooks.list_deliveries(webhook_id)

db.functions.create(name="hello", runtime="javascript", code="...")
db.functions.deploy(fn_id)
db.functions.invoke(fn_id, body='{"name":"Asha"}')

db.payments.stk_push(phone="+255712345678", amount=5000, description="Order #123")
db.payments.snippe_status(reference)
db.payments.list_transactions()

Development

pip install -e ".[test]"
python -m unittest discover -s tests -q

Metadata

Release files for rafikidb 0.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 rafikidb 0.1.0
File Size Uploaded Provenance Actions
rafikidb-0.1.0.tar.gz 11.9 kB Without provenance Details for rafikidb-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 25.8 kB

Release files / rafikidb-0.1.0.tar.gz

Download URL rafikidb-0.1.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7f64364179fde040f512d73c88459f4cf79ac22edccfde3365abac8732977f42
BLAKE2b-256 checksum
How to use checksums
10bb178f652c95732e78ad616e31132c9dad4e9b0312caa16fa6cf5b65d8450f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / rafikidb-0.1.0-py3-none-any.whl

Download URL rafikidb-0.1.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2cddd059ad72d453fbfa376a691d0fb2767a9a97f8cad9444f083f74db87596
BLAKE2b-256 checksum
How to use checksums
a15bff95e6c990be0a7534ac6d6c915ed0a780d5e7f02858960edaddc77e1398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for rafikidb 0.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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