Skip to content

Methods: Projects

Fabian Beiner edited this page Jan 1, 2020 · 5 revisions

“Projects” methods and examples

Get all projects

Method:

getAllProjects();

Example:

var_dump($Todoist->getAllProjects());

array (size=6)
  0 => 
    array (size=3)
      'id' => int 2168427835
      'name' => string 'Inbox' (length=5)
      'comment_count' => int 0
  1 => 
    array (size=4)
      'id' => int 2168427836
      'order' => int 1
      'name' => string 'Personal' (length=8)
      'comment_count' => int 0
  2 => 
    array (size=4)
      'id' => int 2168427838
      'order' => int 2
      'name' => string 'Work' (length=4)
      'comment_count' => int 0
  3 => 
    array (size=4)
      'id' => int 2168427837
      'order' => int 3
      'name' => string 'Shopping' (length=8)
      'comment_count' => int 2
  4 => 
    array (size=5)
      'id' => int 2168428146
      'parent' => int 2168427837
      'order' => int 1
      'name' => string 'Groceries' (length=9)
      'comment_count' => int 0

Create a new project

Method:

createProject(string $projectName, [int $parentProjectId]);

Example:

var_dump($Todoist->createProject('Parent Project'));

array (size=4)
  'id' => int 2225756897
  'order' => int 4
  'name' => string 'Parent Project' (length=14)
  'comment_count' => int 0

var_dump($Todoist->createProject('Child Project', 2225756897));

array (size=5)
  'id' => int 2225756937
  'parent' => int 2225756897
  'order' => int 1
  'name' => string 'Child Project' (length=13)
  'comment_count' => int 0

Get a project

Method:

getProject(int $projectId)

Example:

var_dump($Todoist->getProject(2225756897));

array (size=4)
  'id' => int 2225756897
  'order' => int 4
  'name' => string 'Parent Project' (length=14)
  'comment_count' => int 0

Update a project.

Method:

updateProject(int $projectId, string $newProjectName) 

Method alias:

renameProject(int $projectId, string $newProjectName)

Example:

var_dump($Todoist->updateProject(2225756897, 'New Name'));

boolean true

Delete a project

Method:

deleteProject(int $projectId)

Example:

var_dump($Todoist->deleteProject(2225756897));

boolean true
Clone this wiki locally