Skip to main content

Async Python client for the Cozi Family Organizer API with full type safety and comprehensive error handling

Project description

py-cozi-client

An unofficial Python client for the Cozi Family Organizer API that provides a robust and type-safe interface to the Cozi service.

Features

  • Async/await support - Built with aiohttp for efficient async operations
  • Type safety - Full type hints and data classes for all API interactions
  • Comprehensive API coverage - Support for lists, calendar, and account management
  • Error handling - Custom exception classes for different error scenarios
  • Rate limiting - Built-in rate limit handling and retry logic
  • Authentication - Secure credential management and session handling

Installation

pip install py-cozi-client

For development:

pip install py-cozi-client[dev]

Quick Start

import asyncio
from cozi_client import CoziClient
from models import ListType, ItemStatus

async def main():
    async with CoziClient() as client:
        # Authenticate
        await client.authenticate("your_username", "your_password")
        
        # Create a shopping list
        shopping_list = await client.create_list("Groceries", ListType.SHOPPING)
        
        # Add items to the list
        await client.add_item(shopping_list.id, "Milk")
        await client.add_item(shopping_list.id, "Bread")
        
        # Get all lists
        lists = await client.get_lists()
        for lst in lists:
            print(f"List: {lst.name} ({lst.type.value})")

asyncio.run(main())

API Reference

CoziClient

The main client class for interacting with the Cozi API.

Authentication

await client.authenticate(username: str, password: str)
await client.logout()

List Management

# Create lists
await client.create_list(name: str, list_type: ListType)

# Get lists
await client.get_lists() -> List[CoziList]
await client.get_list(list_id: str) -> CoziList

# Delete lists
await client.delete_list(list_id: str)

Item Management

# Add items
await client.add_item(list_id: str, text: str, assignee_id: Optional[str] = None)

# Update items
await client.update_item(list_id: str, item_id: str, text: Optional[str] = None, 
                        status: Optional[ItemStatus] = None)

# Remove items
await client.remove_item(list_id: str, item_id: str)

# Get items
await client.get_items(list_id: str) -> List[CoziItem]

Calendar Operations

# Get appointments
await client.get_appointments(start_date: date, end_date: date) -> List[CoziAppointment]

# Create appointments
await client.create_appointment(subject: str, start_time: datetime, 
                               end_time: datetime, location: Optional[str] = None)

Account Management

# Get family members
await client.get_family_members() -> List[CoziPerson]

# Get account information
await client.get_account_info()

Data Models

CoziList

@dataclass
class CoziList:
    id: str
    name: str
    type: ListType
    created_date: datetime
    items: List[CoziItem]

CoziItem

@dataclass
class CoziItem:
    id: str
    text: str
    status: ItemStatus
    assignee_id: Optional[str]
    created_date: datetime

CoziAppointment

@dataclass
class CoziAppointment:
    id: str
    subject: str
    start_time: datetime
    end_time: datetime
    location: Optional[str]
    attendees: List[str]

Enums

class ListType(Enum):
    SHOPPING = "shopping"
    TODO = "todo"

class ItemStatus(Enum):
    COMPLETE = "complete"
    INCOMPLETE = "incomplete"

Exceptions

  • CoziException - Base exception class
  • AuthenticationError - Authentication failures
  • ValidationError - Request validation errors
  • RateLimitError - API rate limit exceeded
  • APIError - General API errors
  • NetworkError - Network connectivity issues
  • ResourceNotFoundError - Resource not found (404)

Development

Setup

git clone <repository-url>
cd py-cozi-client
pip install -e .[dev]

Examples

See the test files for comprehensive usage examples:

  • test_list_operations.py - List and item management
  • test_calendar_operations.py - Calendar and appointment management

Requirements

  • Python 3.7+
  • aiohttp 3.9.2+

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Matthew Jucius

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

py_cozi_client-1.2.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

py_cozi_client-1.2.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file py_cozi_client-1.2.0.tar.gz.

File metadata

  • Download URL: py_cozi_client-1.2.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_cozi_client-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7bf12ba8aee30e8d6b955e0adb28ae115857f8ca3679d62b55644596d8b82194
MD5 cc6cae461c9ecd374df23832dd36e9d1
BLAKE2b-256 e454a8f50157168ee3cfab14b1a47e759bef03196273b5df797ecdf58d6730d9

See more details on using hashes here.

File details

Details for the file py_cozi_client-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: py_cozi_client-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_cozi_client-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8576b8008b697baeb153a78a8b57dc3bda38806242fcab4b16498123f3c17575
MD5 c4a97b7314f867b80808bac0d15c543a
BLAKE2b-256 a274346ec0480f84ff3ce0fd23de5e350d09825f3ff97140bc3953964116babd

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