Todoist-api
A comprehensive Rust wrapper for the Todoist Unified API v1, providing a clean and ergonomic interface for managing tasks, projects, labels, sections, and comments with cursor-based pagination.
Features
- Async/await support - Built with Tokio for high-performance async operations
- Full CRUD operations - Create, read, update, and delete all Todoist entities
- Project management - Complete project lifecycle management
- Label support - Full label operations with filtering
- Section management - Organize projects with sections
- Comment system - Add and manage comments on tasks and projects
- Advanced filtering - Filter tasks, projects, and labels with pagination
- Type safety - Full Rust type safety with Serde serialization
- Error handling - Comprehensive error handling with specific error types and rate limiting support
- Well-documented - Extensive documentation
Installation
Add this to your Cargo.toml:
[]
= "1.0.0-alpha.1"
Quick Start
use TodoistWrapper;
use CreateTaskArgs;
async
Error Handling
The library provides comprehensive error handling with specific error types that allow you to handle different scenarios appropriately:
use ;
async
Rate Limiting
The library automatically detects rate limiting (HTTP 429) and provides retry information:
use Duration;
// Handle rate limiting with automatic retry
async
Error Types
RateLimited- API rate limiting with retry informationAuthenticationError- Invalid or expired API tokenAuthorizationError- Insufficient permissionsNotFound- Resource not foundValidationError- Invalid request parametersServerError- Todoist server errors (5xx)NetworkError- Network/connection issuesParseError- Response parsing failuresEmptyResponse- Unexpected empty API responsesGeneric- Other errors with optional status codes
API Reference
Creating a Client
let todoist = new;
Task Operations
// Get all tasks (returns paginated response)
let response = todoist.get_tasks.await?;
for task in response.results
// Use response.next_cursor for pagination
if let Some = response.next_cursor
// Get a specific task
let task = todoist.get_task.await?;
// Get tasks for a specific project (paginated)
let response = todoist.get_tasks_for_project.await?;
// Use response.next_cursor for pagination
// Get tasks by filter query (paginated)
let filter_args = TaskFilterArgs ;
let response = todoist.get_tasks_by_filter.await?;
// Create a simple task
let args = CreateTaskArgs ;
let task = todoist.create_task.await?;
// Create a task with full options
let create_args = CreateTaskArgs ;
let task = todoist.create_task.await?;
// Update a task
let update_args = UpdateTaskArgs ;
let updated_task = todoist.update_task.await?;
// Complete a task
todoist.complete_task.await?;
// Reopen a completed task
todoist.reopen_task.await?;
// Delete a task
todoist.delete_task.await?;
// Get completed tasks by completion date (paginated)
use CompletedTasksFilterArgs;
let completed_args = CompletedTasksFilterArgs ;
let response = todoist.get_completed_tasks_by_completion_date.await?;
for task in response.results
// Get completed tasks by due date (paginated)
let response = todoist.get_completed_tasks_by_due_date.await?;
Project Operations
// Get all projects (paginated)
let response = todoist.get_projects.await?;
for project in response.results
// Get a specific project
let project = todoist.get_project.await?;
// Get projects with filtering
let filter_args = ProjectFilterArgs ;
let projects = todoist.get_projects_filtered.await?;
// Create a new project
let create_args = CreateProjectArgs ;
let project = todoist.create_project.await?;
// Update a project
let update_args = UpdateProjectArgs ;
let updated_project = todoist.update_project.await?;
// Delete a project
todoist.delete_project.await?;
Label Operations
// Get all labels (paginated)
let response = todoist.get_labels.await?;
for label in response.results
// Get a specific label
let label = todoist.get_label.await?;
// Get labels with filtering
let filter_args = LabelFilterArgs ;
let labels = todoist.get_labels_filtered.await?;
// Create a new label
let create_args = CreateLabelArgs ;
let label = todoist.create_label.await?;
// Update a label
let update_args = UpdateLabelArgs ;
let updated_label = todoist.update_label.await?;
// Delete a label
todoist.delete_label.await?;
Section Operations
// Get all sections (paginated)
let response = todoist.get_sections.await?;
for section in response.results
// Get a specific section
let section = todoist.get_section.await?;
// Get sections for a project (paginated)
let filter_args = SectionFilterArgs ;
let response = todoist.get_sections_filtered.await?;
// Create a new section
let create_args = CreateSectionArgs ;
let section = todoist.create_section.await?;
// Update a section
let update_args = UpdateSectionArgs ;
let updated_section = todoist.update_section.await?;
// Delete a section
todoist.delete_section.await?;
Comment Operations
// Get all comments
let comments = todoist.get_comments.await?;
// Get a specific comment
let comment = todoist.get_comment.await?;
// Get comments for a task
let filter_args = CommentFilterArgs ;
let task_comments = todoist.get_comments_filtered.await?;
// Create a new comment
let create_args = CreateCommentArgs ;
let comment = todoist.create_comment.await?;
// Update a comment
let update_args = UpdateCommentArgs ;
let updated_comment = todoist.update_comment.await?;
// Delete a comment
todoist.delete_comment.await?;
Data Models
The library provides comprehensive data models for all Todoist entities:
PaginatedResponse<T>- Generic wrapper for paginated API responses withresultsandnext_cursorTask- Complete task information with all fields (v1 API model)Project- Project details and metadataLabel- Label information and stylingSection- Section organization within projects (v1 API model)Comment- Comment system for tasks and projectsAttachment- File attachments for commentsUser- User information and preferencesDue- Due date and time informationDeadline- Deadline informationDuration- Task duration tracking
Argument Types
For flexible API operations, the library provides argument types:
CreateTaskArgs- Full task creation optionsUpdateTaskArgs- Task update parametersCreateProjectArgs- Project creation optionsUpdateProjectArgs- Project update parametersCreateLabelArgs- Label creation optionsUpdateLabelArgs- Label update parametersCreateSectionArgs- Section creation optionsUpdateSectionArgs- Section update parametersCreateCommentArgs- Comment creation optionsUpdateCommentArgs- Comment update parameters
Filter Types
For advanced querying and pagination:
TaskFilterArgs- Task filtering and paginationCompletedTasksFilterArgs- Completed tasks filtering with date rangesProjectFilterArgs- Project filtering and paginationLabelFilterArgs- Label filtering and paginationSectionFilterArgs- Section filtering and paginationCommentFilterArgs- Comment filtering and pagination
Advanced Error Handling
All operations return TodoistResult<T> with specific error types for precise error handling:
use ;
match todoist.get_tasks.await
Error Types
The library provides specific error types for different scenarios:
RateLimited- API rate limiting with retry informationAuthenticationError- Invalid or expired API tokenAuthorizationError- Insufficient permissionsNotFound- Resource not foundValidationError- Invalid request parametersServerError- Todoist server errors (5xx)NetworkError- Network/connection issuesParseError- Response parsing failuresEmptyResponse- Unexpected empty API responsesGeneric- Other errors with optional status codes
Configuration
The library uses sensible defaults:
- 10-second timeout for HTTP requests
- Fallback to default client if custom client creation fails
- Bearer token authentication
- Comprehensive error handling with rate limiting detection
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
For detailed release notes and version history, see CHANGELOG.md.