API

vaibhavdhio
Shopify Partner
1 0 0

def get_all_orders():
last=0
orders=pd.DataFrame()
while True:
url = f"https://{apikey}:{password}@{hostname}/admin/api/{version}/{resource}.json?" 
response = requests.request("GET", url)

df=pd.DataFrame(response.json()[resource])
orders=pd.concat([orders,df])
last=df['id'].iloc[-1]
if len(df)<250:
break
return(orders)
df = get_all_orders()

@All members, I'm using above function to get the orders and products data from website but I'm only able to get 50 records for each, Is there any changes required?

Reply 1 (1)

Umiko
Shopify Staff
42 8 13

Hi @vaibhavdhio 👋

 

From your post, your request doesn't appear to be passing the `limit` parameter. I'd recommend reviewing this example for retrieving a list of orders, and specifying the `limit` to be the maximum (250) rather than the default (50). The same can be passed to the products endpoint as well. This doc for making paginated requests also has examples on how to iterate through the pages, in case you need to fetch more than 250+ orders/products.

 

Hope that helps!

Umiko | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog