Skip to main content

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/retro.md",
        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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acontext-0.0.1.dev2.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acontext-0.0.1.dev2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file acontext-0.0.1.dev2.tar.gz.

File metadata

  • Download URL: acontext-0.0.1.dev2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for acontext-0.0.1.dev2.tar.gz
Algorithm Hash digest
SHA256 43715ecd4dc7c870f2f0a7d530c3bf77c82e374d1e8894c423fe3e8d79485794
MD5 d0cee9832b8082c7293d8c2c2fb76764
BLAKE2b-256 4dd8b5ae36f334637e0525b8c6bfbbeeaede154c966b4bc1f14f9b4fc356d4df

See more details on using hashes here.

File details

Details for the file acontext-0.0.1.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for acontext-0.0.1.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b5f162bd29d1d1752ff8e6a9f1d1f373bb6dea8bfce52b476296675ec6a9c6
MD5 ca803e1722649469ffd742c3842a4466
BLAKE2b-256 b902db49f9ef11fdb36dc3c076e6e93df9fa551f23a057a22662f21acd4ea1ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page