This document describes the API naming conventions for the caldav library, including guidance on legacy vs recommended method names.
The caldav library maintains backward compatibility while introducing cleaner API names. Both sync (DAVClient) and async (AsyncDAVClient) clients support the recommended API names.
| Recommended | Legacy | Notes |
|---|---|---|
get_principal() |
principal() |
Returns the Principal object for the authenticated user |
search_principals(name=None) |
principals(name=None) |
Search for principals on the server |
Example:
# Recommended
principal = client.get_principal()
# Legacy (still works, but not recommended for new code)
principal = client.principal()| Recommended | Legacy | Notes |
|---|---|---|
supports_dav() |
check_dav_support() |
Returns DAV support string or None |
supports_caldav() |
check_cdav_support() |
Returns True if CalDAV is supported |
supports_scheduling() |
check_scheduling_support() |
Returns True if RFC6638 scheduling is supported |
Example:
# Recommended
if client.supports_caldav():
calendars = client.get_calendars()
# Legacy (still works, but not recommended for new code)
if client.check_cdav_support():
calendars = client.get_calendars()These methods use the recommended naming and are available in both sync and async clients:
| Method | Description |
|---|---|
get_calendars(principal=None) |
Get all calendars for a principal |
get_events(calendar_url, start, end) |
Get events in a date range |
get_todos(calendar_url, ...) |
Get todos with optional filters |
search_calendar(calendar_url, ...) |
Search calendar with flexible criteria |
| Recommended | Legacy | Notes |
|---|---|---|
add_event(...) |
save_event(...) |
save_event is deprecated; use add_event for adding new events |
add_todo(...) |
save_todo(...) |
save_todo is deprecated; use add_todo for adding new todos |
add_journal(...) |
save_journal(...) |
save_journal is deprecated; use add_journal for adding new journals |
add_object(...) |
save_object(...) |
save_object is deprecated; use add_object for adding new objects |
Note: These methods are for adding new content to the calendar. To update an existing object, fetch it first and use object.save().
See #71 for rationale.
| Recommended | Legacy | Notes |
|---|---|---|
get_event_by_uid(uid) |
event_by_uid(uid) |
event_by_uid is deprecated |
get_todo_by_uid(uid) |
todo_by_uid(uid) |
todo_by_uid is deprecated |
get_journal_by_uid(uid) |
journal_by_uid(uid) |
journal_by_uid is deprecated |
get_object_by_uid(uid) |
object_by_uid(uid) |
object_by_uid is deprecated |
| Recommended | Legacy | Notes |
|---|---|---|
principal.get_calendars() |
principal.calendars() |
calendars is deprecated |
calendar.get_events() |
calendar.events() |
events is deprecated |
calendar.get_todos() |
calendar.todos() |
todos is deprecated |
calendar.get_journals() |
calendar.journals() |
journals is deprecated |
calendar.get_objects_by_sync_token() |
calendar.objects_by_sync_token() |
objects_by_sync_token is deprecated |
| Recommended | Legacy | Notes |
|---|---|---|
search(...) |
date_search(...) |
date_search is deprecated; use search instead |
Example:
# Recommended
events = calendar.search(
start=datetime(2024, 1, 1),
end=datetime(2024, 12, 31),
event=True,
expand=True
)
# Legacy (deprecated, emits DeprecationWarning)
events = calendar.date_search(
start=datetime(2024, 1, 1),
end=datetime(2024, 12, 31),
expand=True
)Calendar.date_search()- useCalendar.search()insteadDAVClient.principals()- useDAVClient.search_principals()insteadCalendarObjectResource.expand_rrule()- expansion is handled bysearch(expand=True)CalendarObjectResource.split_expanded()- expansion is handled bysearch(expand=True)
The following methods are considered "legacy" but will continue to work. New code should prefer the recommended alternatives:
DAVClient.principal()- useget_principal()insteadDAVClient.principals()- usesearch_principals()instead (deprecated with warning)DAVClient.check_dav_support()- usesupports_dav()insteadDAVClient.check_cdav_support()- usesupports_caldav()insteadDAVClient.check_scheduling_support()- usesupports_scheduling()insteadCalendar.save_event()- useadd_event()instead (see issue #71)Calendar.save_todo()- useadd_todo()instead (see issue #71)Calendar.save_journal()- useadd_journal()instead (see issue #71)Calendar.save_object()- useadd_object()instead (see issue #71)Calendar.event_by_uid()- useget_event_by_uid()insteadCalendar.todo_by_uid()- useget_todo_by_uid()insteadCalendar.journal_by_uid()- useget_journal_by_uid()insteadCalendar.object_by_uid()- useget_object_by_uid()insteadPrincipal.calendars()- useget_calendars()insteadCalendar.events()- useget_events()insteadCalendar.todos()- useget_todos()insteadCalendar.journals()- useget_journals()insteadCalendar.objects_by_sync_token()- useget_objects_by_sync_token()instead
The new naming conventions follow these principles:
- Consistency: Same method names work in both sync and async clients
- Clarity:
get_*prefix for methods that retrieve data - Readability:
supports_*is more natural thancheck_*_support - Python conventions: Method names follow PEP 8 style
-
Replace
date_search()withsearch():# Before events = calendar.date_search(start, end, expand=True) # After events = calendar.search(start=start, end=end, event=True, expand=True)
-
Optionally update to new naming conventions:
# Before principal = client.principal() if client.check_cdav_support(): ... # After (recommended) principal = client.get_principal() if client.supports_caldav(): ...
-
Remove usage of deprecated methods:
expand_rrule()- usesearch(expand=True)insteadsplit_expanded()- usesearch(expand=True)instead