Examples

As an example let's:

  • Get a list of all projects in a team
  • Get all tasks from one of the projects
  • Create a new task

All code samples in this section are made with curl using the command line
You can find samples in Node, Ruby, JavaScript, Python in the description of a particular REST API method.

Get projects list:

Request:

curl --request GET \
  --url https://api.ganttpro.com/v1.0/projects/ \
  --header 'accept: application/json' \
  --header 'X-API-KEY: YOUR_API_KEY_HERE'

Response:

[
  {
    "projectId":1598541836426,
    "name":"Sample Project 1"
  },
  {
    "projectId":1598541953820,
    "name":"Sample project 2"
  }
]

Get all tasks from one of the projects:

Now let's get all tasks from the first project projectId=1598541836426

Request:

curl --request GET \
  --url https://api.ganttpro.com/v1.0/tasks/?projectId=1598541836426 \
  --header 'accept: application/json' \
  --header 'X-API-KEY: YOUR_API_KEY_HERE'

Response:

[
  ...
  {
    "id":20216469,
    "projectId":1598541836426,
    "name":"Sample subproject 1",
    "description":null,
    "type":"project",
    "progress":0,
    "duration":2400,
    "estimation":0,
    "sortorder":1,
    "parent":20216467,
    "color":12,
    "deadline":null,
    "status":1,
    "priority":3,
    "resources":[
      
    ],
    "comments":[
      
    ],
    "attachments":[
      
    ],
    "links":[
      
    ],
    "timeLogs":[
      
    ],
    "customColumns":[
      
    ],
    "startDate":"2020-08-27 09:00:00",
    "endDate":"2020-09-02 18:00:00"
  },
  {
    "id":20216468,
    "projectId":1598541836426,
    "name":"Sample task1",
    "description":null,
    "type":"task",
    "progress":0,
    "duration":2400,
    "estimation":60,
    "sortorder":1,
    "parent":20216469,
    "color":1,
    "deadline":null,
    "status":1,
    "priority":3,
    "resources":[
      {
        "resourceValue":40,
        "resourceId": 726707
      }
    ],
    "comments":[
      
    ],
    "attachments":[
      
    ],
    "links":[
      
    ],
    "timeLogs":[
      
    ],
    "customColumns":[
      
    ],
    "startDate":"2020-08-27 09:00:00",
    "endDate":"2020-09-02 18:00:00"
  },
  ...
]

Create a new task

Now, let's add a new task to the subproject 20216469.

Request:

curl --request POST \
  --url https://api.ganttpro.com/v1.0/tasks \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --data '{"projectId":1598541836426, "name": "My new task created via an API", "parent": 20216469}'
{
    "projectId":1598541836426,
    "name": "1",
    "parent": 20216469
}

Response:

{
  "item":{
    "id":20222109,
    "projectId":1598541836426,
    "name":"My new task created via an API",
    "description":null,
    "type":"task",
    "progress":0,
    "duration":1,
    "estimation":0,
    "sortorder":7,
    "parent":20216469,
    "color":1,
    "deadline":null,
    "status":1,
    "priority":7,
    "resources":[
      
    ],
    "comments":[
      
    ],
    "attachments":[
      
    ],
    "links":[
      
    ],
    "timeLogs":[
      
    ],
    "customFields":[
      
    ],
    "startDate":"2020-09-04 09:00:00",
    "endDate":"2020-09-04 09:01:00"
  }
}