The official Python SDK for interacting with the Todoist API. It provides synchronous and asynchronous clients to manage tasks, projects, labels, filters, and more. The current stable version is 4.0.0, and it generally receives updates aligned with API changes and new features from Todoist.
pip install todoist-api-pythonVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the Todoist API client using an API token (preferably from an environment variable). It then fetches all projects and creates a new task, demonstrating basic read and write operations. Remember to replace 'YOUR_API_TOKEN_HERE' or set the TODOIST_API_TOKEN environment variable.
Review the changelog and update import paths (`from todoist_api_python.api import ...`), method names (e.g., `create_task` instead of `add_task`), and method signatures as needed. Existing code written for v2.x.x will not work without modifications.
Upgrade your Python environment to 3.10 or newer. If you must use an older Python version, consider pinning to `todoist-api-python<4.0.0` for Python 3.8-3.9, or `todoist-api-python<3.0.0` for Python 3.7 and below.
For sync code, use `TodoistAPI`. For async code, use `TodoistAPIAsync` and `await` its methods. Do not mix them directly without proper async/sync bridging.
Always validate project IDs if they are dynamically obtained. If you explicitly want a task in a specific project, ensure the `project_id` is correct and belongs to the user. For inbox tasks, explicitly pass `None` or omit the `project_id`.
Update the import statement to `from todoist_api_python.api import TodoistAPI` as per v3.0.0 and later.
Provide your Todoist API token as the first argument when initializing the client, e.g., `api = TodoistAPI('YOUR_API_TOKEN')` or `api = TodoistAPI(os.environ.get('TODOIST_API_TOKEN'))`.Upgrade your Python environment to 3.10 or newer. Alternatively, if you cannot upgrade Python, install an older version of the library (e.g., `pip install todoist-api-python<4.0.0`).
Update the method call to the new naming convention. `add_item` is now `create_task`. Similarly, `update_item` is `update_task`, and `add_project` is `create_project`, etc.