SDKs overview
Todoist offers a public API that enables developers to programmatically interact with its task management platform. This API facilitates the creation, retrieval, updating, and deletion of tasks, projects, labels, filters, and other core Todoist entities. To streamline development, Todoist provides official SDKs for popular programming languages. These SDKs abstract the underlying HTTP requests and JSON parsing, allowing developers to focus on application logic rather than direct API communication. The API primarily adheres to a RESTful architecture, utilizing standard HTTP methods and JSON payloads for data exchange. Authentication is typically handled via OAuth 2.0 for third-party applications or personal API tokens for private integrations, ensuring secure access to user data Todoist Help Center.
Beyond the officially supported SDKs, a vibrant community of developers has contributed a range of libraries and wrappers in various programming languages. These community-driven projects often extend functionality, provide alternative approaches, or support languages not covered by the official offerings. While official SDKs are maintained directly by Todoist, community libraries are supported by their respective creators and the broader open-source community. Developers integrating with Todoist have the flexibility to choose between official, supported SDKs for stability and direct support, or community libraries for broader language coverage and specific feature sets.
Official SDKs by language
Todoist maintains official SDKs for Python and JavaScript, which are designed to provide a consistent and supported interface for interacting with the Todoist API. These SDKs are regularly updated to reflect changes in the API and to incorporate new features. They offer a structured way to manage resources such as tasks, projects, and users, by providing client-side methods that map directly to API endpoints. Using official SDKs can simplify development, reduce the likelihood of errors, and ensure compatibility with the latest API versions.
The following table summarizes the key details of the official Todoist SDKs:
| Language | Package Name | Install Command (Example) | Maturity | Description |
|---|---|---|---|---|
| Python | todoist-api-python |
pip install todoist-api-python |
Stable | Official Python client for the Todoist REST API. Provides object-oriented access to tasks, projects, and other data. |
| JavaScript | @todoist/api |
npm install @todoist/api |
Stable | Official JavaScript/TypeScript client for the Todoist REST API, suitable for Node.js and browser environments. |
Installation
Installation of Todoist's official SDKs typically involves using standard package managers for the respective programming languages. These commands download and install the necessary libraries, making them available for import into your development projects.
Python SDK Installation
To install the official Python SDK, todoist-api-python, you can use pip, the standard package installer for Python. It is recommended to use a virtual environment to manage dependencies.
pip install todoist-api-python
After installation, you can import the client and initialize it with your API token:
from todoist_api_python.api import TodoistAPI
api = TodoistAPI("YOUR_API_TOKEN")
JavaScript SDK Installation
For JavaScript projects, the official SDK @todoist/api can be installed using npm or yarn. This package is compatible with both Node.js and browser environments.
npm install @todoist/api
Alternatively, using yarn:
yarn add @todoist/api
Once installed, you can import the TodoistApi client and initialize it:
import { TodoistApi } from '@todoist/api';
const api = new TodoistApi('YOUR_API_TOKEN');
For browser-based applications, ensure you handle API tokens securely, typically by proxying requests through a backend server to avoid exposing credentials directly in client-side code, as described by general API security practices OAuth.net documentation.
Quickstart example
This quickstart example demonstrates how to use the Todoist Python SDK to fetch and print all active tasks for the authenticated user. Before running this code, ensure you have installed the todoist-api-python package and replaced "YOUR_API_TOKEN" with your actual Todoist API token. Your API token can be found in your Todoist settings under Integrations > Developer.
Python Quickstart: Fetching Active Tasks
from todoist_api_python.api import TodoistAPI
from todoist_api_python.models import Task
def get_all_active_tasks(api_token: str):
try:
api = TodoistAPI(api_token)
tasks = api.get_tasks()
print(f"Found {len(tasks)} active tasks:")
for task in tasks:
print(f"- {task.content} (ID: {task.id})")
except Exception as error:
print(error)
# Replace with your actual API token
API_TOKEN = "YOUR_API_TOKEN"
get_all_active_tasks(API_TOKEN)
This script initializes the TodoistAPI client with your token and then calls the get_tasks() method, which returns a list of Task objects. It then iterates through the tasks and prints their content and ID. Error handling is included to catch potential issues during the API call, such as network problems or invalid tokens.
JavaScript Quickstart: Adding a New Task
This JavaScript example demonstrates how to use the @todoist/api SDK to add a new task to your Todoist inbox. Ensure you have installed the package and replaced 'YOUR_API_TOKEN' with your Todoist API token.
import { TodoistApi } from '@todoist/api';
const API_TOKEN = 'YOUR_API_TOKEN'; // Replace with your actual API token
const api = new TodoistApi(API_TOKEN);
async function addNewTask(taskContent) {
try {
const task = await api.addTask({
content: taskContent,
dueString: 'today at 6pm',
priority: 4, // 1 for lowest, 4 for highest
});
console.log('Task added successfully:', task.content, 'with ID:', task.id);
} catch (error) {
console.error('Error adding task:', error);
}
}
addNewTask('Review API documentation for new features');
This JavaScript snippet defines an asynchronous function addNewTask that uses the api.addTask method to create a new task. It specifies the task content, a due date string, and a priority level. The await keyword ensures that the API call completes before proceeding, and error handling is implemented with a try...catch block to manage potential issues during the API request.
Community libraries
The Todoist developer community has developed various unofficial libraries and wrappers that extend the reach of the Todoist API to languages and frameworks not officially supported. These libraries often provide alternative implementations, add convenience methods, or target specific use cases. While not directly maintained by Todoist, many of these projects are open-source and actively supported by their maintainers and contributors.
Some notable community-contributed libraries include:
- PHP: Several PHP wrappers are available, often providing a more object-oriented interface than direct API calls. These can be useful for integrating Todoist into web applications built with frameworks like Laravel or Symfony.
- Ruby: Ruby gems exist for interacting with the Todoist API, enabling Ruby developers to build scripts and applications that manage tasks and projects.
- Go: Go language bindings allow developers to build high-performance applications and microservices that integrate with Todoist, leveraging Go's concurrency features.
- Java: Community-driven Java libraries provide client functionalities for Android development or enterprise Java applications.
- Swift/Objective-C: For iOS and macOS development, there are community libraries that simplify integration with the Todoist API, often leveraging Swift's modern language features.
Developers interested in community libraries should review the project's documentation, GitHub repository, and community activity to assess its maintenance status, feature set, and compatibility with the latest Todoist API version. Searching platforms like GitHub with terms such as "Todoist API client" or "Todoist SDK" alongside the desired programming language can yield relevant results.
When choosing between an official SDK and a community library, consider factors such as the level of support, update frequency, specific features offered, and the reputation of the maintainers. Official SDKs generally offer more stability and direct support from Todoist, while community libraries can offer broader language support and innovative features driven by specific developer needs.