The official Python SDK for AnkhDB - Real-time Multi-tenant BaaS.
Project description
ankhdb
The official Python SDK for AnkhDB — a self-hosted, multi-tenant Backend-as-a-Service with Auth, Database, Storage, and Edge Functions.
Installation
pip install ankhdb
Quick Start
Find your Project ID and API Key in the AnkhDB Dashboard → Settings.
from ankhdb import AnkhDB
db = AnkhDB("YOUR_PROJECT_ID", "YOUR_API_KEY")
# Self-hosted / local override:
# db = AnkhDB("YOUR_PROJECT_ID", "YOUR_API_KEY", server_url="http://localhost:5000")
Authentication
Manage your app's end-users. Enable Require Email Verification in the dashboard to gate logins behind email confirmation.
# Register a new user
res = db.register("user@example.com", "securepassword")
# res["token"] is set automatically (or absent if email verification is required)
# Login
db.login("user@example.com", "securepassword")
# Check current session
session = db.get_session()
# Logout (clears local token)
db.logout()
Database
Schema-free NoSQL collections with optional Row-Level Security (RLS) policies.
posts = db.from_collection("posts")
# Insert
doc = posts.insert({"title": "Hello AnkhDB", "author": "Alice"})
# Read all
all_posts = posts.select()
# Read one
one = posts.get(doc["id"])
# Update
posts.update(doc["id"], {"title": "Updated Title"})
# Delete
posts.delete(doc["id"])
Storage
Upload and manage files up to 50 MB per file.
# Upload a local file
uploaded = db.storage_upload("/path/to/image.png")
print(uploaded["url"]) # Public URL
# List all files
files = db.storage_list()
# Get file metadata
meta = db.storage_get(uploaded["id"])
# Delete
db.storage_delete(uploaded["id"])
Edge Functions
Invoke serverless JavaScript functions you write in the AnkhDB Dashboard.
# Invoke a function named "greet"
res = db.invoke_function("greet", {"name": "Alice"})
print(res["result"]) # Whatever the function set on `result`
Example function code (written in the dashboard):
result = { greeting: `Hello, ${payload.name}!` };
API Reference
| Method | Description |
|---|---|
AnkhDB(project_id, api_key, server_url?, token?) |
Create a client. |
db.register(email, password) |
Register a new end-user. |
db.login(email, password) |
Login and auto-store JWT. |
db.logout() |
Clear the local token. |
db.get_session() |
Verify token, get user info. |
db.from_collection(name) |
Get a query builder for a collection. |
db.get_collections() |
List all collections. |
db.storage_upload(filepath, filename?) |
Upload a local file. |
db.storage_list() |
List all uploaded files. |
db.storage_get(id) |
Get file metadata + URL. |
db.storage_delete(id) |
Delete a file. |
db.invoke_function(name, payload?) |
Invoke an edge function. |
License
MIT © KemetSoft
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ankhdb-2.0.1.tar.gz.
File metadata
- Download URL: ankhdb-2.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fead2cbc383650ae525d9dc15b0c0aed9fd07c2c45bc10206d941e1078b3c60
|
|
| MD5 |
077ed226fd05645aebf43359bacefa14
|
|
| BLAKE2b-256 |
3498e5eaffd60eb4f8b18c4cb56e5d738976c5432746fcac4d31e9581bc1230b
|
File details
Details for the file ankhdb-2.0.1-py3-none-any.whl.
File metadata
- Download URL: ankhdb-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87f7423c55a4c3b0e3e2200769cf5fac4af6eeb0d0144c3c23309ce18392e572
|
|
| MD5 |
6cfe09ab92e80f65b63a0da342d4411b
|
|
| BLAKE2b-256 |
93c4fd63b9e18d8e5870418c5b32d9fa4f33c989343404c5e164247134e87ae8
|