api

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2025 License: MIT Imports: 0 Imported by: 0

README ΒΆ

todoist-api-go

Go Reference

This repository provides a Go library that implements Todoist API v1.

πŸ“¦ Packages

  • Package todoist implements the base client.

  • Package sync defines models and helpers for the Sync API.

  • Package rest defines models for the RESTful API.

  • Package ws implements a WebSocket client for real-time notifications.

🚧 Implementation Notes

Not all APIs have been implemented. Most of the Sync APIs and a small portion of the RESTful APIs have been implemented.

Feature Status
Sync API
Feature Status
Sections βœ… Implemented
Reminders βœ… Implemented
Projects βœ… Implemented
Labels βœ… Implemented
Tasks βœ… Implemented
Filters βœ… Implemented
User πŸ”„ In progress
Workspace ❌ No plan
Workspace users ❌ No plan
View Options ❌ No plan
Sharing ❌ No plan
Comments ❌ No plan
Live Notifications ❌ No plan
RESTful API
Feature Status
Projects Get Archived βœ… Implemented
Tasks Completed By Completion Date βœ… Implemented
Tasks Completed By Due Date βœ… Implemented
WebSocket API
Feature Status
WebSocket Client βœ… Implemented

πŸ§ͺ Examples

Sync API Basic Usage
token := os.Getenv("API_TOKEN")
cli := todoist.NewClient(http.DefaultClient, token, todoist.DefaultHandler)
taskSvc := todoist.NewTaskService(cli)

_, err := cli.SyncWithAutoToken(context.Background(), true)
if err != nil {
    panic(err)
}

args := &sync.TaskAddArgs{Content: "test"}
_, err = taskSvc.AddTask(context.Background(), args)
if err != nil {
    panic(err)
}
Sync API Multiple Commands
token := os.Getenv("API_TOKEN")
cli := todoist.NewClient(http.DefaultClient, token, todoist.DefaultHandler)

projCmd := sync.NewCommand(&sync.ProjectAddArgs{Name: "test"})

tempID := projCmd.TempID.String()
taskCmd := sync.NewCommand(&sync.TaskAddArgs{Content: "test", ProjectID: &tempID})

_, err := cli.ExecuteCommands(context.Background(), sync.Commands{projCmd, taskCmd})
if err != nil {
    panic(err)
}
RESTful API Basic Usage
token := os.Getenv("API_TOKEN")
cli := todoist.NewClient(http.DefaultClient, token, todoist.DefaultHandler)
taskSvc := todoist.NewTaskService(cli)

req := &rest.TaskQuickAddRequest{Text: "test"}
_, err := taskSvc.QuickAddTask(context.Background(), req)
if err != nil {
    panic(err)
}
Custom Handler
func (h *customHandler) SyncToken(ctx context.Context) (*string, error) {
	// Full sync every time.
	st := sync.DefaultSyncToken
	return &st, nil
}

func (h *customHandler) ResourceTypes(ctx context.Context) (*sync.ResourceTypes, error) {
	// Only sync tasks.
	return &sync.ResourceTypes{sync.Tasks}, nil
}

func (h *customHandler) HandleResponse(ctx context.Context, resp any) error {
	// Print the tasks.
	switch r := resp.(type) {
	case *sync.SyncResponse:
		for _, task := range r.Tasks {
			fmt.Printf("Task ID: %s, Content: %s\n", task.ID, task.Content)
		}
	case *rest.TaskGetCompletedResponse:
		for _, task := range r.Tasks {
			fmt.Printf("Completed Task ID: %s, Content: %s\n", task.ID, task.Content)
		}
	}

	return nil
}

πŸ“š More Examples

You can find more usage examples in todoist-cli, a Todoist CLI client with an integrated WebSocket daemon for real-time syncing.

πŸ” Comparison

Feature todoist-api-go todoist/cli
Exec command and sync in one request βœ… ❌
WebSocket support βœ… ❌
Local filter implementation ❌ βœ…
API version Todoist API v1 Sync API v9

⭐ Credit

Documentation ΒΆ

Overview ΒΆ

Package api provides a Go client for interacting with the Todoist API v1.

Client ΒΆ

Package todoist implements a user-friendly client for the Todoist API, offering a simplified interface for interacting with various resources. It supports using a custom handler to manage sync tokens and handle resource operations, such as storing API responses.

WebSocket ΒΆ

Package ws implements a WebSocket client for receiving real-time sync notifications from the Todoist server. It is useful for enabling automatic background synchronization of tasks and updates.

Directories ΒΆ

Path Synopsis
examples
custom-handler command
Package rest defines the models of the REST API.
Package rest defines the models of the REST API.
Package sync defines the models of the sync API.
Package sync defines the models of the sync API.
Package todoist implements a client for interacting with the Todoist API v1.
Package todoist implements a client for interacting with the Todoist API v1.
Package ws provides a WebSocket client for receiving real-time sync notifications
Package ws provides a WebSocket client for receiving real-time sync notifications

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL