todoist

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 15 Imported by: 0

README

go-todoist

Go Reference CI

A clean, idiomatic Go client for the Todoist API v1 — the unified API that merges the former REST and Sync APIs.

  • Zero external dependencies (standard library only).
  • context.Context on every call.
  • Cursor pagination exposed both as raw pages and as iter.Seq2 iterators.
  • REST coverage for tasks, projects, sections, labels, comments, reminders, workspaces, and user, plus the batched Sync API. (Filters have no REST endpoint in v1 and are managed via Sync.)

Requires Go 1.23+ (uses range-over-function iterators).

Install

go get github.com/smirnoffmg/go-todoist

Authentication

Create a client with a personal API token (Todoist → Settings → Integrations → Developer) or an OAuth2 access token:

api := todoist.New(os.Getenv("TODOIST_TOKEN"))

Options: WithHTTPClient, WithBaseURL, WithUserAgent.

Tasks and pagination

Each list resource has two forms: a low-level page fetch (GetTasks) and an auto-paginating iterator (Tasks) that transparently follows the cursor.

ctx := context.Background()
api := todoist.New(os.Getenv("TODOIST_TOKEN"))

// Iterate over every task, following pagination automatically.
for task, err := range api.Tasks(ctx, &todoist.GetTasksArgs{ProjectID: "220474322"}) {
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(task.ID, task.Content)
}

// Or fetch a single page and manage the cursor yourself.
page, err := api.GetTasks(ctx, &todoist.GetTasksArgs{Limit: 50})
if err != nil {
    log.Fatal(err)
}
fmt.Println(len(page.Results), page.NextCursor)

Create, update, and complete a task:

task, err := api.CreateTask(ctx, todoist.CreateTaskArgs{
    Content:   "Buy milk",
    DueString: todoist.Ptr("tomorrow at 9am"),
    Priority:  todoist.Ptr(todoist.PriorityHigh),
})
if err != nil {
    log.Fatal(err)
}

_, _ = api.UpdateTask(ctx, task.ID, todoist.UpdateTaskArgs{Content: todoist.Ptr("Buy oat milk")})
_ = api.CloseTask(ctx, task.ID)

Optional request fields are pointers so an unset field is omitted rather than sent as a zero value. Use the Ptr helper to set them inline.

Error handling

Non-2xx responses return an *todoist.Error carrying the status and body. On rate limiting (429) it also exposes RetryAfter.

_, err := api.GetTask(ctx, "bad-id")
var apiErr *todoist.Error
if errors.As(err, &apiErr) {
    fmt.Println(apiErr.StatusCode, apiErr.RetryAfter)
    if apiErr.Temporary() {
        // safe to retry after apiErr.RetryAfter
    }
}

Sync API

The Sync endpoint batches multiple write commands in one round trip and supports incremental sync via a persisted token. Commands can reference each other's temp_id.

addProject := todoist.NewCommand("project_add", "proj-tmp", map[string]any{"name": "Launch"})
addTask := todoist.NewCommand("item_add", "", map[string]any{
    "content":    "Draft announcement",
    "project_id": "proj-tmp", // resolved via temp_id mapping
})

resp, err := api.Sync(ctx, todoist.SyncRequest{
    ResourceTypes: []string{"projects", "items"},
    Commands:      []todoist.Command{addProject, addTask},
})
if err != nil {
    log.Fatal(err)
}
if err := resp.Err(); err != nil {
    log.Fatal(err) // aggregates per-command failures
}

realProjectID := resp.TempIDMapping["proj-tmp"]
fmt.Println("created project", realProjectID)

// Persist resp.SyncToken and pass it back next time for an incremental sync.

Development

make lint   # golangci-lint run
make test   # go test -race -cover ./... (offline; 100% coverage)
Testing against real Todoist

Integration tests hit the live API. They are gated behind the integration build tag so they never run in the normal offline suite or CI, and they skip automatically unless TODOIST_TOKEN is set. Each test creates its own scratch project/label and deletes it on cleanup, so your existing data is left untouched.

Get a personal token from Todoist → Settings → Integrations → Developer, then:

export TODOIST_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
make test-integration
# or:
go test -tags=integration -run Integration -v ./...

These tests cover the full round trip: authenticating (GetUser), the task lifecycle (create → get → update → close → reopen → delete), sections and comments, labels, project pagination via the iterator, and a read-only Sync.

License

See LICENSE.

Documentation

Overview

Package todoist is a client for the unified Todoist API v1 (https://developer.todoist.com/api/v1/).

It has no external dependencies, takes a context.Context on every call, and exposes cursor pagination both as raw pages and as range-over-function iterators.

Authentication

Construct a client with a personal or OAuth2 token:

api := todoist.New(os.Getenv("TODOIST_TOKEN"))

Pagination

List endpoints have two forms: a low-level page fetch (for example GetTasks) returning a Page, and an auto-paginating iterator (for example Tasks) returning an iter.Seq2 that transparently follows the cursor:

for task, err := range api.Tasks(ctx, nil) {
    if err != nil {
        return err
    }
    fmt.Println(task.Content)
}

Errors

Non-2xx responses are returned as *Error, which carries the status, body, and (on HTTP 429) a RetryAfter duration.

Filters

Todoist API v1 has no REST endpoints for filters; they are managed through the Sync API. See Client.Sync and NewCommand.

Index

Examples

Constants

View Source
const (
	PriorityNormal = 1
	PriorityMedium = 2
	PriorityHigh   = 3
	PriorityUrgent = 4
)

Priority levels for tasks. The API uses 1 (natural, lowest) through 4 (urgent, highest); note this is the reverse of what the Todoist UI shows.

View Source
const DefaultBaseURL = "https://api.todoist.com/api/v1"

DefaultBaseURL is the root of the Todoist API v1.

Variables

This section is empty.

Functions

func NewUUID

func NewUUID() string

NewUUID returns a random RFC 4122 version 4 UUID string, suitable for command and temp IDs.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v. It is a convenience for setting the optional pointer fields on request argument structs inline.

Types

type AccessToken added in v0.2.0

type AccessToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
}

AccessToken is an OAuth2 access token returned by MigratePersonalToken.

type Attachment

type Attachment struct {
	ResourceType string `json:"resource_type,omitempty"`
	FileName     string `json:"file_name,omitempty"`
	FileType     string `json:"file_type,omitempty"`
	FileURL      string `json:"file_url,omitempty"`
	FileSize     int    `json:"file_size,omitempty"`
	UploadState  string `json:"upload_state,omitempty"`
}

Attachment describes a file attached to a comment.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Todoist API v1 client. It is safe for concurrent use as long as its configuration is not mutated after construction.

func New

func New(token string, opts ...Option) *Client

New returns a Client authenticated with the given personal or OAuth2 token.

Example
package main

import (
	"os"

	todoist "github.com/smirnoffmg/go-todoist"
)

func main() {
	api := todoist.New(os.Getenv("TODOIST_TOKEN"))
	_ = api
}

func (*Client) AcceptWorkspaceInvitation added in v0.2.0

func (c *Client) AcceptWorkspaceInvitation(ctx context.Context, inviteCode string) (WorkspaceInvitation, error)

AcceptWorkspaceInvitation accepts an invitation by its invite code.

func (*Client) ArchiveProject

func (c *Client) ArchiveProject(ctx context.Context, id string) error

ArchiveProject archives a project.

func (*Client) ArchiveSection added in v0.2.0

func (c *Client) ArchiveSection(ctx context.Context, id string) error

ArchiveSection archives a section.

func (*Client) ArchivedProjects added in v0.2.0

func (c *Client) ArchivedProjects(ctx context.Context, args *GetProjectsArgs) iter.Seq2[Project, error]

ArchivedProjects returns an iterator over all archived projects, following pagination.

func (*Client) CloseTask

func (c *Client) CloseTask(ctx context.Context, id string) error

CloseTask marks a task as complete.

func (*Client) Comments

func (c *Client) Comments(ctx context.Context, args *GetCommentsArgs) iter.Seq2[Comment, error]

Comments returns an iterator over all comments matching args, following pagination.

func (*Client) CompletedByCompletionDate added in v0.2.0

func (c *Client) CompletedByCompletionDate(ctx context.Context, args *GetCompletedTasksArgs) iter.Seq2[Task, error]

CompletedByCompletionDate iterates over all tasks completed within the time range, following pagination.

func (*Client) CompletedByDueDate added in v0.2.0

func (c *Client) CompletedByDueDate(ctx context.Context, args *GetCompletedTasksArgs) iter.Seq2[Task, error]

CompletedByDueDate iterates over all tasks completed within the time range, keyed by due date, following pagination.

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, args CreateCommentArgs) (Comment, error)

CreateComment creates a new comment.

func (*Client) CreateFolder added in v0.3.0

func (c *Client) CreateFolder(ctx context.Context, args CreateFolderArgs) (Folder, error)

CreateFolder creates a new folder.

func (*Client) CreateLabel

func (c *Client) CreateLabel(ctx context.Context, args CreateLabelArgs) (Label, error)

CreateLabel creates a new personal label.

func (*Client) CreateLocationReminder added in v0.2.0

func (c *Client) CreateLocationReminder(ctx context.Context, args CreateLocationReminderArgs) (LocationReminder, error)

CreateLocationReminder creates a new location reminder.

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, args CreateProjectArgs) (Project, error)

CreateProject creates a new project.

func (*Client) CreateProjectFromFile added in v0.2.0

func (c *Client) CreateProjectFromFile(ctx context.Context, name string, workspaceID *string, file io.Reader, fileName string) (ProjectImportCreateResponse, error)

CreateProjectFromFile creates a new project from a CSV template file. When workspaceID is non-nil the project is created in that workspace.

func (*Client) CreateReminder

func (c *Client) CreateReminder(ctx context.Context, args CreateReminderArgs) (Reminder, error)

CreateReminder creates a new reminder.

func (*Client) CreateSection

func (c *Client) CreateSection(ctx context.Context, args CreateSectionArgs) (Section, error)

CreateSection creates a new section.

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, args CreateTaskArgs) (Task, error)

CreateTask creates a new task.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	todoist "github.com/smirnoffmg/go-todoist"
)

func main() {
	api := todoist.New(os.Getenv("TODOIST_TOKEN"))

	task, err := api.CreateTask(context.Background(), todoist.CreateTaskArgs{
		Content:   "Buy milk",
		DueString: todoist.Ptr("tomorrow at 9am"),
		Priority:  todoist.Ptr(todoist.PriorityHigh),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(task.ID)
}

func (*Client) CreateWorkspace

func (c *Client) CreateWorkspace(ctx context.Context, args CreateWorkspaceArgs) (Workspace, error)

CreateWorkspace creates a new workspace.

func (*Client) DeleteComment

func (c *Client) DeleteComment(ctx context.Context, id string) error

DeleteComment deletes a comment.

func (*Client) DeleteFolder added in v0.3.0

func (c *Client) DeleteFolder(ctx context.Context, id string) error

DeleteFolder deletes a folder.

func (*Client) DeleteLabel

func (c *Client) DeleteLabel(ctx context.Context, id string) error

DeleteLabel deletes a label.

func (*Client) DeleteLocationReminder added in v0.2.0

func (c *Client) DeleteLocationReminder(ctx context.Context, id string) error

DeleteLocationReminder deletes a location reminder.

func (*Client) DeleteProject

func (c *Client) DeleteProject(ctx context.Context, id string) error

DeleteProject deletes a project.

func (*Client) DeleteReminder

func (c *Client) DeleteReminder(ctx context.Context, id string) error

DeleteReminder deletes a reminder.

func (*Client) DeleteSection

func (c *Client) DeleteSection(ctx context.Context, id string) error

DeleteSection deletes a section and all of its tasks.

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, id string) error

DeleteTask deletes a task.

func (*Client) DeleteUpload added in v0.3.0

func (c *Client) DeleteUpload(ctx context.Context, fileURL string) error

DeleteUpload deletes a previously uploaded file by its URL.

func (*Client) DeleteWorkspaceInvitation added in v0.2.0

func (c *Client) DeleteWorkspaceInvitation(ctx context.Context, workspaceID int64, userEmail string) (WorkspaceInvitation, error)

DeleteWorkspaceInvitation revokes a pending invitation.

func (*Client) Folders added in v0.3.0

func (c *Client) Folders(ctx context.Context, workspaceID string, args *GetFoldersArgs) iter.Seq2[Folder, error]

Folders returns an iterator over all folders in a workspace, following pagination.

func (*Client) GetAllWorkspaceInvitations added in v0.2.0

func (c *Client) GetAllWorkspaceInvitations(ctx context.Context, workspaceID string) ([]WorkspaceInvitation, error)

GetAllWorkspaceInvitations returns all invitations for a workspace (admin view).

func (*Client) GetArchivedProjects added in v0.2.0

func (c *Client) GetArchivedProjects(ctx context.Context, args *GetProjectsArgs) (Page[Project], error)

GetArchivedProjects returns a single page of archived projects.

func (*Client) GetCollaborators

func (c *Client) GetCollaborators(ctx context.Context, projectID string, args *GetProjectsArgs) (Page[Collaborator], error)

GetCollaborators returns a page of collaborators for a shared project.

func (*Client) GetComment

func (c *Client) GetComment(ctx context.Context, id string) (Comment, error)

GetComment returns a single comment by ID.

func (*Client) GetComments

func (c *Client) GetComments(ctx context.Context, args *GetCommentsArgs) (Page[Comment], error)

GetComments returns a single page of comments.

func (*Client) GetCompletedByCompletionDate added in v0.2.0

func (c *Client) GetCompletedByCompletionDate(ctx context.Context, args *GetCompletedTasksArgs) (Page[Task], error)

GetCompletedByCompletionDate returns a page of tasks completed within the args' time range, keyed by completion date.

func (*Client) GetCompletedByDueDate added in v0.2.0

func (c *Client) GetCompletedByDueDate(ctx context.Context, args *GetCompletedTasksArgs) (Page[Task], error)

GetCompletedByDueDate returns a page of tasks completed within the args' time range, keyed by due date.

func (*Client) GetFolder added in v0.3.0

func (c *Client) GetFolder(ctx context.Context, id string) (Folder, error)

GetFolder returns a single folder by ID.

func (*Client) GetFolders added in v0.3.0

func (c *Client) GetFolders(ctx context.Context, workspaceID string, args *GetFoldersArgs) (Page[Folder], error)

GetFolders returns a single page of folders in a workspace.

func (*Client) GetLabel

func (c *Client) GetLabel(ctx context.Context, id string) (Label, error)

GetLabel returns a single label by ID.

func (*Client) GetLabels

func (c *Client) GetLabels(ctx context.Context, args *GetLabelsArgs) (Page[Label], error)

GetLabels returns a single page of labels.

func (*Client) GetLocationReminder added in v0.2.0

func (c *Client) GetLocationReminder(ctx context.Context, id string) (LocationReminder, error)

GetLocationReminder returns a single location reminder by ID.

func (*Client) GetLocationReminders added in v0.2.0

func (c *Client) GetLocationReminders(ctx context.Context, args *GetLocationRemindersArgs) (Page[LocationReminder], error)

GetLocationReminders returns a single page of location reminders.

func (*Client) GetProductivityStats

func (c *Client) GetProductivityStats(ctx context.Context) (ProductivityStats, error)

GetProductivityStats returns the authenticated user's completed-task and karma statistics.

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, id string) (Project, error)

GetProject returns a single project by ID.

func (*Client) GetProjects

func (c *Client) GetProjects(ctx context.Context, args *GetProjectsArgs) (Page[Project], error)

GetProjects returns a single page of projects.

func (*Client) GetReminders

func (c *Client) GetReminders(ctx context.Context, args *GetRemindersArgs) (Page[Reminder], error)

GetReminders returns a single page of reminders.

func (*Client) GetSection

func (c *Client) GetSection(ctx context.Context, id string) (Section, error)

GetSection returns a single section by ID.

func (*Client) GetSections

func (c *Client) GetSections(ctx context.Context, args *GetSectionsArgs) (Page[Section], error)

GetSections returns a single page of sections.

func (*Client) GetSharedLabels added in v0.2.0

func (c *Client) GetSharedLabels(ctx context.Context, args *GetSharedLabelsArgs) (Page[string], error)

GetSharedLabels returns a page of shared label names (labels used on tasks but not saved as personal labels).

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id string) (Task, error)

GetTask returns a single task by ID.

func (*Client) GetTasks

func (c *Client) GetTasks(ctx context.Context, args *GetTasksArgs) (Page[Task], error)

GetTasks returns a single page of tasks matching args.

func (*Client) GetTasksByFilter added in v0.2.0

func (c *Client) GetTasksByFilter(ctx context.Context, args *GetTasksByFilterArgs) (Page[Task], error)

GetTasksByFilter returns a page of tasks matching a Todoist filter query. This is the v1 replacement for the removed filters REST endpoints.

func (*Client) GetTemplateFile added in v0.2.0

func (c *Client) GetTemplateFile(ctx context.Context, projectID string, useRelativeDates bool) (string, error)

GetTemplateFile returns a project exported as a CSV template, as raw text.

func (*Client) GetTemplateURL added in v0.2.0

func (c *Client) GetTemplateURL(ctx context.Context, projectID string, useRelativeDates bool) (FileURLResponse, error)

GetTemplateURL returns a URL to a project exported as a template file.

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (User, error)

GetUser returns the authenticated user's profile.

func (*Client) GetWorkspace

func (c *Client) GetWorkspace(ctx context.Context, id string) (Workspace, error)

GetWorkspace returns a single workspace by ID.

func (*Client) GetWorkspaceActiveProjects added in v0.2.0

func (c *Client) GetWorkspaceActiveProjects(ctx context.Context, workspaceID string, args *GetProjectsArgs) (Page[Project], error)

GetWorkspaceActiveProjects returns a page of active projects in a workspace.

func (*Client) GetWorkspaceArchivedProjects added in v0.2.0

func (c *Client) GetWorkspaceArchivedProjects(ctx context.Context, workspaceID string, args *GetProjectsArgs) (Page[Project], error)

GetWorkspaceArchivedProjects returns a page of archived projects in a workspace.

func (*Client) GetWorkspaceInvitations added in v0.2.0

func (c *Client) GetWorkspaceInvitations(ctx context.Context, workspaceID string) ([]WorkspaceInvitation, error)

GetWorkspaceInvitations returns the current user's pending invitations for a workspace.

func (*Client) GetWorkspaceUsers

func (c *Client) GetWorkspaceUsers(ctx context.Context, args *GetWorkspaceUsersArgs) (Page[WorkspaceUser], error)

GetWorkspaceUsers returns a page of members of a workspace.

func (*Client) GetWorkspaces

func (c *Client) GetWorkspaces(ctx context.Context) ([]Workspace, error)

GetWorkspaces returns the workspaces the user belongs to. Unlike the other list endpoints this one is not paginated and returns a plain array.

func (*Client) ImportIntoProjectFromFile added in v0.2.0

func (c *Client) ImportIntoProjectFromFile(ctx context.Context, projectID string, file io.Reader, fileName string) (ProjectImportResponse, error)

ImportIntoProjectFromFile imports a CSV template file into an existing project.

func (*Client) ImportIntoProjectFromTemplateID added in v0.2.0

func (c *Client) ImportIntoProjectFromTemplateID(ctx context.Context, projectID, templateID string, locale *string) (ProjectImportResponse, error)

ImportIntoProjectFromTemplateID imports a shared template into an existing project. Locale is optional (e.g. "en").

func (*Client) JoinProject added in v0.2.0

func (c *Client) JoinProject(ctx context.Context, id string) error

JoinProject adds the current user to a shared project.

func (*Client) JoinWorkspace added in v0.2.0

func (c *Client) JoinWorkspace(ctx context.Context, args JoinWorkspaceArgs) (WorkspaceUser, error)

JoinWorkspace adds the current user to a workspace and returns their membership.

func (*Client) Labels

func (c *Client) Labels(ctx context.Context, args *GetLabelsArgs) iter.Seq2[Label, error]

Labels returns an iterator over all labels, following pagination.

func (*Client) LocationReminders added in v0.2.0

func (c *Client) LocationReminders(ctx context.Context, args *GetLocationRemindersArgs) iter.Seq2[LocationReminder, error]

LocationReminders returns an iterator over all location reminders, following pagination.

func (*Client) MigratePersonalToken added in v0.2.0

func (c *Client) MigratePersonalToken(ctx context.Context, clientID, clientSecret, personalToken, scope string) (AccessToken, error)

MigratePersonalToken exchanges a personal API token for an OAuth2 access token scoped to the given application. Scope is a comma-separated list of OAuth scopes.

func (*Client) MoveTask added in v0.2.0

func (c *Client) MoveTask(ctx context.Context, id string, args MoveTaskArgs) (Task, error)

MoveTask moves a task to a different project, section, or parent task.

func (*Client) Projects

func (c *Client) Projects(ctx context.Context, args *GetProjectsArgs) iter.Seq2[Project, error]

Projects returns an iterator over all projects, following pagination.

func (*Client) QuickAddTask

func (c *Client) QuickAddTask(ctx context.Context, text string) (Task, error)

QuickAddTask creates a task using Todoist's natural-language quick-add syntax.

func (*Client) RejectWorkspaceInvitation added in v0.2.0

func (c *Client) RejectWorkspaceInvitation(ctx context.Context, inviteCode string) (WorkspaceInvitation, error)

RejectWorkspaceInvitation rejects an invitation by its invite code.

func (*Client) Reminders

func (c *Client) Reminders(ctx context.Context, args *GetRemindersArgs) iter.Seq2[Reminder, error]

Reminders returns an iterator over all reminders, following pagination.

func (*Client) RemoveSharedLabel added in v0.2.0

func (c *Client) RemoveSharedLabel(ctx context.Context, name string) error

RemoveSharedLabel removes a shared label from all tasks that use it.

func (*Client) RenameSharedLabel added in v0.2.0

func (c *Client) RenameSharedLabel(ctx context.Context, name, newName string) error

RenameSharedLabel renames a shared label across all tasks that use it.

func (*Client) ReopenTask

func (c *Client) ReopenTask(ctx context.Context, id string) error

ReopenTask reopens a previously completed task.

func (*Client) RevokeToken added in v0.2.0

func (c *Client) RevokeToken(ctx context.Context, clientID, clientSecret, accessToken string) error

RevokeToken revokes an OAuth2 access token. It authenticates with the application's client credentials rather than the client's own token.

func (*Client) SearchLabels added in v0.3.0

func (c *Client) SearchLabels(ctx context.Context, args *SearchLabelsArgs) (Page[Label], error)

SearchLabels returns a page of labels matching the query.

func (*Client) SearchLabelsSeq added in v0.3.0

func (c *Client) SearchLabelsSeq(ctx context.Context, args *SearchLabelsArgs) iter.Seq2[Label, error]

SearchLabelsSeq iterates over all labels matching the query, following pagination.

func (*Client) SearchProjects added in v0.3.0

func (c *Client) SearchProjects(ctx context.Context, args *SearchProjectsArgs) (Page[Project], error)

SearchProjects returns a page of projects matching the query.

func (*Client) SearchProjectsSeq added in v0.3.0

func (c *Client) SearchProjectsSeq(ctx context.Context, args *SearchProjectsArgs) iter.Seq2[Project, error]

SearchProjectsSeq iterates over all projects matching the query, following pagination.

func (*Client) SearchSections added in v0.3.0

func (c *Client) SearchSections(ctx context.Context, args *SearchSectionsArgs) (Page[Section], error)

SearchSections returns a page of sections matching the query.

func (*Client) SearchSectionsSeq added in v0.3.0

func (c *Client) SearchSectionsSeq(ctx context.Context, args *SearchSectionsArgs) iter.Seq2[Section, error]

SearchSectionsSeq iterates over all sections matching the query, following pagination.

func (*Client) Sections

func (c *Client) Sections(ctx context.Context, args *GetSectionsArgs) iter.Seq2[Section, error]

Sections returns an iterator over all sections, following pagination.

func (*Client) SharedLabels added in v0.2.0

func (c *Client) SharedLabels(ctx context.Context, args *GetSharedLabelsArgs) iter.Seq2[string, error]

SharedLabels returns an iterator over all shared label names, following pagination.

func (*Client) Sync

func (c *Client) Sync(ctx context.Context, req SyncRequest) (*SyncResponse, error)

Sync performs a synchronization request against the /sync endpoint, batching any commands in req. Callers should persist the returned SyncToken to make subsequent incremental syncs.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	todoist "github.com/smirnoffmg/go-todoist"
)

func main() {
	api := todoist.New(os.Getenv("TODOIST_TOKEN"))

	addProject := todoist.NewCommand("project_add", "proj-tmp", map[string]any{"name": "Launch"})
	addTask := todoist.NewCommand("item_add", "", map[string]any{
		"content":    "Draft announcement",
		"project_id": "proj-tmp", // resolved via temp_id mapping
	})

	resp, err := api.Sync(context.Background(), todoist.SyncRequest{
		ResourceTypes: []string{"projects", "items"},
		Commands:      []todoist.Command{addProject, addTask},
	})
	if err != nil {
		log.Fatal(err)
	}
	if err := resp.Err(); err != nil {
		log.Fatal(err)
	}
	fmt.Println("created project", resp.TempIDMapping["proj-tmp"])
	// Persist resp.SyncToken for the next incremental sync.
}

func (*Client) Tasks

func (c *Client) Tasks(ctx context.Context, args *GetTasksArgs) iter.Seq2[Task, error]

Tasks returns an iterator over all tasks matching args, transparently following pagination cursors.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	todoist "github.com/smirnoffmg/go-todoist"
)

func main() {
	api := todoist.New(os.Getenv("TODOIST_TOKEN"))

	// The iterator follows pagination cursors automatically.
	for task, err := range api.Tasks(context.Background(), &todoist.GetTasksArgs{ProjectID: "220474322"}) {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(task.ID, task.Content)
	}
}

func (*Client) TasksByFilter added in v0.2.0

func (c *Client) TasksByFilter(ctx context.Context, args *GetTasksByFilterArgs) iter.Seq2[Task, error]

TasksByFilter iterates over all tasks matching a filter query, following pagination.

func (*Client) UnarchiveProject

func (c *Client) UnarchiveProject(ctx context.Context, id string) error

UnarchiveProject restores an archived project.

func (*Client) UnarchiveSection added in v0.2.0

func (c *Client) UnarchiveSection(ctx context.Context, id string) error

UnarchiveSection restores an archived section.

func (*Client) UpdateComment

func (c *Client) UpdateComment(ctx context.Context, id string, args UpdateCommentArgs) (Comment, error)

UpdateComment updates an existing comment.

func (*Client) UpdateFolder added in v0.3.0

func (c *Client) UpdateFolder(ctx context.Context, id string, args UpdateFolderArgs) (Folder, error)

UpdateFolder updates an existing folder.

func (*Client) UpdateLabel

func (c *Client) UpdateLabel(ctx context.Context, id string, args UpdateLabelArgs) (Label, error)

UpdateLabel updates an existing label.

func (*Client) UpdateLocationReminder added in v0.2.0

func (c *Client) UpdateLocationReminder(ctx context.Context, id string, args UpdateLocationReminderArgs) (LocationReminder, error)

UpdateLocationReminder updates an existing location reminder.

func (*Client) UpdateProject

func (c *Client) UpdateProject(ctx context.Context, id string, args UpdateProjectArgs) (Project, error)

UpdateProject updates an existing project.

func (*Client) UpdateReminder

func (c *Client) UpdateReminder(ctx context.Context, id string, args UpdateReminderArgs) (Reminder, error)

UpdateReminder updates an existing reminder.

func (*Client) UpdateSection

func (c *Client) UpdateSection(ctx context.Context, id string, args UpdateSectionArgs) (Section, error)

UpdateSection updates an existing section.

func (*Client) UpdateTask

func (c *Client) UpdateTask(ctx context.Context, id string, args UpdateTaskArgs) (Task, error)

UpdateTask updates an existing task and returns the updated resource.

func (*Client) UpdateWorkspace

func (c *Client) UpdateWorkspace(ctx context.Context, id string, args UpdateWorkspaceArgs) (Workspace, error)

UpdateWorkspace updates an existing workspace.

func (*Client) UploadFile added in v0.3.0

func (c *Client) UploadFile(ctx context.Context, file io.Reader, fileName string, projectID *string) (UploadResult, error)

UploadFile uploads a file and returns its metadata. When projectID is non-nil the upload is associated with that project.

func (*Client) WorkspaceActiveProjects added in v0.2.0

func (c *Client) WorkspaceActiveProjects(ctx context.Context, workspaceID string, args *GetProjectsArgs) iter.Seq2[Project, error]

WorkspaceActiveProjects iterates over all active projects in a workspace.

func (*Client) WorkspaceArchivedProjects added in v0.2.0

func (c *Client) WorkspaceArchivedProjects(ctx context.Context, workspaceID string, args *GetProjectsArgs) iter.Seq2[Project, error]

WorkspaceArchivedProjects iterates over all archived projects in a workspace.

type Collaborator

type Collaborator struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Collaborator is a user who shares a project.

type Command

type Command struct {
	Type   string `json:"type"`
	UUID   string `json:"uuid"`
	TempID string `json:"temp_id,omitempty"`
	Args   any    `json:"args"`
}

Command is a single write operation submitted to the Sync API. Multiple commands can be batched in one Sync call and may reference each other's temp_id values.

func NewCommand

func NewCommand(commandType, tempID string, args any) Command

NewCommand builds a Command with a freshly generated UUID. Pass a non-empty tempID when the created object needs to be referenced by later commands in the same batch.

type Comment

type Comment struct {
	ID         string      `json:"id"`
	TaskID     string      `json:"task_id"`
	ProjectID  string      `json:"project_id"`
	Content    string      `json:"content"`
	PostedAt   string      `json:"posted_at"`
	PostedUID  string      `json:"posted_uid"`
	Attachment *Attachment `json:"attachment"`
}

Comment is a comment on a task or project.

type CreateCommentArgs

type CreateCommentArgs struct {
	Content    string      `json:"content"`
	TaskID     *string     `json:"task_id,omitempty"`
	ProjectID  *string     `json:"project_id,omitempty"`
	Attachment *Attachment `json:"attachment,omitempty"`
}

CreateCommentArgs are the parameters for creating a comment. Content and exactly one of TaskID or ProjectID are required.

type CreateFolderArgs added in v0.3.0

type CreateFolderArgs struct {
	Name         string `json:"name"`
	WorkspaceID  int64  `json:"workspace_id"`
	DefaultOrder *int   `json:"default_order,omitempty"`
	ChildOrder   *int   `json:"child_order,omitempty"`
}

CreateFolderArgs are the parameters for creating a folder. Name and WorkspaceID are required.

type CreateLabelArgs

type CreateLabelArgs struct {
	Name       string  `json:"name"`
	Color      *string `json:"color,omitempty"`
	Order      *int    `json:"order,omitempty"`
	IsFavorite *bool   `json:"is_favorite,omitempty"`
}

CreateLabelArgs are the parameters for creating a label. Name is required.

type CreateLocationReminderArgs added in v0.2.0

type CreateLocationReminderArgs struct {
	TaskID     string `json:"task_id"`
	Name       string `json:"name"`
	LocLat     string `json:"loc_lat"`
	LocLong    string `json:"loc_long"`
	LocTrigger string `json:"loc_trigger"`
	Radius     *int   `json:"radius,omitempty"`
}

CreateLocationReminderArgs are the parameters for creating a location reminder. TaskID, Name, LocLat, LocLong and LocTrigger are required; LocTrigger is "on_enter" or "on_leave".

type CreateProjectArgs

type CreateProjectArgs struct {
	Name       string  `json:"name"`
	ParentID   *string `json:"parent_id,omitempty"`
	Color      *string `json:"color,omitempty"`
	IsFavorite *bool   `json:"is_favorite,omitempty"`
	ViewStyle  *string `json:"view_style,omitempty"`
}

CreateProjectArgs are the parameters for creating a project. Name is required.

type CreateReminderArgs

type CreateReminderArgs struct {
	ItemID      string  `json:"item_id"`
	Type        string  `json:"type"`
	DueString   *string `json:"due_string,omitempty"`
	DueDate     *string `json:"due_date,omitempty"`
	DueDatetime *string `json:"due_datetime,omitempty"`
	MinuteBias  *int    `json:"minute_offset,omitempty"`
	Name        *string `json:"name,omitempty"`
	LocLat      *string `json:"loc_lat,omitempty"`
	LocLong     *string `json:"loc_long,omitempty"`
	LocTrigger  *string `json:"loc_trigger,omitempty"`
	Radius      *int    `json:"radius,omitempty"`
}

CreateReminderArgs are the parameters for creating a reminder. ItemID and Type are required.

type CreateSectionArgs

type CreateSectionArgs struct {
	Name      string `json:"name"`
	ProjectID string `json:"project_id"`
	Order     *int   `json:"order,omitempty"`
}

CreateSectionArgs are the parameters for creating a section. Name and ProjectID are required.

type CreateTaskArgs

type CreateTaskArgs struct {
	Content      string   `json:"content"`
	Description  *string  `json:"description,omitempty"`
	ProjectID    *string  `json:"project_id,omitempty"`
	SectionID    *string  `json:"section_id,omitempty"`
	ParentID     *string  `json:"parent_id,omitempty"`
	Order        *int     `json:"order,omitempty"`
	Labels       []string `json:"labels,omitempty"`
	Priority     *int     `json:"priority,omitempty"`
	AssigneeID   *string  `json:"assignee_id,omitempty"`
	DueString    *string  `json:"due_string,omitempty"`
	DueDate      *string  `json:"due_date,omitempty"`
	DueDatetime  *string  `json:"due_datetime,omitempty"`
	DueLang      *string  `json:"due_lang,omitempty"`
	Deadline     *string  `json:"deadline_date,omitempty"`
	Duration     *int     `json:"duration,omitempty"`
	DurationUnit *string  `json:"duration_unit,omitempty"`
}

CreateTaskArgs are the parameters for creating a task. Content is required; pointer fields are omitted from the request when nil.

type CreateWorkspaceArgs

type CreateWorkspaceArgs struct {
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
}

CreateWorkspaceArgs are the parameters for creating a workspace. Name is required.

type DayStats

type DayStats struct {
	Date           string `json:"date"`
	TotalCompleted int    `json:"total_completed"`
}

DayStats holds completion counts for a single day.

type Deadline

type Deadline struct {
	Date string `json:"date"`
	Lang string `json:"lang,omitempty"`
}

Deadline represents a task deadline (a full-day date).

type Due

type Due struct {
	Date        string `json:"date"`
	String      string `json:"string"`
	Lang        string `json:"lang"`
	IsRecurring bool   `json:"is_recurring"`
	Timezone    string `json:"timezone,omitempty"`
}

Due represents the due date of a task.

type Duration

type Duration struct {
	Amount int    `json:"amount"`
	Unit   string `json:"unit"`
}

Duration represents the estimated duration of a task.

type Error

type Error struct {
	// StatusCode is the HTTP status code of the response.
	StatusCode int
	// Status is the HTTP status text of the response.
	Status string
	// Body is the raw response body, typically a JSON error payload.
	Body string
	// RetryAfter is populated from the Retry-After header on 429 responses.
	RetryAfter time.Duration
}

Error is returned for any non-2xx response from the Todoist API. It carries the HTTP status and the raw response body so callers can inspect the failure.

Example
package main

import (
	"context"
	"errors"
	"fmt"
	"os"

	todoist "github.com/smirnoffmg/go-todoist"
)

func main() {
	api := todoist.New(os.Getenv("TODOIST_TOKEN"))

	_, err := api.GetTask(context.Background(), "does-not-exist")
	var apiErr *todoist.Error
	if errors.As(err, &apiErr) {
		fmt.Println(apiErr.StatusCode)
		if apiErr.Temporary() {
			// Retry after apiErr.RetryAfter.
		}
	}
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Temporary

func (e *Error) Temporary() bool

Temporary reports whether the error is likely transient (rate limiting or a server-side failure) and the request may succeed if retried.

type FileURLResponse added in v0.2.0

type FileURLResponse struct {
	FileName string `json:"file_name"`
	FileURL  string `json:"file_url"`
}

FileURLResponse points to a generated template file.

type Filter

type Filter struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Query      string `json:"query"`
	Color      string `json:"color"`
	Order      int    `json:"item_order"`
	IsFavorite bool   `json:"is_favorite"`
}

Filter is a saved filter query.

The Todoist API v1 does not expose filters as REST endpoints; they are managed through the Sync API using the "filter_add", "filter_update" and "filter_delete" commands, and returned in SyncResponse.Filters when "filters" is among the requested resource types. See Sync and NewCommand.

type Folder added in v0.3.0

type Folder struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	WorkspaceID  string `json:"workspace_id"`
	DefaultOrder int    `json:"default_order"`
	ChildOrder   int    `json:"child_order"`
	IsDeleted    bool   `json:"is_deleted"`
}

Folder groups projects within a workspace.

type GetCommentsArgs

type GetCommentsArgs struct {
	TaskID    string
	ProjectID string
	Cursor    string
	Limit     int
}

GetCommentsArgs controls listing of comments. Exactly one of TaskID or ProjectID must be set.

type GetCompletedTasksArgs added in v0.2.0

type GetCompletedTasksArgs struct {
	Since       time.Time
	Until       time.Time
	WorkspaceID string
	ProjectID   string
	SectionID   string
	ParentID    string
	FilterQuery string
	FilterLang  string
	Cursor      string
	Limit       int
}

GetCompletedTasksArgs are the parameters for the completed-task endpoints. Since and Until define the (inclusive, exclusive) time range and are required; the remaining fields are optional filters and pagination controls.

type GetFoldersArgs added in v0.3.0

type GetFoldersArgs struct {
	Cursor string
	Limit  int
}

GetFoldersArgs controls listing and pagination of folders.

type GetLabelsArgs

type GetLabelsArgs struct {
	Cursor string
	Limit  int
}

GetLabelsArgs controls listing and pagination of labels.

type GetLocationRemindersArgs added in v0.2.0

type GetLocationRemindersArgs struct {
	TaskID string
	Cursor string
	Limit  int
}

GetLocationRemindersArgs controls listing and pagination of location reminders.

type GetProjectsArgs

type GetProjectsArgs struct {
	Cursor string
	Limit  int
}

GetProjectsArgs controls listing and pagination of projects.

type GetRemindersArgs

type GetRemindersArgs struct {
	Cursor string
	Limit  int
}

GetRemindersArgs controls listing and pagination of reminders.

type GetSectionsArgs

type GetSectionsArgs struct {
	ProjectID string
	Cursor    string
	Limit     int
}

GetSectionsArgs controls listing and pagination of sections.

type GetSharedLabelsArgs added in v0.2.0

type GetSharedLabelsArgs struct {
	OmitPersonal bool
	Cursor       string
	Limit        int
}

GetSharedLabelsArgs controls listing of shared labels. When OmitPersonal is true, labels that also exist as personal labels are excluded.

type GetTasksArgs

type GetTasksArgs struct {
	ProjectID string
	SectionID string
	ParentID  string
	Label     string
	Cursor    string
	Limit     int
}

GetTasksArgs are the filters and pagination controls for listing tasks. All fields are optional.

type GetTasksByFilterArgs added in v0.2.0

type GetTasksByFilterArgs struct {
	Query  string
	Lang   string
	Cursor string
	Limit  int
}

GetTasksByFilterArgs are the parameters for querying tasks with a filter string. Query is required.

type GetWorkspaceUsersArgs

type GetWorkspaceUsersArgs struct {
	WorkspaceID string
	Cursor      string
	Limit       int
}

GetWorkspaceUsersArgs controls listing and pagination of workspace members.

type JoinWorkspaceArgs added in v0.2.0

type JoinWorkspaceArgs struct {
	InviteCode  *string `json:"invite_code,omitempty"`
	WorkspaceID *string `json:"workspace_id,omitempty"`
}

JoinWorkspaceArgs identifies the workspace to join, by invite code or by workspace ID (for open workspaces). At least one should be set.

type Label

type Label struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Color      string `json:"color"`
	Order      int    `json:"item_order"`
	IsFavorite bool   `json:"is_favorite"`
}

Label is a personal label.

type LocationReminder added in v0.2.0

type LocationReminder struct {
	ID         string `json:"id"`
	ItemID     string `json:"item_id"`
	ProjectID  string `json:"project_id"`
	NotifyUID  string `json:"notify_uid"`
	Name       string `json:"name"`
	LocLat     string `json:"loc_lat"`
	LocLong    string `json:"loc_long"`
	LocTrigger string `json:"loc_trigger"`
	Radius     int    `json:"radius"`
	Type       string `json:"type"`
	IsDeleted  bool   `json:"is_deleted"`
}

LocationReminder is a reminder that triggers on arriving at or leaving a geographic location.

type MoveTaskArgs added in v0.2.0

type MoveTaskArgs struct {
	ProjectID *string `json:"project_id,omitempty"`
	SectionID *string `json:"section_id,omitempty"`
	ParentID  *string `json:"parent_id,omitempty"`
}

MoveTaskArgs specifies where to move a task. Exactly one destination should be set.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(raw string) Option

WithBaseURL overrides the API base URL. Useful for testing against a stub server. The trailing slash, if any, is trimmed.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets the underlying HTTP client used for requests.

func WithRetry added in v0.2.0

func WithRetry(maxRetries int) Option

WithRetry enables retrying requests that fail with HTTP 429 or 5xx, up to maxRetries additional attempts. Between attempts the client waits for the Retry-After duration when the server provides one, otherwise an exponential backoff. Retries respect context cancellation. Retrying is disabled by default (maxRetries <= 0).

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent sets the User-Agent header sent with each request.

type Page

type Page[T any] struct {
	Results    []T    `json:"results"`
	NextCursor string `json:"next_cursor"`
}

Page is a single page of a cursor-paginated list response. NextCursor is empty when there are no further pages.

type ProductivityStats

type ProductivityStats struct {
	KarmaLastUpdate float64        `json:"karma_last_update"`
	KarmaTrend      string         `json:"karma_trend"`
	Karma           float64        `json:"karma"`
	CompletedCount  int            `json:"completed_count"`
	DaysItems       []DayStats     `json:"days_items"`
	WeekItems       []WeekStats    `json:"week_items"`
	Goals           map[string]any `json:"goals"`
}

ProductivityStats holds the user's karma and completion statistics.

type Project

type Project struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Color          string `json:"color"`
	ParentID       string `json:"parent_id"`
	Order          int    `json:"child_order"`
	CommentCount   int    `json:"comment_count"`
	IsShared       bool   `json:"is_shared"`
	IsFavorite     bool   `json:"is_favorite"`
	IsInboxProject bool   `json:"is_inbox_project"`
	IsArchived     bool   `json:"is_archived"`
	ViewStyle      string `json:"view_style"`
	WorkspaceID    string `json:"workspace_id"`
	URL            string `json:"url"`
}

Project is a Todoist project.

type ProjectImportCreateResponse added in v0.2.0

type ProjectImportCreateResponse struct {
	ProjectImportResponse
	ProjectID string `json:"project_id"`
}

ProjectImportCreateResponse is returned when a template creates a new project.

type ProjectImportResponse added in v0.2.0

type ProjectImportResponse struct {
	Status       string    `json:"status"`
	TemplateType string    `json:"template_type"`
	Projects     []Project `json:"projects"`
	Sections     []Section `json:"sections"`
	Tasks        []Task    `json:"tasks"`
	Comments     []Comment `json:"comments"`
	ProjectNotes []Comment `json:"project_notes"`
}

ProjectImportResponse is returned when a template is imported into an existing project.

type Reminder

type Reminder struct {
	ID         string `json:"id"`
	ItemID     string `json:"item_id"`
	Type       string `json:"type"`
	Due        *Due   `json:"due"`
	MinuteBias int    `json:"minute_offset"`
	Name       string `json:"name"`
	LocLat     string `json:"loc_lat"`
	LocLong    string `json:"loc_long"`
	LocTrigger string `json:"loc_trigger"`
	Radius     int    `json:"radius"`
	IsDeleted  bool   `json:"is_deleted"`
}

Reminder is a reminder attached to a task.

type SearchLabelsArgs added in v0.3.0

type SearchLabelsArgs struct {
	Query  string
	Cursor string
	Limit  int
}

SearchLabelsArgs are the parameters for searching labels. Query is required.

type SearchProjectsArgs added in v0.3.0

type SearchProjectsArgs struct {
	Query  string
	Cursor string
	Limit  int
}

SearchProjectsArgs are the parameters for searching projects. Query is required.

type SearchSectionsArgs added in v0.3.0

type SearchSectionsArgs struct {
	Query     string
	ProjectID string
	Cursor    string
	Limit     int
}

SearchSectionsArgs are the parameters for searching sections. Query is required.

type Section

type Section struct {
	ID          string `json:"id"`
	ProjectID   string `json:"project_id"`
	Name        string `json:"name"`
	Order       int    `json:"section_order"`
	IsArchived  bool   `json:"is_archived"`
	WorkspaceID string `json:"workspace_id"`
}

Section is a section within a project.

type SyncRequest

type SyncRequest struct {
	SyncToken     string
	ResourceTypes []string
	Commands      []Command
}

SyncRequest is the payload for a call to the Sync API. An empty SyncToken is sent as "*", requesting a full sync.

type SyncResponse

type SyncResponse struct {
	SyncToken     string                     `json:"sync_token"`
	FullSync      bool                       `json:"full_sync"`
	SyncStatus    map[string]json.RawMessage `json:"sync_status"`
	TempIDMapping map[string]string          `json:"temp_id_mapping"`

	Projects  []Project  `json:"projects"`
	Items     []Task     `json:"items"`
	Sections  []Section  `json:"sections"`
	Labels    []Label    `json:"labels"`
	Notes     []Comment  `json:"notes"`
	Reminders []Reminder `json:"reminders"`
	Filters   []Filter   `json:"filters"`
	User      *User      `json:"user"`
}

SyncResponse is the result of a Sync API call. Only the resource slices relevant to the requested ResourceTypes are populated.

func (*SyncResponse) Err

func (r *SyncResponse) Err() error

Err aggregates any per-command failures reported in SyncStatus. It returns nil when every command succeeded (status "ok") or when no commands were sent.

type TZInfo

type TZInfo struct {
	Timezone  string `json:"timezone"`
	GMTString string `json:"gmt_string"`
	Hours     int    `json:"hours"`
	Minutes   int    `json:"minutes"`
	IsDST     int    `json:"is_dst"`
}

TZInfo is the user's timezone configuration.

type Task

type Task struct {
	ID           string    `json:"id"`
	ProjectID    string    `json:"project_id"`
	SectionID    string    `json:"section_id"`
	ParentID     string    `json:"parent_id"`
	Content      string    `json:"content"`
	Description  string    `json:"description"`
	Priority     int       `json:"priority"`
	Labels       []string  `json:"labels"`
	Due          *Due      `json:"due"`
	Deadline     *Deadline `json:"deadline"`
	Duration     *Duration `json:"duration"`
	AssigneeID   string    `json:"assignee_id"`
	AssignerID   string    `json:"assigner_id"`
	Order        int       `json:"child_order"`
	CommentCount int       `json:"comment_count"`
	IsCompleted  bool      `json:"checked"`
	AddedAt      string    `json:"added_at"`
	CompletedAt  string    `json:"completed_at"`
	URL          string    `json:"url"`
}

Task is a Todoist task (an "item" in Sync API terms).

type UpdateCommentArgs

type UpdateCommentArgs struct {
	Content string `json:"content"`
}

UpdateCommentArgs are the parameters for updating a comment.

type UpdateFolderArgs added in v0.3.0

type UpdateFolderArgs struct {
	Name         *string `json:"name,omitempty"`
	DefaultOrder *int    `json:"default_order,omitempty"`
}

UpdateFolderArgs are the parameters for updating a folder. Only non-nil fields are sent.

type UpdateLabelArgs

type UpdateLabelArgs struct {
	Name       *string `json:"name,omitempty"`
	Color      *string `json:"color,omitempty"`
	Order      *int    `json:"order,omitempty"`
	IsFavorite *bool   `json:"is_favorite,omitempty"`
}

UpdateLabelArgs are the parameters for updating a label. Only non-nil fields are sent.

type UpdateLocationReminderArgs added in v0.2.0

type UpdateLocationReminderArgs struct {
	Name       *string `json:"name,omitempty"`
	LocLat     *string `json:"loc_lat,omitempty"`
	LocLong    *string `json:"loc_long,omitempty"`
	LocTrigger *string `json:"loc_trigger,omitempty"`
	Radius     *int    `json:"radius,omitempty"`
}

UpdateLocationReminderArgs are the parameters for updating a location reminder. Only non-nil fields are sent.

type UpdateProjectArgs

type UpdateProjectArgs struct {
	Name       *string `json:"name,omitempty"`
	Color      *string `json:"color,omitempty"`
	IsFavorite *bool   `json:"is_favorite,omitempty"`
	ViewStyle  *string `json:"view_style,omitempty"`
}

UpdateProjectArgs are the parameters for updating a project. Only non-nil fields are sent.

type UpdateReminderArgs

type UpdateReminderArgs struct {
	Type        *string `json:"type,omitempty"`
	DueString   *string `json:"due_string,omitempty"`
	DueDate     *string `json:"due_date,omitempty"`
	DueDatetime *string `json:"due_datetime,omitempty"`
	MinuteBias  *int    `json:"minute_offset,omitempty"`
	Name        *string `json:"name,omitempty"`
}

UpdateReminderArgs are the parameters for updating a reminder.

type UpdateSectionArgs

type UpdateSectionArgs struct {
	Name string `json:"name"`
}

UpdateSectionArgs are the parameters for updating a section.

type UpdateTaskArgs

type UpdateTaskArgs struct {
	Content      *string  `json:"content,omitempty"`
	Description  *string  `json:"description,omitempty"`
	Labels       []string `json:"labels,omitempty"`
	Priority     *int     `json:"priority,omitempty"`
	AssigneeID   *string  `json:"assignee_id,omitempty"`
	DueString    *string  `json:"due_string,omitempty"`
	DueDate      *string  `json:"due_date,omitempty"`
	DueDatetime  *string  `json:"due_datetime,omitempty"`
	DueLang      *string  `json:"due_lang,omitempty"`
	Deadline     *string  `json:"deadline_date,omitempty"`
	Duration     *int     `json:"duration,omitempty"`
	DurationUnit *string  `json:"duration_unit,omitempty"`
}

UpdateTaskArgs are the parameters for updating a task. Only non-nil fields are sent, so the zero value leaves the task unchanged.

type UpdateWorkspaceArgs

type UpdateWorkspaceArgs struct {
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
}

UpdateWorkspaceArgs are the parameters for updating a workspace.

type UploadResult added in v0.3.0

type UploadResult struct {
	FileURL      string `json:"file_url"`
	FileName     string `json:"file_name"`
	FileType     string `json:"file_type"`
	FileSize     int    `json:"file_size"`
	ResourceType string `json:"resource_type"`
	UploadState  string `json:"upload_state"`
	Image        string `json:"image"`
	ImageWidth   int    `json:"image_width"`
	ImageHeight  int    `json:"image_height"`
}

UploadResult describes a file uploaded to Todoist, suitable for attaching to a comment.

func (UploadResult) Attachment added in v0.3.0

func (u UploadResult) Attachment() Attachment

Attachment converts an upload into the Attachment form accepted by CreateComment.

type User

type User struct {
	ID           string  `json:"id"`
	Email        string  `json:"email"`
	FullName     string  `json:"full_name"`
	InboxID      string  `json:"inbox_project_id"`
	TZInfo       TZInfo  `json:"tz_info"`
	Lang         string  `json:"lang"`
	DateFormat   int     `json:"date_format"`
	TimeFormat   int     `json:"time_format"`
	StartDay     int     `json:"start_day"`
	Karma        float64 `json:"karma"`
	IsPremium    bool    `json:"is_premium"`
	PremiumUntil string  `json:"premium_until"`
	AvatarBig    string  `json:"avatar_big"`
}

User is the authenticated user's profile.

type WeekStats

type WeekStats struct {
	From           string `json:"from"`
	To             string `json:"to"`
	TotalCompleted int    `json:"total_completed"`
}

WeekStats holds completion counts for a single week.

type Workspace

type Workspace struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Role        string `json:"role"`
	Plan        string `json:"current_active_plan"`
	IsGuest     bool   `json:"is_guest_allowed"`
	MemberCount int    `json:"member_count"`
	LogoBig     string `json:"logo_big"`
}

Workspace is a Todoist workspace (team space).

type WorkspaceInvitation added in v0.2.0

type WorkspaceInvitation struct {
	ID             string `json:"id"`
	InviterID      string `json:"inviter_id"`
	UserEmail      string `json:"user_email"`
	WorkspaceID    string `json:"workspace_id"`
	Role           string `json:"role"`
	IsExistingUser bool   `json:"is_existing_user"`
}

WorkspaceInvitation is a pending invitation for a user to join a workspace.

type WorkspaceUser

type WorkspaceUser struct {
	UserID      string `json:"user_id"`
	WorkspaceID string `json:"workspace_id"`
	UserEmail   string `json:"user_email"`
	FullName    string `json:"full_name"`
	Role        string `json:"role"`
	ImageID     string `json:"image_id"`
}

WorkspaceUser is a member of a workspace.

Jump to

Keyboard shortcuts

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