A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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?
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