This project is a Python script that exports all active and completed tasks from the Todoist API to a JSON file, including attachments and comments, and generates a human-readable HTML backup using Jinja2. # Copilot Workspace Instructions ## Project Purpose Export all active and completed tasks from Todoist, including attachments and comments, to a JSON file and a human-readable HTML file. Uses the official Todoist Python client and Jinja2 for HTML rendering. ## Key Implementation Details - Use the Todoist API via the official Python client (`todoist-api-python`). - Fetch projects and tasks using the iterator objects returned by the API for paging. - For completed tasks, use `get_completed_tasks_by_completion_date` for the last 3 months only (API limitation). - For comments and tasks, always iterate over the returned iterator to collect all items. - Download attachments to the `attachments/` folder and reference their local filenames in the JSON and HTML outputs. - Tasks are nested under their project in the JSON output, with all available fields included. - Comments are nested under each task as an array. - Use a `.venv` Python environment for dependencies. - Output files are named `Todoist-Actual-Backup-YYYY-MM-DD.json` and `.html` (current date). - The script is run with the `export` argument; any other argument or none shows usage instructions. - Handle datetime serialization for JSON output using a custom function. ## File Structure - `export_todoist.py`: Main script for export logic. - `requirements.txt`: Lists dependencies (`todoist-api-python`, `Jinja2`, `requests`). - `todoist_backup_template.html`: Jinja2 template for HTML output. - `attachments/`: Folder for downloaded attachments. - `.venv/`: Python virtual environment. - `.github/copilot-instructions.md`: Copilot workspace instructions. ## Error Handling - Print errors for missing API key, failed API requests, and failed downloads. - If a field is not serializable, convert to string or ISO format for JSON. ## Usage - Activate the virtual environment and install requirements before running. - Set the `TODOIST_KEY` environment variable with your Todoist API key. - Run `python export_todoist.py export` to perform the export. ## Suggestions for Copilot - When generating code, prefer iterators for API responses and handle paging. - Always include all available fields from API objects in output. - Use Jinja2 for HTML rendering and reference local attachment files.