Pagination using Python

Hi, I’m working on exporting all Asana tasks to a csv file, which currently works well:

However, to future proof it I believe I need to implement some form of pagination. I’ve read the documentation on pagination but it leaves you without an example of how to implement this.

Something to do with the below line of code, but then what? Is that enough? Surely not…
client.options[‘page_size’] = 10

Can anyone point me in the right direction on how to paginate and loop through using Python? Many thanks,

Dan

In the Node library the pagination was kinda built in, did you browse the Python library looking for the word “pagination”? cc @Diakoptis @Phil_Seeman who are the best with the API :slight_smile:

All of the Asana client libraries have paging built into them; you don’t need to do anything about it. The library handles the paging and returns to you all of the items you’ve asked for in your request.

The default page size is 50 items; you can set a smaller or larger value, up to a max of 100, but odds are you probably don’t need to vary from the default size. The page size is just an internal “number of items per request”; the only impact a specific number will have is in how many API calls are needed to get all of the data.

See here for a bit more on the topic:

1 Like

Great, so it’s all automatic, I don’t have to do anything with an offset token or next_page, nothing…fantastic. The pagination page implied otherwise, is it out of date or is it just me misinterpreting it? Build an app with Asana

1 Like

Well, from that page, there is this:

Note that all of Asana’s official client libraries support pagination by default.

:slight_smile:

2 Likes

Haha, yes I did notice that, but then it went on to describe more in detail, leaving me wondering why we need to do anything if it’s already built in.

@Daniel_Hutchings I did the same the first time :slight_smile: