List all customers via stripe API
<p>I'm trying to get a list of all the customers in my stripe account but am limited by pagination, wanted to know what the most pythonic way to do this.</p>

<pre><code>customers = []
results = stripe.Customer.list(limit=100)
print len(results.data)
for c in results:
    customers.append(c)
results = stripe.Customer.list(limit=100, starting_after=results.data[-1].id)
for c in results:
    customers.append(c)
</code></pre>

<p>This lists the first 200, but then how do I do this if I have say 300, 500, etc customers?</p>

<p>Stripe's Python library has an "auto-pagination" feature:</p>

<pre><code>customers = stripe.Customer.list(limit=100)
for customer in customers.auto_paging_iter():
    # Do something with customer
</code></pre>

<p>The <code>auto_paging_iter</code> method will iterate over every customer, firing new requests as needed in the background until every customer has been retrieved.</p>

<p>The auto-pagination feature is documented <a href="https://stripe.com/docs/api/python#pagination" rel="nofollow">here</a> (you have to scroll down a bit).</p>

python stripe-payments