Home > Software engineering >  How can I pull only 'yesterday's' orders from Shopify API using Python. Needs to be d
How can I pull only 'yesterday's' orders from Shopify API using Python. Needs to be d

Time:11-06

I have successfully pulled all orders. My goal however is to each day have my task scheduler run my python script to pull yesterday's or today's only orders and append the orders to an ongoing master orders list in either a SQL table or excel file. I am thinking it has to be a parameter in the URL but cant figure it out. Can anyone help with this? below is my python script url:

date = datetime.today().strftime('%Y-%m-%d')

    url = "https://{API}:{Password}@{StoreName}/admin/api/2021-10/orders.json?created_at="   date   f"&limit=250&status=any&since_id={last}"
  

response = requests.request("GET", url)

CodePudding user response:

According to the shopify documentation here about orders you can give 2 parameters:

created_at_max (Show orders created at or before date.) & created_at_min (Show orders created at or after date.)

So if you try these in your setup you should be fine. Example from the docs:

curl -X GET "https://your-development-store.myshopify.com/admin/api/2021-10/orders.json?updated_at_min=2005-07-31T15:57:11-04:00"
  • Related