Python SDK for interacting with the ContextBase memory API.
Project description
ContextBase Python SDK
A Python SDK for interacting with the ContextBase MCP API, simple key-value memory storage service with authentication and search capabilities.
Installation
pip install contextbase-py
Usage
Initialization
from contextbase import Context
ctx = Context(base_url='https://contextbase.onrender.com')
Authentication
signup_token = ctx.signup('user@example.com', 'password')
login_token = ctx.login('user@example.com', 'password')
ctx.set_token('your-auth-token')
Memory Operations
ctx.set('myKey', 'myValue')
ctx.set('temporaryKey', 'temporaryValue', 3600) # 1 hour TTL
ctx.set('temporaryKey', 'temporaryValue') # Without TTL
memory = ctx.get('myKey')
all_memories = ctx.list()
search_results = ctx.search('queryString')
ctx.delete('myKey')
API Reference
Constructor
Context(
base_url: str,
token: str = None # Optional initially, required for memory operations
)
Methods
| Method | Parameters | Return Type | Description |
|---|---|---|---|
set_token |
token: str |
None |
Sets the authentication token |
signup |
email: str, password: str |
str |
Creates a new user account and returns a token |
login |
email: str, password: str |
str |
Authenticates user and returns a token |
set |
key: str, value: str, ttl: int = None |
dict |
Stores a memory with optional TTL (in seconds) |
get |
key: str |
dict |
Retrieves a memory by key |
list |
None | list |
Lists all memories |
search |
query: str |
list |
Searches memories by query string |
delete |
key: str |
dict |
Deletes a memory by key |
License
MIT
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
contextbase_py-1.0.0.tar.gz
(3.2 kB
view details)
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 contextbase_py-1.0.0.tar.gz.
File metadata
- Download URL: contextbase_py-1.0.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dad34276b6abe248881dba2471fb14b235f2cafb24fdcebf7fcec79aae1787b
|
|
| MD5 |
c224d115b7c09fbfaef3392cdf43654b
|
|
| BLAKE2b-256 |
749f2df054988047c9a6272a5c00107f34784a6a1120b6682bc2753cdc840382
|
File details
Details for the file contextbase_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: contextbase_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f14fa79426f360a984aaea0d21f946bb60b1cb5fea427c2bfc913363b7dd5436
|
|
| MD5 |
81e2d74fedc501b78a6de5a1152cb240
|
|
| BLAKE2b-256 |
aec756cc8782628af17a6dc4a728766c2b392317553130cb178c0de25d06ed91
|