Python SDK Quickstart
Get the Chronary Python SDK installed and talking to the API in under 5 minutes.
Install
Section titled “Install”pip install chronaryuv add chronarypoetry add chronaryRequires Python 3.9+.
Authenticate
Section titled “Authenticate”-
Grab your API key from console.chronary.ai.
-
Set it as an environment variable:
Terminal window export CHRONARY_API_KEY="chr_sk_your_key_here" -
Or pass it directly to the client:
from chronary import Chronaryclient = Chronary(api_key="chr_sk_your_key_here")
Register your first agent
Section titled “Register your first agent”from chronary import Chronary
client = Chronary()
agent = client.agents.create( name="Sales Agent - Acme Corp", type="ai", description="Handles meeting scheduling for the sales team",)print(agent.id) # "agt_a1b2c3d4"Create a calendar
Section titled “Create a calendar”calendar = client.agents.calendars.create( agent.id, name="Sales Meetings", timezone="America/New_York",)print(calendar.id) # "cal_x1y2z3"print(calendar.ical_url) # Subscribe to this in Google Calendar!Add an event
Section titled “Add an event”event = client.events.create( calendar_id=calendar.id, title="Strategy sync with Acme Corp", start_time="2026-04-07T14:00:00Z", end_time="2026-04-07T14:30:00Z", description="Quarterly strategy alignment",)print(event.id) # "evt_m1n2o3"Check availability
Section titled “Check availability”availability = client.availability.get( agent_id=agent.id, start="2026-04-07T09:00:00Z", end="2026-04-07T17:00:00Z", slot_duration="30m",)print(f"{len(availability.slots)} available slots found")Async usage
Section titled “Async usage”Every method has an async equivalent via AsyncChronary. This example reuses the calendar you created above rather than creating another agent and calendar, so it fits on the Free plan:
import asynciofrom chronary import AsyncChronary
async def main(): client = AsyncChronary()
calendar = await client.calendars.get("cal_x1y2z3") # the calendar from "Create a calendar"
event = await client.events.create( calendar_id=calendar.id, title="Follow-up with Acme Corp", start_time="2026-04-08T14:00:00Z", end_time="2026-04-08T14:30:00Z", )
await client.close()
asyncio.run(main())Use async with for automatic cleanup:
async with AsyncChronary() as client: agents = client.agents.list() async for agent in agents: print(agent.name)Pagination
Section titled “Pagination”List methods return auto-paging iterators that handle pagination automatically:
# Iterate through all agents (auto-fetches pages)for agent in client.agents.list(): print(agent.name)
# Async iterationasync for agent in client.agents.list(): print(agent.name)For manual control, access the underlying ListResponse:
page = client.agents.list(limit=10)print(page.data) # list of Agent objectsprint(page.total) # total countprint(page.has_more) # whether more pages exist
# Fetch next page manuallynext_page = client.agents.list(limit=10, offset=10)Agent-scoped resources
Section titled “Agent-scoped resources”Access calendars, events, and availability scoped to a specific agent. The calendar you created with client.agents.calendars.create(agent.id, ...) above is one of them:
# List an agent's calendarsfor cal in client.agents.calendars.list("agt_a1b2c3d4"): print(cal.name)
# List events across all of an agent's calendarsfor event in client.agents.events.list("agt_a1b2c3d4"): print(f"{event.title}: {event.start_time}")
# Check an agent's availabilityavailability = client.agents.availability.get( "agt_a1b2c3d4", start="2026-04-07T09:00:00Z", end="2026-04-07T17:00:00Z",)Client configuration
Section titled “Client configuration”Customize the client behavior with constructor options:
import httpxfrom chronary import Chronary
client = Chronary( api_key="chr_sk_...", # API key (or set CHRONARY_API_KEY env var) base_url="https://api.chronary.ai", # Override for testing/staging timeout=60.0, # Request timeout in seconds (default: 60) max_retries=2, # Automatic retries on failure (default: 2) httpx_client=httpx.Client( # Custom httpx client for proxy/transport proxy="http://localhost:8080", ),)The SDK automatically retries on network errors and 429/5xx responses with exponential backoff. A Retry-After header of up to 60 seconds is waited out before the retry. A response whose Retry-After is longer than 60 seconds (such as an iCal sync cooldown or a daily sign-up cap), and a monthly quota error (quota_exceeded), are raised at once instead of retried.
Error handling
Section titled “Error handling”The SDK raises typed exceptions you can catch specifically:
from chronary import Chronary, NotFoundError, RateLimitError, AuthenticationError
client = Chronary()
try: agent = client.agents.get("agt_nonexistent")except NotFoundError as e: print(f"Not found: {e.message}") print(f"Request ID: {e.request_id}")except RateLimitError as e: print(f"Rate limited: {e.message}")except AuthenticationError as e: print(f"Bad API key: {e.message}")See the Error Codes page for the full exception hierarchy.
What’s next?
Section titled “What’s next?”- Quickstart — the same workflow using curl, CLI, and JavaScript
- Calendars guide — org-level vs agent-owned, metadata, iCal URLs
- Webhooks guide — get notified when events change
- API reference — every endpoint documented