Google Tasks

  • Tasks can be retrieved from a specific task list using Tasks.Tasks.list(TASK_LIST_ID).

  • A new task can be created with a title, notes, and due date using Tasks.Tasks.insert(task, TASK_LIST_ID).

  • An existing task can be marked as completed by retrieving it, setting its status to 'completed', and updating it using Tasks.Tasks.update(task, TASK_LIST_ID, TASK_ID).

Get tasks from task list

function getTasksFromDefaultList() {
  // You can substitute a task list ID here to retrieve all the tasks
  // in that list.

  var TASK_LIST_ID = '@default';

  var taskList = Tasks.Tasklists.get(TASK_LIST_ID);

  // Display the task list details.
  console.log('Name: %s (%s)', taskList.title, taskList.id);

  // Retrieve all the tasks in the list.
  var tasks = Tasks.Tasks.list(TASK_LIST_ID);

  for (var i = 0; i < tasks.items.length; i++) {
    console.log('  %s) Title: %s, Due on: %s, Status: %s, ID = %s.',
               i.toFixed(0), tasks.items[i].title,
               tasks.items[i].due ? tasks.items[i].due : 'Never',
               tasks.items[i].status, tasks.items[i].id);
  }
}

Create a task

function createTask() {
  // You can substitute a task