是否可以使用Stripe API查询日期时间范围?

Chr*_* W. 9 api json http stripe-payments

使用Stripe API,我希望能够查询日期范围,或者,如果失败,那么日期大于小于某个任意日期.

我知道我可以根据确切的日期查询某些内容,例如:

https://api.stripe.com/v1/events?created=1336503409
Run Code Online (Sandbox Code Playgroud)

但我想要的东西......

# Search for events where `created` is greater than the epoch time: 1336503400
https://api.stripe.com/v1/events?created__gt=1336503400 
Run Code Online (Sandbox Code Playgroud)

anu*_*rag 12

是.来自https://stripe.com/docs/api?lang=curl#list_events

created:基于事件创建日期在列表上的过滤器.该值可以是具有精确UTC时间戳的字符串,也可以是具有以下选项的字典:

gt(可选)应在此时间戳之后创建返回值.

gte(可选)应在此时间戳之后创建返回值.

lt(可选)应在此时间戳之前创建返回值.

lte(可选)应在此时间戳之前或之前创建返回值.

所以使用curl,你可以构建一个这样的请求:

curl https://api.stripe.com/v1/events?created%5Blt%5D=1337923293 -u <you_api_key>:
Run Code Online (Sandbox Code Playgroud)

未转义,查询参数是created[lt]=1337923293.


小智 7

如果你正在寻找如何使用ruby客户端,这里是:

Stripe::Charge.all(limit: 100, 'created[lt]' => timestamps })
Run Code Online (Sandbox Code Playgroud)


Rob*_*ter 5

沿着同样的路线。您可以使用 Python 客户端实现同样的效果,如下所示:

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})
Run Code Online (Sandbox Code Playgroud)