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.1.1.tar.gz (12.5 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.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_cozi_client-1.1.1.tar.gz
  • Upload date:
  • Size: 12.5 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.1.1.tar.gz
Algorithm Hash digest
SHA256 d06359fbe292de536c18a05b3effda1617d0dcc2b2d52307ec98d8b21154cbc3
MD5 d744ff113ece3e88bd2c9610c92bf00b
BLAKE2b-256 b53b66dedf86e5ba01eea0db8101380210dae00d68f591604c5fe5b7de725cd6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_cozi_client-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf0099ea94830e17ba42b9534a0666d5fe24d22979ca0e7b6bedea7ffe7e4093
MD5 615a8b9005c061cffc034baff98617e2
BLAKE2b-256 f025f185666feb1618729bb86247ec75d6059a6919fb7bc47a8f5b44d853fc70

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