π§ Work in Progress: This SDK is actively being developed and will be continuously updated to provide comprehensive coverage of the entire Todoist API. New endpoints and features are being added regularly. Check the changelog for the latest updates!
An unofficial, lightweight TypeScript/JavaScript SDK for integrating with the Todoist API in Node.js applications.
npm install todoist-nodejs-sdk- Go to Todoist Settings
- Scroll down to "API token" and copy your token
import { Todoist } from 'todoist-nodejs-sdk';
// Initialize the SDK
const todoist = new Todoist({
apiKey: 'your-api-token-here',
});
// Get all projects
const projects = await todoist.projects.getProjects();
console.log('Your projects:', projects);
// Get a specific project
const project = await todoist.projects.getProjectById('project-id');
console.log('Project details:', project);// Get all projects
const projects = await todoist.projects.getProjects();
// Get archived projects
const archivedProjects = await todoist.projects.getArchivedProjects();
// Create a new project
const newProject = await todoist.projects.createProject({
name: 'My New Project',
description: 'A project for organizing tasks',
color: 'blue',
isFavorite: true,
});
// Update a project
const updatedProject = await todoist.projects.updateProject({
projectId: 'project-id',
name: 'Updated Project Name',
description: 'Updated description',
isFavorite: false,
});
// Get project collaborators
const collaborators = await todoist.projects.getProjectColaborators({
projectId: 'project-id',
});
// Get project permissions
const permissions = await todoist.projects.getProjectPermissions();// Get tasks by project
const tasks = await todoist.tasks.getTasks({
projectId: 'project-id',
});
// Get tasks by section
const sectionTasks = await todoist.tasks.getTasks({
sectionId: 'section-id',
});
// Get tasks by label
const labeledTasks = await todoist.tasks.getTasks({
label: 'urgent',
});
// Get specific tasks by IDs
const specificTasks = await todoist.tasks.getTasks({
ids: ['task-id-1', 'task-id-2'],
});
// Create a new task
const newTask = await todoist.tasks.createTask({
content: 'Buy groceries',
description: 'Weekly shopping list',
projectId: 'project-id',
priority: 2,
labels: ['shopping', 'urgent'],
dueDate: '2024-12-31',
});
// Get a specific task by ID
const task = await todoist.tasks.getTaskById('task-id');
// Get completed tasks
const completedTasks = await todoist.tasks.getCompletedTasks({
sortBy: 'completionDate',
projectId: 'project-id',
limit: 10,
});
// Get tasks by filter
const urgentTasks = await todoist.tasks.getTasksByFilter({
filter: '@urgent',
limit: 20,
});
// Quick add a task
const quickTask = await todoist.tasks.quickAddTask({
text: 'Call tomorrow',
note: 'Birthday reminder',
});
// Update a task
const updatedTask = await todoist.tasks.updateTask({
taskId: 'task-id',
content: 'Updated task content',
priority: 4,
labels: ['updated'],
});
// Move a task to different project
await todoist.tasks.moveTask({
taskId: 'task-id',
projectId: 'new-project-id',
});
// Reopen a completed task
const reopenedTask = await todoist.tasks.reopenTask('task-id');
// Close a task
await todoist.tasks.closeTask('task-id');
// Delete a task
await todoist.tasks.deleteTask('task-id');import { Todoist, TodoistError } from 'todoist-nodejs-sdk';
try {
const projects = await todoist.projects.getProjects();
} catch (error) {
if (error instanceof TodoistError) {
console.error('Todoist API Error:', error.message);
console.error('Cause:', error.cause);
} else {
console.error('Unexpected error:', error);
}
}The main class for interacting with the Todoist API.
new Todoist({ apiKey: string });getProjects(request?: GetProjectsRequest): Promise<Project[]>getProjectById(projectId: string): Promise<Project>getArchivedProjects(request?: GetArchivedProjectsRequest): Promise<Project[]>getProjectColaborators(request: GetProjectColaboratorsRequest): Promise<ProjectColaborator[]>getProjectPermissions(): Promise<ProjectPermissions>createProject(request: CreateProjectRequest): Promise<Project>updateProject(request: UpdateProjectRequest): Promise<Project>
getSections(request?: GetSectionsRequest): Promise<Section[]>createSection(request: CreateSectionRequest): Promise<Section>
getTasks(request: GetAllTasksRequest): Promise<Task[]>createTask(request: CreateTaskRequest): Promise<Task>getTaskById(taskId: string): Promise<Task>getCompletedTasks(request: GetCompletedTasksRequest): Promise<CompletedTask[]>getTasksByFilter(request: GetTasksByFilterRequest): Promise<Task[]>quickAddTask(request: QuickAddTaskRequest): Promise<Task>reopenTask(taskId: string): Promise<Task>closeTask(taskId: string): Promise<void>moveTask(request: MoveTaskRequest): Promise<void>updateTask(request: UpdateTaskRequest): Promise<Task>deleteTask(taskId: string): Promise<void>
This SDK is written in TypeScript and includes comprehensive type definitions:
import {
Todoist,
Project,
Task,
CompletedTask,
CreateProjectRequest,
UpdateProjectRequest,
CreateTaskRequest,
UpdateTaskRequest,
GetAllTasksRequest,
GetCompletedTasksRequest,
GetTasksByFilterRequest,
QuickAddTaskRequest,
MoveTaskRequest,
} from 'todoist-nodejs-sdk';For security, store your API token in environment variables:
# .env file
TODOIST_API_KEY=your-api-token-hereimport { Todoist } from 'todoist-nodejs-sdk';
const todoist = new Todoist({
apiKey: process.env.TODOIST_API_KEY!,
});We welcome contributions! Here's how you can help:
Found a bug? Please create an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details (Node.js version, etc.)
Have an idea? We'd love to hear it! Please create an issue with:
- Clear description of the feature
- Use cases and examples
- Any implementation ideas
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes:
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
# Clone the repository
git clone https://github.com/mds2000/todoist-nodejs-sdk.git
cd todoist-nodejs-sdk
# Install dependencies
npm install
# Build the project
npm run build# Run linting
npm run lint
# Build the project
npm run buildThis project is licensed under the MIT License - see the LICENSE file for details.
MatΓas da Silva - GitHub
- π Documentation
- π Report Issues
See CHANGELOG.md for a list of changes and version history.
β Star this repository if you find it helpful!