Metadata-Version: 2.4
Name: todoist_api_python
Version: 3.0.0
Summary: Official Python SDK for the Todoist API.
Project-URL: Homepage, https://github.com/Doist/todoist-api-python
Project-URL: Repository, https://github.com/Doist/todoist-api-python
Project-URL: Documentation, https://developer.todoist.com/rest/
Author-email: Doist Developers <dev@doist.com>
License-Expression: MIT
License-File: LICENSE
Keywords: api,python,rest,sync,todoist
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: ~=3.13
Requires-Dist: annotated-types
Requires-Dist: dataclass-wizard<1.0,>=0.35.0
Requires-Dist: requests<3,>=2.32.3
Description-Content-Type: text/markdown

# Todoist API Python Client

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

### Installation

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

```toml
dependencies = [
  ...
  "todoist-api-python>=3.0.0,<4",
  ...
]
```

### Supported Python Versions

While we only actively test under Python 3.13, we strive to support all versions from Python 3.9 and above.

### Usage

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

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

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

# 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)
```

Example of paginating through a completed project tasks:

```python
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](https://developer.todoist.com/rest/v2/?python).

### Development

To install Python dependencies:

```sh
$ uv sync
```

To install pre-commit:

```sh
$ uv run pre-commit install
```

You can try your changes via REPL by running:

```sh
$ uv run python
```

You can then import the library as described in [Usage](#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.
