How to extract incomplete checkout details using API?

NiteshKumar
Visitor
2 0 0
url = f"https://{API_KEY}:{PASSWORD}@{SHOP_NAME}.myshopify.com/admin/api/{VERSION}/checkouts.json"

 

# Make the API call
response = requests.get(url)

 

# # Check if the response is successful
# if response.status_code == 200:
#     # Parse the JSON response
#     data = response.json()
#     checkouts = data['checkouts']

 

#     # Print out the checkouts details
#     for checkout in checkouts:
#         print(json.dumps(checkout, indent=2))
# else:
#     print("Failed to fetch data:", response.status_code)

 

if response.status_code == 200:
    # Parse the JSON response
    data = response.json()
    checkouts = data['checkouts']

 

    # Loop through each checkout
    for checkout in checkouts:
        # Print customer details if available
        customer = checkout.get('customer')
        if customer:
            print("Customer ID:", customer.get('id'))
            print("Email:", customer.get('email'))  # Ensure 'email' is in your response
            print("Phone:", customer.get('phone'))  # Ensure 'phone' is in your response

 

            default_address = customer.get('default_address')
            if default_address:
                print("Address:", default_address)
        else:
            print("No customer details available for checkout ID:", checkout.get('id'))
else:
    print("Failed to fetch data:", response.status_code)
i am using this code to extract details from user that they have filled during checkout but did not complete.
I have confirmed that user has given email address and phone number at checkout page but still i am getting
none response
 
 Customer ID: 6840019877935
Email: None
Phone: None
Address: {'id': 8099554099247, 'customer_id': 6840019877935, 'company': None, 'province': 'Uttar Pradesh', 'country': 'India', 'province_code': 'UP', 'country_code': 'IN', 'country_name': 'India', 'default': True}
Customer ID: 6840478761007
Email: None
Phone: None
Address: {'id': 8099591258159, 'customer_id': 6840478761007, 'company': None, 'province': 'Uttar Pradesh', 'country': 'India', 'province_code': 'UP', 'country_code': 'IN', 'country_name': 'India', 'default': True}
Replies 0 (0)