How to get all the tasks from a certain project from Todoist Python API

842 views Asked by At

I want to get all tasks from a specific task from Todoist. The documentation says. Taken from the documentation the code for getting all tasks is the following:

from todoist_api_python.api import TodoistAPI

api = TodoistAPI('someToken...')

try:
    tasks = api.get_tasks()
    print(tasks)
except Exception as error:
    print(error)

The documentation does not contain any information about how to get all the tasks from a certain project. Due the reason that I found also another opportunity to get all tasks I am sure there is a way to call all the tasks from a project but it is just not obviously how.

Another way to get all projects from Todoist:

from todoist.api import TodoistAPI

key = "someToken..."
api = TodoistAPI(key)
api.sync()
print(api.state["projects"])
1

There are 1 answers

0
yemy On

Solution

from todoist.api import TodoistAPI

key = "someToken..."
api = TodoistAPI(key)
api.sync()

for project in api.state['items']:
    if(project["project_id"] == someProjectId):
        print(project["content"])