-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorders.py
32 lines (24 loc) · 1023 Bytes
/
orders.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
def get_orders(shopify_store_url, access_token):
# https://shopify.dev/docs/api/usage/pagination-rest
url = f"https://{shopify_store_url}/admin/api/2024-07/orders.json?status=any"
headers = {
"Content-Type": "application/json",
"X-Shopify-Access-Token": access_token
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Query failed with status code {response.status_code}: {response.text}")
def get_order_count(shopify_store_url, access_token):
url = f"https://{shopify_store_url}/admin/api/2024-07/count.json?status=any"
headers = {
"Content-Type": "application/json",
"X-Shopify-Access-Token": access_token
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Query failed with status code {response.status_code}: {response.text}")