Official Python SDK for the Todoist API.
Actively maintained. Last release 4 weeks ago, commits in 15 of the last 26 weeks. A safe choice.
pip install todoist-api-pythonTodoist API Python Client
This is the official Python SDK for the Todoist API.
Installation
pip install todoist-api-python
Or add the project as a dependency in pyproject.toml:
dependencies = [
"todoist-api-python>=3.1.0,<4",
]
Supported Python Versions
Python version 3.10 and above.
Usage
Here's an example of initializing the API client, fetching a task, and paginating through its comments:
from todoist_api_python.api import TodoistAPI
api = TodoistAPI("YOUR_API_TOKEN")
task = api.get_task("6X4Vw2Hfmg73Q2XR")
print(f"Task: {task.content}")
comments_iter = api.get_comments(task_id=task.id)
for comments in comments_iter:
for comment in comments:
print(f"Comment: {comment.content}")
Async usage
Always close TodoistAPIAsync explicitly, either via async with (recommended) or by calling await api.close().
from todoist_api_python.api_async import TodoistAPIAsync
async with TodoistAPIAsync("YOUR_API_TOKEN") as api:
task = await api.get_task("6X4Vw2Hfmg73Q2XR")
print(task.content)
Documentation
For more detailed reference documentation, have a look at the SDK documentation and the API documentation.
Migrating from 3.x
Version 4.x introduces a breaking HTTP stack migration from requests to httpx.
TodoistAPI(..., session=...)is nowTodoistAPI(..., client=...)withhttpx.Client.TodoistAPIAsync(..., session=...)is nowTodoistAPIAsync(..., client=...)withhttpx.AsyncClient.- Error handling should catch
httpx.HTTPStatusErrorinstead ofrequests.exceptions.HTTPError.
Development
To install Python dependencies:
$ uv sync
To install pre-commit:
$ uv run pre-commit install
You can try your changes via REPL by running: