In this post we will share a quick tutorial on fetching all customers from Stripe using the Stripe API.

The problem

Stripe does not allow one to fetch all of one's customers in one go. Stripe returns customers in paginated lists. This means we must paginate through the list in a loop using a ID in batches of 100.

Code example

Here is an illustration of how to fetch all customers by paging through a list of customers from the Stripe API. It is written in Kotlin but you can apply the same logic in any programming language. We fetch batches of 100 customers and do so in a loop until a batch is returned and the property is not true. This means we have fetched all the customers.