[英]Is there a way to bulk delete a list of customers using the Stripe API?
[英]List all customers via stripe API
我正在嘗試獲取我的Stripe帳戶中所有客戶的列表,但是受分頁的限制,我想知道執行此操作最有效的方法。
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)
它列出了前200個,但是如果我說有300、500等客戶,該怎么辦?
Stripe的Python庫具有“自動分頁”功能:
customers = stripe.Customer.list(limit=100)
for customer in customers.auto_paging_iter():
# Do something with customer
auto_paging_iter
方法將遍歷每個客戶,並在后台根據需要觸發新請求,直到檢索到每個客戶為止。
自動分頁功能記錄在這里 (您必須向下滾動一點)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.