嗨我想通过shopify API从shopify商店获取所有订单,我使用的是R脚本,到目前为止我只能获得250条记录,即每页限制,如果我不在php中使用limit关键字它默认为50。
这是我到目前为止所拥有的
library(dplyr)
library(httr)
library(rlist)
library(jsonlite)
apikey <- "xxxxxxxxxx1d2fd1fb8710"
pass <- "xxxxxxxxxxxx3e4d38d476fdb188ac7"
orders <- GET(
url = "https://xxxxx-xxxxx.myshopify.com/admin/orders.json?query=&limit=250&status=any",
authenticate(user = apikey, password = pass)
)
如果我想通过PHP做同样的事情我使用https调用,我得到相同的250结果
https://1x877xxxxbd3ed99ae30d1eb4d71cxxx:[email protected]/admin/orders.json?query=&limit=250&status=any
有没有办法可以在一次通话中获得所有订单?
或者如果没有,是否有办法获得不同的页面,如第1,2,3,4,5页等,稍后我可以将这些数据帧合并为1。
使用分页。清楚地在文档中描述。
正如其他人所说,你必须使用分页。我最近创建了一个名为shopr的R包,这使得它相当容易。
library(shopr)
orders <- shopr_get_orders(
shopURL = "https://xxxxx-xxxxx.myshopify.com",
APIKey = apikey,
APIPassword = pass,
APIVersion = "2019-04",
max_pages = Inf, # this is the default
limit_per_page = 250L, # this is the default
since_id = 0L # this is the default
)
购物者将连续调用API,获取250个订单的块,然后将它们组合在一起。