Pagination using Python


#1

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


#2

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:


#3

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:


#4

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? https://asana.com/developers/documentation/getting-started/pagination


#5

Well, from that page, there is this:

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

:slight_smile:


#6

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.


#7

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