Skip to content

Commit b1b26fd

Browse files
committed
Improve README
1 parent 6f6f1a3 commit b1b26fd

File tree

1 file changed

+22
-52
lines changed

1 file changed

+22
-52
lines changed

README.md

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,48 @@
11
# Todoist API Python Client
22

3-
This is the official Python API client for the Todoist REST API.
3+
This is the official Python SDK for the Todoist API.
44

5-
### Installation
5+
## Installation
66

7-
The repository can be included as a dependency in `pyproject.toml`.
8-
It is best to integrate to a release tag to ensure a stable dependency:
7+
```bash
8+
pip install todoist-api-python
9+
```
10+
11+
Or add the project as a dependency in `pyproject.toml`:
912

1013
```toml
1114
dependencies = [
12-
...
1315
"todoist-api-python>=3.0.0,<4",
14-
...
1516
]
1617
```
1718

1819
### Supported Python Versions
1920

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

22-
### Usage
23+
## Usage
2324

24-
An example of initializing the API client and fetching a user's tasks:
25+
Here's an example of initializing the API client, fetching a task, and paginating through its comments:
2526

2627
```python
27-
from todoist_api_python.api_async import TodoistAPIAsync
2828
from todoist_api_python.api import TodoistAPI
2929

30-
# Fetch tasks synchronously
31-
def get_tasks_sync():
32-
api = TodoistAPI("my token")
33-
try:
34-
tasks = api.get_tasks()
35-
print(tasks)
36-
except Exception as error:
37-
print(error)
38-
39-
# Fetch tasks asynchronously
40-
async def get_tasks_async():
41-
api = TodoistAPIAsync("YOURTOKEN")
42-
try:
43-
tasks = await api.get_tasks()
44-
print(tasks)
45-
except Exception as error:
46-
print(error)
47-
```
48-
49-
Example of paginating through a completed project tasks:
50-
51-
```python
52-
def get_all_completed_items(original_params: dict):
53-
params = original_params.copy()
54-
results = []
55-
56-
while True:
57-
response = api.get_completed_items(**(params | {"limit": 100}))
58-
results.append(response.items)
59-
60-
if not response.has_more:
61-
break
62-
63-
params["cursor"] = response.next_cursor
30+
api = TodoistAPI("YOUR_API_TOKEN")
6431

65-
# flatten the results
66-
return [item for sublist in results for item in sublist]
32+
task = api.get_task("6X4Vw2Hfmg73Q2XR")
33+
print(f"Task: {task.content}")
6734

68-
items = get_all_completed_items({"project_id": 123})
35+
comments_iter = api.get_comments(task_id=task.id)
36+
for comments in comments_iter:
37+
for comment in comments:
38+
print(f"Comment: {comment.content}")
6939
```
7040

71-
### Documentation
41+
## Documentation
7242

73-
For more detailed reference documentation, have a look at the [API documentation with Python examples](https://developer.todoist.com/rest/v2/?python).
43+
For more detailed reference documentation, have a look at the [SDK documentation](https://doist.github.io/todoist-api-python/) and the [API documentation](https://developer.todoist.com).
7444

75-
### Development
45+
## Development
7646

7747
To install Python dependencies:
7848

@@ -104,10 +74,10 @@ A new update is automatically released by GitHub Actions, by creating a release
10474

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

107-
### Feedback
77+
## Feedback
10878

109-
Any feedback, such as bugs, questions, comments, etc. can be reported as *Issues* in this repository, and will be handled by Doist.
79+
Any feedback, bugs, questions, comments, etc., can be reported as *Issues* in this repository.
11080

11181
### Contributions
11282

113-
We would love contributions in the form of *Pull requests* in this repository.
83+
We would love contributions! *Pull requests* are welcome.

0 commit comments

Comments
 (0)