Skip to main content

Python SDK

Installation

pip install charlie-mac

Initialise

from charlie_mac import CharlieMacClient
import os

client = CharlieMacClient(
tenant_id=os.environ["AZURE_TENANT_ID"],
client_id=os.environ["AZURE_CLIENT_ID"],
client_secret=os.environ["AZURE_CLIENT_SECRET"],
)

Usage

# List documents
result = client.documents.list(limit=10)

# Get a document
doc = client.documents.get("doc_abc123")

# Create a document
new_doc = client.documents.create(
title="Hello world",
content="# Hello\n\nThis is my first doc.",
)

# Update a document
client.documents.update("doc_abc123", title="Updated title")

# Delete a document
client.documents.delete("doc_abc123")

Error handling

from charlie_mac.exceptions import NotFoundError

try:
doc = client.documents.get("doc_missing")
except NotFoundError:
print("Document not found")