嗨,我正在尝试通过shopify API从shopify商店获取所有订单,我使用的是R脚本,到目前为止,如果我不使用limit关键字,那么我只能获取250条记录,即每页的限制在php中,默认值为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:dcfee3235061bd149ebxxxxxxxxxxxxx@store.myshopify.com/admin/orders.json?query=&limit=250&status=any
有没有一种方法可以一次打电话获得所有订单?
否则,是否可以获取不同的页面,例如第1,2,3,4,5页等,以后我可以将这些数据帧合并为1。
答案 0 :(得分:1)
使用分页。文档中有明确说明。
答案 1 :(得分:0)
正如其他人所说,您必须使用分页。我最近创建了一个名为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
)
shopr将连续调用该API,以获取250个订单的大块,然后将它们组合在一起。