Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

Stripe API in python gives incorrect number of transactions

This is my code for retrieving the number of transactions in Stripe API

import stripe
customers = stripe.Customer.list()
print(len(customers))

The above code always prints 10 in the output. I am using the test public and private keys that Stripe website has given me. What part of my code is incorrect?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

According to the Stripe API docs, the default limit for requesting a list of customers is 10. That is likely why you are only ending up with 10 customers instead of your entire list.

As is the case with many such APIs, the documentation includes a parameter to enable pagination, starting_after or ending_before. You can read more about to Stripe's API here - I would recommend building up your API doc reading muscles since I've personally found them to be incredibly helpful when working with a project like this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...