pipedrive-python icon indicating copy to clipboard operation
pipedrive-python copied to clipboard

Pagination of Results

Open DuckHawk123 opened this issue 5 years ago • 1 comments

I'm running the .get_all_deals_with_filter() function and have pagination within the results. (I'm only getting the first 100 and it is saying there are more results.) How do I update this to get those additional "pages" of results? It appears that I can only pass the filter_id into the function without error, unless I'm doing something wrong.

DuckHawk123 avatar Nov 09 '20 23:11 DuckHawk123

You can increase limit. I think max was 500. And then you have to write an iterator which goes over the pages.

Quick example:

r = client.get_all_deals_with_filter({"limit" :500,}) # first query

while r['additional_data']["pagination"]: # iterator

    for item in r["data"]:

        # "do something with your items"
        
    if not r['additional_data']["pagination"]['more_items_in_collection']: # check if there are no more pages
        break

    r = client.organizations.get_all_deals_with_filter({"limit" :500, "start": r['additional_data']["pagination"]["next_start"]}) # next query

ernests avatar Dec 30 '20 14:12 ernests