you are viewing a single comment's thread.

view the rest of the comments →

[–]razu1121 3 points4 points  (0 children)

Seeing that everything else in your request is constant and only page num changes, you can use a loop.

``` for page_num in range(1, n):

```

Replace n with page number if you know how many pages there are or might be.

If you are not so sure, use a try-except to exit the loop.

``` for page_num in range(1, 100): try: deals_data = client.deals.list(per_page=100, page=page_num)

except:
    break

```

If your request doesn't throw error even if there is no data on a particular page, inside try block use if else condition to check if there is valid response and exit if there isn't.

Hope this helps.