What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get all orders with python

Get all orders with python

VictorFerrer_95
Visitor
3 0 0

Hello everyone!

 

I'm using this python code to get all orders from my shop, but I'm only getting the Open orders, and I want all the orders I have completed. Does anyone know what I'm missing?

 

HERE THE PYTHON CODE

def get_all_orders():


secret = XXXX
api = XXXX
password = XXXX
hostname = XXXXX
version = '2021-10'
resource = 'orders'

last=0
orders=pd.DataFrame()

while True:
url = f"https://{api}:{password}@{hostname}/admin/api/{version}/{resource}/.json?limit=250&since_id={last}"
response = requests.request("GET", url)

df=pd.DataFrame(response.json()['orders'])
orders=pd.concat([orders,df])

last=df['id'].iloc[-1]
if len(df)<250:
break

return(orders)

 

df=get_all_orders()

 

HERE THE ORDERS I GET: (I want the Closed Orders)

VictorFerrer_95_0-1637687760682.png

VictorFerrer_95_1-1637687831035.png

 

 

 

 

 

Thank you!

Replies 3 (3)

tewe
Shopify Partner
244 46 102

Hi @VictorFerrer_95 ,

 

maybe your app does not have the correct permission. For all orders you need the permission read_all_orders, see https://shopify.dev/api/usage/access-scopes

 

Regards

Thomas

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App
VictorFerrer_95
Visitor
3 0 0

Hi @tewe ,

 

Thanks for your reply.

 

It is the Private App the app you mean? I created a Private App inside the shop and I granted to the app all the read accesses regarding orders and products:

 

VictorFerrer_95_0-1637746113383.png

Don't know why I'm only getting the Open orders...

Noitseuq
Visitor
2 0 0

Thanks!