How does AWeber's API handle pagination?

When you try to obtain a collection that contains many entries from AWeber's API we'll limit the amount of information returned to you at one time, requiring you to view the information in smaller chunks. This is referred to as pagination because you have to "page" through the response like you would with a book.

Paginating the API responses allows AWeber to better handle all the requests we get from our API users and ensure that the service remains available for all who wish to use it.

The Start and Size Variables

The collections in AWeber's API have two special parameters available that control the number of records returned and the offset for where the collection starts.

  • ws.start works much like OFFSET would in a database query. It describes how many items to skip before we start returning them in our response. The default value is 0, or the start of the collection.
  • ws.size works like LIMIT would in a database query. It says how many records we should return in each page of our response. Both the maximum and default value is 100.

You can combine these parameters with your request in order to change how we return information to you. Here's an example using Python and Requests that shows an offset of 10 and a page size of 50:

params_dict = {'ws.start': 10,
               'ws.size': 50}
response = oauth_session.get(url, params=params_dict)

Next and Previous Page Links

Since all that fussing with query parameters can be a pain, AWeber's API handles some of the pagination for you automatically. If you request a collection of data larger than the specified size parameter (or 100 if none was specified) we will return links that will give you the next or previous page of results within the response body. Look for these:

  • next_collection_link automatically sets the start value to be n+size, where n is the current start and the size is whatever you set (or 100 if you didn't set anything). If you are currently looking at subscribers 100-199 this would set the ws.start query parameter to 200.
  • prev_collection_link automatically sets the start value to be n-size, where n is the current start and the size is whatever you set (or 100 if you didn't set anything). If you are currently looking at subscribers 100-199 this would set the ws.start query parameter to 0.

These links only appear if a next or previous result page is available. If they are present, you can use them to iterate over each page to obtain a large amount of data. Here's a Python and Requests example of how you could traverse a large list of subscribers:

next_url = 'https://api.aweber.com/1.0/accounts/{account_id}/lists/{list_id}/subscribers'
while next_url:
    response = oauth_session.get(next_url)
    next_url = ''
    if 'next_collection_link' in response.json():
        next_url = response.json()['next_collection_link']
Have more questions? Submit a request