May I ask how I can get all customers?
According to the Chargebee documentation for list operations (here), one has to repeatedly call the API until the next_offset
field is missing in the response object. The offset
parameter allows us to start where we left off.
One can use the limit
parameter to ask Chargebee for more customers in one call, reducing the number of total calls we have to make.
I included a Python snippet as an example of how to implement pagination.
import chargebee
def get_all_customers(params, limit=100, offset=None):
customers = list()
params['limit'] = limit
params['offset'] = offset
while True:
entries = chargebee.Customer.list(params)
customers.extend(entries.response)
if entries.next_offset:
params['offset'] = entries.next_offset
else:
break
return customers
def main():
chargebee.configure('<api_token>', '<site>')
customers = get_all_customers({"first_name[is]": "John"})
for customer in customers:
print(customer)
if __name__ == '__main__':
main()
I have more than 100 customers, but I still do not have "next_offset" returned.
Unfortunately, we cannot provide help with that, as we cannot access your Chargebee environment and debug.