English 中文(简体)
能否与Srape API查询日期范围?
原标题:Is it possible to query for datetime ranges with the Stripe API?

使用 < a href=>" "https://stripe.com/docs/api" rel= "noreferrer" > Stripe API ,我希望能够查询日期 ranges ,或者,如果没有查询,则查询日期是 大于 的任意日期。

我知道我可以查询一些基于 < exact 日期的东西,例如:

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

但我想要一些类似...

# Search for events where `created` is greater than the epoch time: 1336503400
https://api.stripe.com/v1/events?created__gt=1336503400 
最佳回答

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

< 坚固 > 创建 : 基于事件创建日期的列表过滤器。 值可以是字符串, 带有精确的 UTC 时间戳, < 坚固 > 或字典, 包含以下选项 :

gt (可选择的) 返回值应该在此时间戳后创建 。

< 坚固> gte (可选) 返回值应该在此时间戳之后或之后创建或等于此时间戳 。

返回值应该在此时间戳之前创建 。

< 强 > lte (可选) 返回值应该在此时间戳之前或之前创建或等于此时间戳 。

有了卷曲,你可以提出这样的要求:

curl "https://api.stripe.com/v1/events?created%5Blt%5D=1337923293" 
 -u ${YOUR_API_KEY}:

ununesaped 查询参数是 created[lt]=1337923293

问题回答

如果您想用 < a href=> "https://github.com/strip/stripe/stripe-ruby" >ruby client 来做,这里是:

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

同样的思路,你也可以和 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})

对于我们中使用Go Api的人来说,以下两种格式都用来选择范围:

params := &stripe.ChargeListParams{}
params.Filters.AddFilter("created", "lt", strconv.Itoa(1592217599))
params.Filters.AddFilter("created", "gt", strconv.Itoa(1591612124)) 
i := charge.List(params)

params := &stripe.ChargeListParams{}
params.Filters.AddFilter("created[lt]", "", strconv.Itoa(1592217599))
params.Filters.AddFilter("created[gt]", "", strconv.Itoa(1591612124))
i := charge.List(params)




相关问题
How to set response filename without forcing "save as" dialog

I am returning a stream in some response setting the appropriate content-type header. The behavior I m looking for is this: If the browser is able to render content of the given content type then it ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler. This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read the response. The processing of IPN request is ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

Finding out where curl was redirected

I m using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually ...