Cant get pagination to work in python

I can’t get pagination to work
The following call return 100 lines exactly (although there are many more)
the next_page is not to be found anywhere

result = client.tasks.search_tasks_for_workspace(WORKSPACE_GID,
opt_fields=[“name”, “gid”,
for r in result:

If I am not mistaken, the search endpoint is not paginated automatically like others with the Asana libs, you have to do the pagination yourself, usually using the creation date of tasks. That’s what I do in my case.

I sort by created_date, then request the first page, get the creation date of the last task, and ask for the next page.

@Phil_Seeman can you confirm?


@Bastien_Siebman is exactly correct, no pagination in the Search API. See the paragraph titled “Pagination” here in the docs:

Thanks for the quick response …
Is there a code example to show how it’s done

Hold on I’ll share part of my javascript code

this.query = {
      limit: 100,
      opt_fields: 'parent.gid,,name,created_at,parent.completed,is_rendered_as_separator',
      completed: false,
      sort_by: 'created_at' // default is descending order

then calling the search code which basically looks like this

 search(createdAtBefore?: string) {
    if (createdAtBefore) {
      this.query['created_at.before'] = createdAtBefore
    }, this.query).subscribe((collection: any) => {'data', task => {
            this.lastDate = task.created_at
          .on('end', () => {
              // on page end, search next page

@Sharon_Cohen-Ofir that should get you going. Right here is the result of a handful of struggling coding sessions :grimacing:

Below you can find my WORKING python code, in case somebody needs it down the road

found = True
while found:
    result = client.tasks.search_tasks_for_workspace(WORKSPACE_GID,
                                                     {"created_at.before" : last_date },
                                                     opt_fields=["name", "gid",
    found = False
    for r in result:
        found = True
        last_date = r["created_at"]
        <do your processing>

Seems I also had the same question. Thanks for yours solutions.