Using the Stripe API, I'd like to be able to query for date ranges or, failing that, dates that are greater than or less than some arbitrary date.
I know that I can query for something based on an exact date, e.g.,:
https://api.stripe.com/v1/events?created=1336503409
But I want something along the lines of...
# Search for events where `created` is greater than the epoch time: 1336503400
https://api.stripe.com/v1/events?created__gt=1336503400
The Stripe API allows developers to access the functionality of Stripe. Some example API methods include sending invoices, accepting payments, managing subscription billing, and editing and managing account information.
Stripe API contains many resources (datasets). In this function, we can pass in the name of the resource to get the corresponding data. For example, the basic format to get the subscription data is stripe.Subscription.list (). We use getattr in our function in order to include resource as a parameter in the function.
Stripe Billing Analytics Dashboard provides a summarized view of your account, which provides a lot of useful information like MRR, churn, and so on. Unfortunately, there is not an API for the Stripe Billing Analytics Dashboard (I actually contacted the support and asked about this). So, I can’t get the dashboard out to Python directly.
Next, you will need an API key to access the stripe API. Go to stripe.com — Devlopers — API keys, and then click “+ Create secret key” to get an API key. Then you can define the stripe api_key and also don’t forget to define the api_version.
Stripe is an online payment company that offers software and APIs for processing payments and business management. I love that Stripe has different APIs for different languages, which makes people’s lives a lot easier. I primarily use the Stripe Python API. To install: You can also do conda install stripe.
Yes. From https://stripe.com/docs/api?lang=curl#list_events
created: A filter on the list based on the events created date. The value can be a string with an exact UTC timestamp, or it can be a dictionary with the following options:
gt (optional) Return values should have been created after this timestamp.
gte (optional) Return values should have been created after or equal to this timestamp.
lt (optional) Return values should have been created before this timestamp.
lte (optional) Return values should have been created before or equal to this timestamp.
So with curl, you can build a request like this:
curl "https://api.stripe.com/v1/events?created%5Blt%5D=1337923293" \
-u ${YOUR_API_KEY}:
The unescaped query parameter is created[lt]=1337923293
.
If you're looking how to do so with the ruby client, here it is:
Stripe::Charge.all(limit: 100, 'created[lt]' => timestamps })
Along the same lines. You can achieve the same thing with the Python client like so:
import stripe
from datetime import datetime, timedelta
my_date = '1/31/2011'
my_timestamp = datetime.strptime(my_date, "%m/%d/%Y").timestamp()
stripe.Charge.all(created={'lt': my_timestamp})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With