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

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:

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