Skip to content

Instantly share code, notes, and snippets.

@ricard33
Forked from Maxr1998/todoist-cleaner.py
Created July 13, 2021 13:45
Show Gist options
  • Save ricard33/7bca205a64632a5693278f95516cbcdc to your computer and use it in GitHub Desktop.
Save ricard33/7bca205a64632a5693278f95516cbcdc to your computer and use it in GitHub Desktop.
Python script to delete completed tasks from your Todoist Inbox
import todoist
api = todoist.TodoistAPI(token='<your_token_here')
# Initial sync of your account
api.sync()
# Find Inbox in project - can be adapted to delete completed tasks for other projects as well
projects = api.projects.all()
inbox = next(p for p in projects if 'inbox_project' in p)
# Process tasks until explicitly aborted
while True:
# Get completed tasks for project, a maximum of 100 tasks is supported per batch
completed = api.items.get_completed(project_id=inbox['id'], limit=100)
if not completed:
break # No completed tasks left, abort
# Delete the completed tasks
for c in completed:
api.items.delete(c['id'])
# Commit deletion requests
api.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment