skip to Main Content

Hi I am trying to get all Orders from a shopify store via shopify API, I am using an R script and so far I am only able to get 250 records that is the limit per page, if I dont use the limit keyword in the php it defaults it to 50.

Here is what I have so far

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)
)

If I want to do the same via PHP I use the https call and I get the same 250 results

https://1x877xxxxbd3ed99ae30d1eb4d71cxxx:[email protected]/admin/orders.json?query=&limit=250&status=any

Is there a way that I can get ALL orders in one call?

Or if not, is there a way to get different pages, like page 1,2,3,4,5 etc and later on I can union those dataframes into 1.

2

Answers


  1. Use paging. Clearly described in the documentation.

    Login or Signup to reply.
  2. As others have said, you have to use pagination. I recently created an R package called shopr that makes this fairly easy.

    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 will make successive calls to the API, fetching chunks of 250 orders and then combine them together for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search