Search by

fabian-beiner / todoist-php-api-library

FabianBeiner

A PHP client library that provides a native interface to the official Todoist API.

Package info

github.com/FabianBeiner/Todoist-PHP-API-Library

Documentation

pkg:composer/fabian-beiner/todoist-php-api-library

Statistics

Installs: 13 544

Dependents: 0

Suggesters: 0

Stars: 48

Open Issues: 5

v3.0.2 2026-12-01 22:31 UTC

README

CI GitHub tag (latest by date) Packagist Version GitHub stars GitHub issues GitHub license

PHP Client for Todoist

A PHP client for managing Todoist tasks, projects, sections, comments, and labels through Todoist API v1.

Upgrading from 2.x? See the 3.0 migration guide.

Requirements

  • PHP 8.2 or newer with ext-json
  • Composer, which installs Guzzle ^7.15.2 with the library

Quick start

Install the 3.x release from your project directory.

composer require fabian-beiner/todoist-php-api-library:^3.0

Copy your API token from Settings → Integrations → Developer in Todoist. Set it as TODOIST_TOKEN in the environment where you run PHP.

Save this example as quickstart.php in your project directory. It creates a task in your Todoist inbox and prints its content and ID.

<?php

use FabianBeiner\Todoist\TodoistClient;

require __DIR__ . '/vendor/autoload.php';

$token = getenv('TODOIST_TOKEN');
if ($token === false || trim($token) === '') {
    throw new RuntimeException('Set TODOIST_TOKEN before running this script.');
}

$todoist = new TodoistClient($token);
$task = $todoist->createTask('Buy milk', ['due_string' => 'tomorrow']);

echo $task['content'] . ' (' . $task['id'] . ')' . PHP_EOL;
php quickstart.php

Listing and filtering tasks

The getAll* methods fetch every page automatically. A successful call returns a flat array.

foreach ($todoist->getAllTasks() as $task) {
    echo $task['content'] . PHP_EOL;
}

Use project_id to list tasks in one project or filter for a Todoist search expression.

$overdue = $todoist->getAllTasks(['filter' => 'overdue', 'lang' => 'en']);

In filter mode, lang is the only supported extra filter parameter. The library handles limit and cursor itself.

Troubleshooting

  • If a request fails with HTTP 401 or 403, check the API token and the account’s access to the resource.
  • With the default client configuration, HTTP errors throw FabianBeiner\Todoist\TodoistException. Methods that reject empty IDs or other required inputs can still return false before sending a request. See the error handling examples.

API reference

Optional parameter arrays pass API v1 fields through to Todoist. Values supplied in required method arguments take precedence.

Testing

composer install
composer test

The unit tests run offline. To run the live integration suite, export TODOIST_TOKEN for a test account and opt in with TODOIST_INTEGRATION=1.

TODOIST_INTEGRATION=1 vendor/bin/phpunit --group integration

Set TODOIST_SHARED_LABEL as well to run the shared-label test. The suite creates and deletes real tasks, projects, sections, comments, and labels.

Contributing

Before opening a pull request, run vendor/bin/phpunit --exclude-group integration and vendor/bin/php-cs-fixer fix --dry-run --diff. See the Code of Conduct and contributors.

Changelog and license

This is an independent community project.