# 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](https://python-poetry.org/) dependency in `pyproject.toml`.
It is best to integrate to a release tag to ensure a stable dependency:
```toml
[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:
```python
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:
```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
$ poetry install
```
To install pre-commit:
```sh
$ poetry run pre-commit install
```
You can try your changes via REPL by running:
```sh
$ poetry 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/Doist/todoist-api-python",
"name": "todoist-api-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "todoist, rest, api, python",
"author": "Doist Developers",
"author_email": "dev@doist.com",
"download_url": "https://files.pythonhosted.org/packages/c7/a2/09e5cbaf6b6861900ac38b1b074113de9f8adbde5c4ffdd43dee38c4824e/todoist_api_python-2.1.6.tar.gz",
"platform": null,
"description": "# Todoist API Python Client\n\nThis is the official Python API client for the Todoist REST API.\n\n### Installation\n\nThe repository can be included as a [Poetry](https://python-poetry.org/) dependency in `pyproject.toml`.\nIt is best to integrate to a release tag to ensure a stable dependency:\n\n```toml\n[tool.poetry.dependencies]\ntodoist-api-python = \"^v2.0.0\"\n```\n\n### Supported Python Versions\n\nPython 3.9 is fully supported and tested, and while it may work with other Python 3 versions, we do not test for them.\n\n### Usage\n\nAn example of initializing the API client and fetching a user's tasks:\n\n```python\nfrom todoist_api_python.api_async import TodoistAPIAsync\nfrom todoist_api_python.api import TodoistAPI\n\n# Fetch tasks asynchronously\nasync def get_tasks_async():\n api = TodoistAPIAsync(\"YOURTOKEN\")\n try:\n tasks = await api.get_tasks()\n print(tasks)\n except Exception as error:\n print(error)\n\n# Fetch tasks synchronously\ndef get_tasks_sync():\n api = TodoistAPI(\"my token\")\n try:\n tasks = api.get_tasks()\n print(tasks)\n except Exception as error:\n print(error)\n```\n\nExample of paginating through a completed project tasks:\n\n```python\ndef get_all_completed_items(original_params: dict):\n params = original_params.copy()\n results = []\n\n while True:\n response = api.get_completed_items(**(params | {\"limit\": 100}))\n results.append(response.items)\n\n if not response.has_more:\n break\n\n params[\"cursor\"] = response.next_cursor\n\n # flatten the results\n return [item for sublist in results for item in sublist]\n\nitems = get_all_completed_items({\"project_id\": 123})\n```\n\n### Documentation\n\nFor more detailed reference documentation, have a look at the [API documentation with Python examples](https://developer.todoist.com/rest/v2/?python).\n\n### Development\n\nTo install Python dependencies:\n\n```sh\n$ poetry install\n```\n\nTo install pre-commit:\n\n```sh\n$ poetry run pre-commit install\n```\n\nYou can try your changes via REPL by running:\n\n```sh\n$ poetry run python\n```\n\nYou can then import the library as described in [Usage](#usage) without having to create a file.\nIf you decide to use `TodoistAPIAsync`, please keep in mind that you have to `import asyncio`\nand run `asyncio.run(yourmethod())` to make your async methods run as expected.\n\n### Releases\n\nThis API client is public, and available in a PyPI repository.\n\nA 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>`).\n\nUsers of the API client can then update to the new version in their `pyproject.toml` file.\n\n### Feedback\n\nAny feedback, such as bugs, questions, comments, etc. can be reported as *Issues* in this repository, and will be handled by Doist.\n\n### Contributions\n\nWe would love contributions in the form of *Pull requests* in this repository.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Official Python SDK for the Todoist REST API.",
"version": "2.1.6",
"project_urls": {
"Documentation": "https://developer.todoist.com/rest/",
"Homepage": "https://github.com/Doist/todoist-api-python",
"Repository": "https://github.com/Doist/todoist-api-python"
},
"split_keywords": [
"todoist",
" rest",
" api",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f4efa5d9e9401047bc33b68888e96437b00dc46db3b7834087a5c59491940bd0",
"md5": "efaffa9c781168d240688ffbcfb7b9d0",
"sha256": "d8ada7e4d2776b5b41c30927e3f20316d1ea648ed77e7c5b50910a6766e0c016"
},
"downloads": -1,
"filename": "todoist_api_python-2.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "efaffa9c781168d240688ffbcfb7b9d0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 12631,
"upload_time": "2024-08-07T11:46:22",
"upload_time_iso_8601": "2024-08-07T11:46:22.268311Z",
"url": "https://files.pythonhosted.org/packages/f4/ef/a5d9e9401047bc33b68888e96437b00dc46db3b7834087a5c59491940bd0/todoist_api_python-2.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c7a209e5cbaf6b6861900ac38b1b074113de9f8adbde5c4ffdd43dee38c4824e",
"md5": "bf94acb3e1eb742c4a170754af6a6a75",
"sha256": "05b4193923d1befb59f2c5e2dc70c7e4b8746dec9fe406a323c5619f3c5b6ac4"
},
"downloads": -1,
"filename": "todoist_api_python-2.1.6.tar.gz",
"has_sig": false,
"md5_digest": "bf94acb3e1eb742c4a170754af6a6a75",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 13054,
"upload_time": "2024-08-07T11:46:23",
"upload_time_iso_8601": "2024-08-07T11:46:23.671422Z",
"url": "https://files.pythonhosted.org/packages/c7/a2/09e5cbaf6b6861900ac38b1b074113de9f8adbde5c4ffdd43dee38c4824e/todoist_api_python-2.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 11:46:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Doist",
"github_project": "todoist-api-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "todoist-api-python"
}