Skip to content

Client

client

Client for Google Tasks API.

Follow this quickstart guide to enable the API and create the necessary credentials: https://developers.google.com/tasks/quickstart/python

Official Python API documentation: https://googleapis.github.io/google-api-python-client/docs/dyn/tasks_v1.html Official REST documentation: https://developers.google.com/tasks/reference/rest

Danger

The Google Task API does not support setting time information for due dates. Thus, the time information of a datetime object is truncated and a pure date is obtained. https://issuetracker.google.com/issues/128979662

DEFAULT_LIST_ID_LEN = 32 module-attribute

Length of the ID of the Google default tasklist.

MAX_RESULTS_PER_PAGE = 100 module-attribute

Maximum number of results per page when fetching all tasks.

GObject(_resource: Resource, **data: str)

Representation of a general Google Object from the Tasks API.

etag: str instance-attribute

id: str instance-attribute

kind: Kind instance-attribute

model_config = ConfigDict(extra='ignore' if is_stable_release() else 'forbid') class-attribute instance-attribute

title_: str = Field(..., alias='title') class-attribute instance-attribute

updated: datetime instance-attribute

__eq__(other: object) -> bool

__hash__() -> int

GTask(_resource: Resource, **data: str)

Representation of a Google Task.

children: list[GTask] property

Returns the children of this task.

completed_at: datetime | None = Field(alias='completed', default=None) class-attribute instance-attribute

due: datetime | None property writable

Returns the due date of this task.

due_: datetime | None = Field(alias='due', default=None) class-attribute instance-attribute

hidden: bool = False class-attribute instance-attribute

is_completed: bool property writable

Returns whether this task is completed.

is_deleted: bool = Field(alias='deleted', default=False) class-attribute instance-attribute

kind: Literal[Kind.TASK] instance-attribute

notes: str | None property writable

Returns the notes of this task.

notes_: str | None = Field(alias='notes', default=None) class-attribute instance-attribute

parent: GTask | None property writable

Returns the parent task of this task.

parent_id: str | None = Field(alias='parent', default=None) class-attribute instance-attribute

position: int property

Returns the position of this task.

position_: str = Field(alias='position') class-attribute instance-attribute

status: Status = Status.NEEDS_ACTION class-attribute instance-attribute

tasklist: GTaskList property

Returns the task list this task belongs to.

tasklist_id: str property

Returns the task list this task belongs to.

title: str property writable

Returns the title of this task.

delete() -> GTask

Deletes this task.

position_after(previous: GTask | None = None) -> GTask

Moves this task to the behind the given task.

reload() -> GTask

Reloads this task from the API.

GTaskList(_resource: Resource, **data: str)

Representation of a Google Task List.

is_default: bool property

Is this the default task list?

is_empty: bool property

Is this task list empty?

kind: Literal[Kind.TASK_LIST] instance-attribute

title: str property writable

Returns the title of this task list.

__bool__() -> bool

Overwrite default behaviour.

__iter__() -> Iterator[GTask]

Returns an iterator over all tasks in this task list.

__len__() -> int

Return the number of tasks in this task list.

all_tasks(*, show_deleted=False) -> list[GTask]

Returns a list of all tasks, completed or not, in this task list.

create_task(title: str, due: date | datetime | None = None) -> GTask

Creates a new task.

delete() -> None

Deletes this task list.

get_task(task_id: str) -> GTask

Returns the task with the given ID.

reload() -> GTaskList

Reloads this task list from the API.

GTasksClient(config: Config | None = None, *, read_only: bool = False)

Google API to easily handle Google Tasks.

read_only = read_only instance-attribute

resource = self._build_resource() instance-attribute

__enter__() -> GTasksClient

__exit__(exc_type, exc_value, traceback)

all_tasklists(max_results: int | None = None) -> list[GTaskList]

Returns a list of all task lists.

close()

Closes the client.

create_tasklist(title: str) -> GTaskList

Creates a new task list.

get_or_create_tasklist(title: str) -> GTaskList

Returns the task list with the given title or creates it if it doesn't exist yet.

get_tasklist(tasklist_id: str = '@default') -> GTaskList

Returns the task list with the given ID.

If no ID is given, the default task list is returned.

recreate_token()

Recreate the current token using the scopes given at initialization.

search_tasklist(title: str) -> SList[GTaskList]

Returns the task list with the given title.

Kind

Representation of the different kinds of Google Objects.

TASK = 'tasks#task' class-attribute instance-attribute

TASK_LIST = 'tasks#taskList' class-attribute instance-attribute

Representation of a link in a Google Task.

description: str instance-attribute

model_config = ConfigDict(extra='ignore' if is_stable_release() else 'forbid') class-attribute instance-attribute

type: str instance-attribute

Scope

TASKS_RO = 'https://www.googleapis.com/auth/tasks.readonly' class-attribute instance-attribute

Allows read-only access to Google Tasks

TASKS_RW = 'https://www.googleapis.com/auth/tasks' class-attribute instance-attribute

Allows read/write access to Google Tasks

Status

Representation of the different statuses of a Google Task.

COMPLETED = 'completed' class-attribute instance-attribute

NEEDS_ACTION = 'needsAction' class-attribute instance-attribute

assert_datetime(dt: date | datetime | None) -> datetime | None

Asserts that the given object is a datetime object or None.