By Raj

Connect Shopify API to Google Sheets with Apps Script

Want your Shopify orders, products, or inventory to sync into a Google Sheet automatically? Manual CSV exports are slow and get out of date. Google Apps Script can call the Shopify REST API, fetch the JSON, parse it, and write it straight to a spreadsheet—on demand or on a schedule. Once it's set up, your sheet stays up to date without you lifting a finger.

This post shows how to get an API token from Shopify, store it securely in script properties, and use UrlFetchApp to pull orders (or products, customers) into a sheet. The same pattern works for other REST APIs—Stripe, HubSpot, etc.—with different URLs and payloads.

What you need

  • A Shopify store with API access (Admin → Apps → Develop apps → create a private app to get an API key).
  • A Google Sheet where data will land.
  • The Apps Script editor (Extensions → Apps Script).

Store the API token securely

Never put the token in code. Use PropertiesService.getScriptProperties(). In the script editor: Project Settings (gear) → Script properties → Add: SHOPIFY_TOKEN = your token. Then read it in code as above. Only you (and the script) can see it.

Example: pull recent orders

The Shopify REST API returns JSON. We build the URL with your store subdomain and the API version (e.g. 2024-01). We pass the token in the header X-Shopify-Access-Token. The response has an orders array; we loop over it and append one row per order. Use ?. for optional fields (e.g. o.customer?.email) so missing customer data doesn't throw.

function fetchShopifyOrders() {
  const shop = "your-store.myshopify.com";
  const token = PropertiesService
    .getScriptProperties().getProperty("SHOPIFY_TOKEN");

  const url = "https://" + shop
    + "/admin/api/2024-01/orders.json?status=any&limit=50";

  const res = UrlFetchApp.fetch(url, {
    headers: { "X-Shopify-Access-Token": token }
  });

  const orders = JSON.parse(res.getContentText()).orders;
  const sheet = SpreadsheetApp
    .getActiveSpreadsheet().getSheetByName("Orders");

  // Clear and write header
  sheet.clearContents();
  sheet.appendRow([
    "Order #", "Date", "Customer", "Email", "Total", "Status"
  ]);

  orders.forEach(o => {
    sheet.appendRow([
      o.name,
      o.created_at,
      (o.customer?.first_name || "") + " "
        + (o.customer?.last_name || ""),
      o.customer?.email || "",
      o.total_price,
      o.financial_status
    ]);
  });
}

Pagination: get more than 50 orders

The API returns at most 250 per request. To get more, use the page_info link in the response headers and request the next page until there are no more. I can add this for you if you need full history.

Schedule it

Add a time-based trigger (Triggers → every hour / every morning) and your Sheet always has the latest orders. Combine with Charts or Data Studio for a live dashboard.

Need more?

Pagination, inventory sync, webhook listeners, or two-way sync (update Shopify from Sheets)? I build these integrations regularly. Get a quote and I'll set it up.