Python SDK for the Acontext API
Project description
acontext client for python
Python SDK for interacting with the Acontext REST API.
Installation
pip install acontext
Requires Python 3.10 or newer.
Quickstart
from acontext import AcontextClient, MessagePart
with AcontextClient(api_key="sk_project_token") as client:
# List spaces for the authenticated project
spaces = client.spaces.list()
# Create a session bound to the first space
session = client.sessions.create(space_id=spaces[0]["id"])
# Send a text message to the session
client.sessions.send_message(
session["id"],
role="user",
parts=[MessagePart.text_part("Hello from Python!")],
)
See the inline docstrings for the full list of helpers covering sessions, spaces, disks, and artifact uploads.
Managing disks and artifacts
Artifacts now live under project disks. Create a disk first, then upload files through the disk-scoped helper:
from acontext import AcontextClient, FileUpload
client = AcontextClient(api_key="sk_project_token")
try:
disk = client.disks.create()
client.disks.artifacts.upsert(
disk["id"],
file=FileUpload(
filename="retro_notes.md",
content=b"# Retro Notes\nWe shipped file uploads successfully!\n",
content_type="text/markdown",
),
file_path="/notes/",
meta={"source": "readme-demo"},
)
finally:
client.close()
Working with blocks
from acontext import AcontextClient
client = AcontextClient(api_key="sk_project_token")
space = client.spaces.create()
try:
page = client.blocks.create(space["id"], block_type="page", title="Kick-off Notes")
client.blocks.create(
space["id"],
parent_id=page["id"],
block_type="text",
title="First block",
props={"text": "Plan the sprint goals"},
)
finally:
client.close()
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 acontext-0.0.1.dev4.tar.gz.
File metadata
- Download URL: acontext-0.0.1.dev4.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78741eb9e3f26c425b9abf7a80816106e267ee6cf8b751e77346ff53bf59e8e5
|
|
| MD5 |
331125aae2b6d43bdcfb5733a13dacdd
|
|
| BLAKE2b-256 |
6183ab00d36e14fd3d39ac33f9fcf823be440a863989797dd9e53627dbcbf442
|
File details
Details for the file acontext-0.0.1.dev4-py3-none-any.whl.
File metadata
- Download URL: acontext-0.0.1.dev4-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24e7cd1100a62671a46f07723761e10b028f433e306a647db15499643b6611fe
|
|
| MD5 |
c31981872c9663db16f62fa7902ba1ae
|
|
| BLAKE2b-256 |
e3b2d4323b7ebcccff6251bb4f37fc6be9712fac3643fbd41645b4fc6cc08964
|