E-commerce Automation July 2026

How to Automate Shopify Sales Reports with Python (No Servers Needed)

Stop manually downloading CSVs. Learn how to automatically pull your Shopify sales data via API and email a daily summary report using a simple Python script.

L
LiteLambda Team
6 min read

The Problem with Manual E-commerce Reporting

If you run a Shopify store, you likely start your day the same way: logging in, navigating to Analytics, downloading a CSV, opening it in Excel, and doing mental math to figure out your true margin for yesterday.

This manual data pull wastes 15-20 minutes every morning. Over a year, that's nearly 3 work weeks lost to repetitive data entry.

What you actually want is a simple email in your inbox at 8:00 AM every morning:
"Yesterday's Gross Sales: $4,200 | Net Profit: $1,100 | Top Product: Blue Hoodie."

In this guide, we'll write a Python script to do exactly that, and deploy it on LiteLambda so it runs automatically every morning—without you having to configure a server, setup AWS Lambda, or keep your laptop open.

Step 1: Getting your Shopify API Keys

To pull your store's data securely, you need a Custom App token:
1. Go to your Shopify Admin Dashboard.
2. Navigate to Settings > Apps and sales channels > Develop apps.
3. Click Create an app and name it "Daily Reporter".
4. Under Configuration > Admin API integration, grant read_orders and read_products permissions.
5. Click Install app and copy your Admin API access token.

Step 2: The Python Script

We'll use Python and the requests library to fetch the data. This script grabs orders from the past 24 hours, sums up the totals, and uses a free email service to send you a report.

import os
import requests
import datetime

def handler(event, context):
    """
    LiteLambda automated handler for Shopify Reporting
    """
    SHOPIFY_STORE = os.environ.get('SHOPIFY_STORE_NAME') # e.g., 'my-cool-store'
    SHOPIFY_TOKEN = os.environ.get('SHOPIFY_API_TOKEN')

    # Calculate timestamps for the last 24 hours
    now = datetime.datetime.utcnow()
    yesterday = now - datetime.timedelta(days=1)

    url = f"https://{SHOPIFY_STORE}.myshopify.com/admin/api/2024-01/orders.json"

    headers = {
        "X-Shopify-Access-Token": SHOPIFY_TOKEN,
        "Content-Type": "application/json"
    }

    params = {
        "status": "any",
        "created_at_min": yesterday.isoformat(),
        "created_at_max": now.isoformat()
    }

    print("Fetching recent orders...")
    response = requests.get(url, headers=headers, params=params)
    response.raise_for_status()

    orders = response.json().get('orders', [])

    total_sales = 0.0
    for order in orders:
        total_sales += float(order.get('total_price', 0))

    report = f"Daily Report: You had {len(orders)} orders in the last 24h, totaling ${total_sales:.2f}."
    print(report)

    # Optional: Send this report via Telegram, Email, or Slack
    # send_to_slack(report)

    return {
        "status": "success",
        "total_orders": len(orders),
        "total_sales": total_sales
    }

Step 3: Automating it forever

Running this script locally works, but you have to remember to run it. Instead, deploy it instantly on LiteLambda:

  1. Log into your LiteLambda Dashboard.
  2. Create a new Cron Job and paste the code above.
  3. In the Packages box, type requests.
  4. In the Environment Variables box, paste your SHOPIFY_API_TOKEN and SHOPIFY_STORE_NAME.
  5. Set the CRON schedule to 0 8 * * * (8:00 AM daily).
  6. Click Save & Run Manually to test.

That's it. No servers to provision, no Dockerfiles to write, and no complex AWS IAM roles to manage. You now have an enterprise-grade reporting pipeline running for less than a cup of coffee a month.

[!TIP]
Want to extend this? You can easily connect the OpenAI or Anthropic API to have an LLM write a summary of the sales trends before emailing it to you.

Skip the infrastructure setup.

Run this exact code in our secure, isolated Docker sandbox. It takes 10 seconds to deploy.

Deploy this script in 60s →

No DevOps required.