Is it possible to query datetime ranges using the Stripe API?

Using the Stripe API , I would like to be able to query for date ranges or, otherwise, dates that are more or less than any arbitrary date.

I know that I can request something based on the exact date, for example:

https://api.stripe.com/v1/events?created=1336503409 

But I want something like strings ...

 # Search for events where `created` is greater than the epoch time: 1336503400 https://api.stripe.com/v1/events?created__gt=1336503400 
+7
source share
3 answers

Yes. From https://stripe.com/docs/api?lang=curl#list_events

created . Filter the list based on the date the events were generated. The value can be a string with an exact UTC timestamp, or it can be a dictionary with the following parameters :

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 ​​must have been created before this timestamp.

lte (optional) Return values ​​must have been created before or equal to this timestamp.

So, with curl you can create a query like this:

 curl https://api.stripe.com/v1/events?created%5Blt%5D=1337923293 -u <you_api_key>: 

Unescaped, request parameter created[lt]=1337923293 .

+9
source

If you look at how to do this with ruby client , here it is:

 Stripe::Charge.all(limit: 100, 'created[lt]' => timestamps }) 
+5
source

In the same lines. You can do the same with the Python client as follows:

 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}) 
0
source

All Articles