PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How can I pull only 'yesterday's' orders from Shopify API using Python. Needs to be dynamic, not static

 July 01, 2022     datetime, python, shopify, shopify-api     No comments   

Issue

I have successfully pulled all orders. However, my goal is to 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 can't 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)

Solution

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%3A57%3A11-04%3A00"


Answered By - JustLudo
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing