SDKs & Tools
Python SDK
Install and use the AltBase Python SDK for async data queries, authentication, storage, vector search, realtime subscriptions, and more.
Installation
pip install altbasedb
Requires Python 3.11 or later. Uses httpx for HTTP and websockets for realtime.
| Dependency | Version |
|---|---|
httpx | >=0.27, <1 |
websockets | >=13, <15 |
Development Dependencies
pip install altbasedb[dev]
# Includes: pytest, pytest-asyncio, respx
Creating a Client
from altbasedb import create_client
client = create_client("http://localhost:4000", "your-api-key")
The client is async-first. All data methods return awaitable results.
Querying Data
Use the fluent query builder to construct queries:
# Select with filters
result = await client.from_("users").select("id, email, name").eq("id", "123").execute()
print(result.data)
# Insert
await client.from_("posts").insert({"title": "Hello", "body": "First post"}).execute()
# Update
await client.from_("posts").update({"title": "Updated"}).eq("id", 42).execute()
# Delete
await client.from_("posts").delete().eq("id", 42).execute()
Filter Methods
The query builder supports the same filter operators as the JS SDK:
.eq("status", "active")
.neq("role", "admin")
.gt("age", 18)
.gte("price", 10)
.lt("stock", 5)
.lte("priority", 3)
.like("name", "%smith%")
.ilike("email", "%@gmail.com")
.in_("id", [1, 2, 3])
.is_("deleted_at", "null")
Modifiers
.order("created_at", ascending=False)
.limit(10)
.range(0, 9)
.single()
Authentication
# Sign up
await client.auth.sign_up("user@example.com", "securepassword")
# Sign in with password
await client.auth.sign_in_with_password("user@example.com", "password")
# Get current user
user = await client.auth.get_user()
# Sign out
await client.auth.sign_out()
Storage
# Upload a file
with open("photo.jpg", "rb") as f:
await client.storage.from_("avatars").upload("photo.jpg", f.read())
# Download a file
data = await client.storage.from_("avatars").download("photo.jpg")
# Create a signed URL
url = await client.storage.from_("avatars").create_signed_url("photo.jpg", 3600)
# List files
files = await client.storage.from_("avatars").list("user/")
Vector Search
# Similarity search
results = await client.vector("proj_123").search(
"documents",
"embedding",
[0.1, 0.2, 0.3], # query vector
)
# Ask with citations (RAG)
answer = await client.vector("proj_123").ask(
"support",
"How do we rotate API keys?"
)
Full-Text Search
results = await client.search.query("contacts", {
"query": "jane smith",
"fields": ["first_name", "last_name", "email"],
})
Functions
result = await client.functions.invoke("refresh-search", body={"table": "posts"})
GraphQL
result = await client.graphql.query("""
query {
posts(limit: 10) {
id
title
}
}
""")
Events
# Publish an event
await client.events.publish("order.created", {"order_id": "123"})
Realtime
import asyncio
# Subscribe to table changes
channel = client.realtime.channel("realtime:public:posts")
@channel.on("INSERT")
async def on_insert(event):
print("New post:", event)
await channel.subscribe()
# Keep the connection alive
await asyncio.sleep(3600)
Workflows
# Start a workflow run
run = await client.workflows.start("wf_abc123", trigger_data={"email": "user@example.com"})
print(run.id, run.status)
SDK Modules
| Module | Description |
|---|---|
client | Main AltBaseClient class |
auth | Authentication (signup, login, sessions) |
query_builder | Fluent query builder |
storage | Bucket and object operations |
realtime | WebSocket subscriptions |
vector | Vector embeddings and RAG |
search | Full-text search |
functions | Function invocation |
graphql | GraphQL queries |
events | Event pub/sub |
workflows | Workflow automation |
React SDK
Official React hooks for AltBase — data fetching with TanStack Query, realtime CDC subscriptions with automatic cache merging, auth state, and storage.
Dart / Flutter SDK
Install and use the AltBase Dart SDK for cross-platform mobile and web apps — queries, auth, storage, realtime, vector search, and built-in resilience.