API Pagination and the 'nextpage' Token

There are situations when you might need to get all the tasks from a particular Folder/Project/Space or from the whole account at once, and make a GET call to the /tasks endpoint.

Get a full list of tasks using these calls:

  • [GET] /tasks search all tasks in the account
  • [GET] /spaces/{spaceId}/tasks search tasks in specific Space
  • [GET] /folders/{folderId}/tasks search tasks in specific Folder

Please note, there is a limit to the number of tasks which can be displayed in response to these queries.

When calling /tasks, /spaces/{spaceId}/tasks and /folders/{folderId}/tasks Wrike’s API shows up to 1000 tasks. If you use /folders/{folderId}/tasks and /spaces/{spaceId}/tasks with ‘descendants’=false parameter no limits are applied.
The sorting order is based on the updatedDate parameter by default (descending order), but you can customize it with the help of the ‘SortField’ parameter. If you have more than 1000 tasks, you can get a full list by using the response pagination. Using the API you can divide the responses among separate pages and switch between the pages using the ‘nextpage’ token.
To divide responses onto different pages:
  1. Use the call GET /tasks. Add the parameter pageSize=1000. You can also include any additional parameters you would like to add.
  2. ‘responseSize’ and ‘nextPageToken’ parameters are shown in response. ‘responseSize’ indicates the total amount of tasks (hidden and shown).
  3. Copy the ‘nextPageToken’ parameter’s value.
  4. 4. Use the call GET /tasks with the nextPageToken=<value> parameter. If you included additional parameters on Step 1, you will need to include those here as well.

Continue switching pages with the same token, the API stops passing the ‘nextPageToken’ when you hit the end of the list.

You can use the ‘pageSize’ parameter to adjust the response size for your /tasks calls and apply it together with ’sortField’ to be able to sort responses based on certain criteria. Please note, in this case it is not possible to have more than 1000 results.

Pavel M Community Team at Wrike Wrike Product Manager Become a Wrike expert with Wrike Discover

Pavel M Wrike Team member Become a Wrike expert with Wrike Discover

Spot On Innovative Approach Stellar Advice

HI Roberto Silva, this is awesome, I cant thank you enough 😉. 

Comment actions Permalink

Folllowing List for Post: API Pagination and the 'nextpage' Token
[this list is visible for admins and agents only]

Didn’t find what you were looking for? Write new post