# 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/b8/00/6ec16cf54428fc9f3f343e358c38290cd7cc1857e68ca4f89770ff106851/todoist_api_python-2.1.5.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.5",
"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": "190cc490d961ba4b7ddab14815cf31163238fb4752f3473d079d54ff8e2ae2ba",
"md5": "109b688ff68565410d5ac85392a4a8ca",
"sha256": "cef20d0106421a6571b477a631b6157e96a3303b44427f6a3cafef73f219f677"
},
"downloads": -1,
"filename": "todoist_api_python-2.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "109b688ff68565410d5ac85392a4a8ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 12462,
"upload_time": "2024-05-22T06:45:43",
"upload_time_iso_8601": "2024-05-22T06:45:43.434807Z",
"url": "https://files.pythonhosted.org/packages/19/0c/c490d961ba4b7ddab14815cf31163238fb4752f3473d079d54ff8e2ae2ba/todoist_api_python-2.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b8006ec16cf54428fc9f3f343e358c38290cd7cc1857e68ca4f89770ff106851",
"md5": "67fa60e75eca7e869aa039b974c098b0",
"sha256": "bde4f5c91bee06ad22b85366c09f435e60e16c2770e561a6368bc17ca767541f"
},
"downloads": -1,
"filename": "todoist_api_python-2.1.5.tar.gz",
"has_sig": false,
"md5_digest": "67fa60e75eca7e869aa039b974c098b0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 11618,
"upload_time": "2024-05-22T06:45:44",
"upload_time_iso_8601": "2024-05-22T06:45:44.540415Z",
"url": "https://files.pythonhosted.org/packages/b8/00/6ec16cf54428fc9f3f343e358c38290cd7cc1857e68ca4f89770ff106851/todoist_api_python-2.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-22 06:45:44",
"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"
}