Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gets and prints the tasks for "today", from the Todoist API. Intended to be used alongside
# Use the todoist API to get tasks from the current day
import todoist
from datetime import datetime
# Log user in; switch to OAuth eventually...
api = todoist.TodoistAPI()
def get_todays_tasks(email, password):
Get tasks due on the current utc day
:return: list of task dicts
# user = api.user.login(email, password)
api.user.login(email, password)
tasks_today = []
# Sync (load) data
response = api.sync()
# Get "today", only keep Day XX Mon, which Todoist uses
today = datetime.utcnow().strftime("%a %d %b")
for item in response['items']:
due = item['due_date_utc']
if due:
# Slicing :10 gives us the relevant parts
if due[:10] == today:
return tasks_today
Copy link

ochen1 commented Sep 22, 2020

OH! It worked!
Thank you so much!
For some reason, the Todoist API did not work when I tried to use a token, but logging in by email worked.

Thanks so much for this!

Copy link

ijoseph commented Jan 24, 2021

They changed the API at some point. This is what works as of today:

today = datetime.utcnow().strftime("%Y-%m-%d")
api = TodoistAPI(<FILL>)
for item in api.state['items']:
    if item['due'] is not None and item['due']['date'] == today:

Copy link

rolltidehero commented Jun 29, 2022

Is it possible to grab All tasks, sub-tasks & comments (which are images\screenshots)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment