Skip to main content

Official Python SDK for the Todoist REST API.

Project description

Todoist API Python Client

This is the official Python API client for the Todoist REST API.

Installation

The repository can be included as a Poetry dependency in pyproject.toml. It is best to integrate to a release tag to ensure a stable dependency:

[tool.poetry.dependencies]
todoist-api-python = "^v2.0.0"

Supported Python Versions

Python 3.9 is fully supported and tested, and while it may work with other Python 3 versions, we do not test for them.

Usage

An example of initializing the API client and fetching a user's tasks:

from todoist_api_python.api_async import TodoistAPIAsync
from todoist_api_python.api import TodoistAPI

# Fetch tasks asynchronously
async def get_tasks_async():
    api = TodoistAPIAsync("YOURTOKEN")
    try:
        tasks = await api.get_tasks()
        print(tasks)
    except Exception as error:
        print(error)

# Fetch tasks synchronously
def get_tasks_sync():
    api = TodoistAPI("my token")
    try:
        tasks = api.get_tasks()
        print(tasks)
    except Exception as error:
        print(error)

Example of paginating through a completed project tasks:

def get_all_completed_items(original_params: dict):
    params = original_params.copy()
    results = []

    while True:
        response = api.get_completed_items(**(params | {"limit": 100}))
        results.append(response.items)

        if not response.has_more:
            break

        params["cursor"] = response.next_cursor

    # flatten the results
    return [item for sublist in results for item in sublist]

items = get_all_completed_items({"project_id": 123})

Documentation

For more detailed reference documentation, have a look at the API documentation with Python examples.

Development

To install Python dependencies:

$ poetry install

To install pre-commit:

$ poetry run pre-commit install

You can try your changes via REPL by running:

$ poetry run python

You can then import the library as described in Usage without having to create a file. If you decide to use TodoistAPIAsync, please keep in mind that you have to import asyncio and run asyncio.run(yourmethod()) to make your async methods run as expected.

Releases

This API client is public, and available in a PyPI repository.

A new update is automatically released by GitHub Actions, by creating a release with a tag in the format vX.Y.Z (v<Major>.<Minor>.<Patch>).

Users of the API client can then update to the new version in their pyproject.toml file.

Feedback

Any feedback, such as bugs, questions, comments, etc. can be reported as Issues in this repository, and will be handled by Doist.

Contributions

We would love contributions in the form of Pull requests in this repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

todoist_api_python-2.1.6.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

todoist_api_python-2.1.6-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file todoist_api_python-2.1.6.tar.gz.

File metadata

  • Download URL: todoist_api_python-2.1.6.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for todoist_api_python-2.1.6.tar.gz
Algorithm Hash digest
SHA256 05b4193923d1befb59f2c5e2dc70c7e4b8746dec9fe406a323c5619f3c5b6ac4
MD5 bf94acb3e1eb742c4a170754af6a6a75
BLAKE2b-256 c7a209e5cbaf6b6861900ac38b1b074113de9f8adbde5c4ffdd43dee38c4824e

See more details on using hashes here.

File details

Details for the file todoist_api_python-2.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for todoist_api_python-2.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d8ada7e4d2776b5b41c30927e3f20316d1ea648ed77e7c5b50910a6766e0c016
MD5 efaffa9c781168d240688ffbcfb7b9d0
BLAKE2b-256 f4efa5d9e9401047bc33b68888e96437b00dc46db3b7834087a5c59491940bd0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page