Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Todoist

Script integration with Todoist. This object handles OAuth authentication and request signing. The entire Todoist REST API can be used with the request method, and convenience methods are provided for common API endpoints to manage tasks, projects, comments and labels.

The quickAdd method is mostly likely what you are looking for to create tasks as it supports the shorthand the task entry box in Todoist supports to parse projects, etc.

Other methods are direct mappings of the REST API calls provided by Todoist. Most take an options parameter which is a javascript object containing the parameters to be passed to the API, and and the method decodes the JSON response from Todoist and returns it as a Javascript object (or array of objects) with the values as specified in the Todoist API docs.

If an API calls fails, typically the result will be an undefined value, and the lastError property will contains error detail information for troubleshooting.

Example

See Examples-Todoist action group in the Action Directory.

// create Todoist object
let todoist = Todoist.create();
// create task in inbox
todoist.createTask({
  "content": "My Task Name",
  "due_string": "Next wednesday"
});

Hierarchy

  • Todoist

Index

Properties

Optional lastError

lastError: string

If a function fails, this property will contain the last error as a string message, otherwise it will be undefined.

lastResponse

lastResponse: any

If a function success, this property will contain the last response returned by Todoist. The JSON returned by Todoist will be parsed to an object and placed in this property. Refer to Todoist API documentation for details on the contents of this object based on call made.

Methods

closeTask

  • closeTask(taskId: string): boolean
  • Close task (mark complete)

    Parameters

    • taskId: string

    Returns boolean

createComment

  • createComment(options: object): object
  • Parameters

    • options: object

    Returns object

createLabel

  • createLabel(options: object): object
  • Parameters

    • options: object

    Returns object

createProject

  • createProject(options: object): object
  • Parameters

    • options: object

    Returns object

createTask

  • createTask(options: object): object
  • Parameters

    • options: object

    Returns object

getComment

  • getComment(commentId: string): object
  • Parameters

    • commentId: string

    Returns object

getComments

  • getComments(options: object): object[]
  • Parameters

    • options: object

    Returns object[]

getLabel

  • getLabel(labelId: string): object
  • Parameters

    • labelId: string

    Returns object

getLabels

  • getLabels(): object[]
  • Returns object[]

getProject

  • getProject(projectId: string): object
  • Parameters

    • projectId: string

    Returns object

getProjects

  • getProjects(): object[]
  • Returns object[]

getTask

  • getTask(taskId: string): object
  • Parameters

    • taskId: string

    Returns object

getTasks

  • getTasks(options?: object): object[]
  • Parameters

    • Optional options: object

    Returns object[]

quickAdd

  • quickAdd(text: string, note?: string, reminder?: string): object
  • Parameters

    • text: string

      Text to use to create the task. Supports Todoist quick add notation for specifying projects, priority, labels, etc. just as if you were using the Todoist quick add window.

    • Optional note: string

      Optional text to attach as a comment with the task.

    • Optional reminder: string

      Optional natural language date specifying for creating a task reminder.

    Returns object

    Object containing respose data from Todoist.

reopenTask

  • reopenTask(taskId: string): boolean
  • Reopen task (mark incomplete)

    Parameters

    • taskId: string

    Returns boolean

request

  • Execute a request against the Todoist API. For successful requests, the HTTPResponse object will contain an object or array or objects decoded from the JSON returned by Todoist as appropriate to the request made. Refer to Todoist’s API documentation for details about the expected parameters and responses. Drafts will handle wrapping the request in the appropriate OAuth authentication flow.

    Parameters

    • settings: object

      an object configuring the request.

      • Optional data?: object

        A JavaScript object containing data to be encoded into the HTTP body of the request.

        • [x: string]: string
      • Optional headers?: object

        An object contain key-values to be added as custom headers in the request. There is no need to provide authorization headers, Drafts will add those.

        • [x: string]: string
      • method: string

        The HTTP method, like "GET", "POST", etc.

      • Optional parameters?: object

        An object containing key-values to be added to the request as URL parameters.

        • [x: string]: string
      • url: string

        The full URL to the endpoint in the Todoist REST API.

    Returns HTTPResponse

updateComment

  • updateComment(commentId: string, options: object): object
  • Parameters

    • commentId: string
    • options: object

    Returns object

updateLabel

  • updateLabel(labelId: string, options: object): object
  • Parameters

    • labelId: string
    • options: object

    Returns object

updateProject

  • updateProject(projectId: string, options: object): object
  • Parameters

    • projectId: string
    • options: object

    Returns object

updateTask

  • updateTask(taskId: string, options: object): object
  • Parameters

    • taskId: string
    • options: object

    Returns object

Static create

  • create(identifier: string): Todoist
  • Creates a new Todoist object.

    Parameters

    • identifier: string

      Optional string value used to identify a Todoist account. Typically this can be omitted if you only work with one Todoist account in Drafts. Each unique identifier used for Twitter accounts will share credentials - across both action steps and scripts.

    Returns Todoist

Generated using TypeDoc