如何以 Python 或 Chrome 擴充功能匯出任何 Shopify 商店的產品與款式至 CSV 或 Excel
Export Any Shopify Store's Products & Variants to CSV or Excel (Python + Chrome Extension)
Shopify 公開商店提供產品目錄 JSON 端點,可用 Python 分頁擷取產品、款式、SKU、價格及圖片網址,並輸出符合 Shopify Import CSV 格式的檔案。
If you build e-commerce tooling, migrate storefronts from Shopify to WooCommerce, or benchmark competitor catalogs and pricing, you regularly need a clean spreadsheet of a Shopify store's products, variants, SKUs, prices, and image URLs.
The good news: you do not need an Admin API token or a paid scraping proxy for public catalog data. Every standard Shopify storefront exposes structured JSON endpoints that you can query cleanly from Python — or export in 1 click directly inside Chrome.
1. How Shopify exposes public catalog JSON
Any public Shopify store serves its product catalog at:
https://<store-domain>/products.json?limit=250&page=1
You can also scope exports to a single collection:
https://<store-domain>/collections/<collection-handle>/products.json?limit=250&page=1
Each product object includes:
-
Core fields:
id,title,handle,body_html,vendor,product_type,tags,published_at -
Variants (
variants[]):sku,price,compare_at_price,option1,option2,option3,available,grams,barcode -
Media (
images[]): ordered array of full-resolution Shopify CDN URLs and alt text
Practical caveats to handle in code
-
Pagination:
limit=250is the maximum page size. Looppage=1, 2, 3...untilproductscomes back empty. -
Rate limits: Pause ~300–500 ms between pages (and back off on HTTP
429) so you never trip storefront throttling. -
Variant flattening: A single product with 3 sizes × 4 colors has 12 variants. If you want a Shopify Import CSV, only the first row carries
Title,Body (HTML),Vendor, andTags, while subsequent variant rows repeat theHandleand populateOption1/2/3 Value,Variant SKU, andVariant Price.
2. Clean Python exporter (Shopify Import CSV format)
Here is a minimal, production-safe Python script that paginates /products.json and writes a Shopify-compatible CSV with UTF-8 BOM (so Excel opens accented characters and currency symbols cleanly):
import csv
import time
import requests
STORE = "https://example-shop.com"
OUT = "shopify_products.csv"
def fetch_all_products(store_url: str) -> list[dict]:
items, page = [], 1
session = requests.Session()
session.headers["User-Agent"] = "CatalogExporter/1.0"
while True:
resp = session.get(f"{store_url.rstrip('/')}/products.json",
params={"limit": 250, "page": page}, timeout=20)
if resp.status_code == 429:
time.sleep(2.5)
continue
resp.raise_for_status()
batch = resp.json().get("products", [])
if not batch:
break
items.extend(batch)
page += 1
time.sleep(0.35)
return items
def write_shopify_csv(products: list[dict], path: str) -> None:
cols = [
"Handle", "Title", "Body (HTML)", "Vendor", "Type", "Tags",
"Option1 Name", "Option1 Value", "Option2 Name", "Option2 Value",
"Variant SKU", "Variant Price", "Variant Compare At Price", "Image Src",
]
with open(path, "w", newline="", encoding="utf-8-sig") as f:
w = csv.writer(f)
w.writerow(cols)
for p in products:
opts = p.get("options") or []
o1_name = opts[0]["name"] if len(opts) > 0 else "Title"
o2_name = opts[1]["name"] if len(opts) > 1 else ""
imgs = [im["src"] for im in p.get("images", [])]
for idx, v in enumerate(p.get("variants") or [{}]):
first = idx == 0
w.writerow([
p.get("handle", ""),
p.get("title", "") if first else "",
p.get("body_html", "") if first else "",
p.get("vendor", "") if first else "",
p.get("product_type", "") if first else "",
", ".join(p.get("tags", [])) if first else "",
o1_name if first else "",
v.get("option1", ""),
o2_name if first else "",
v.get("option2", ""),
v.get("sku", ""),
v.get("price", ""),
v.get("compare_at_price") or "",
imgs[idx] if idx < len(imgs) else "",
])
if __name__ == "__main__":
prods = fetch_all_products(STORE)
write_shopify_csv(prods, OUT)
print(f"Exported {len(prods)} products to {OUT}")
3. Exporting in 1 click without writing scripts (Chrome Extension)
Writing Python is great for scheduled pipelines, but when you are browsing a store in Chrome and just want:
-
1-click export to Shopify Import CSV, WooCommerce CSV, multi-sheet Excel (
.xlsx), or JSON - Collection filtering, search, and best-seller sorting
- Store Inspector showing the active Shopify theme, currency, median price, % on sale / in stock, and 35+ detected apps (Klaviyo, Judge.me, Loox, Recharge, Gorgias, Triple Whale, PageFly, etc.)
We packaged all of this into a lightweight, 100% local Chrome extension (same-origin fetch inside the active tab — zero <all_urls> tracking and zero external servers):
- Install on Chrome Web Store: ShopExport — Shopify Product Exporter
- Extension hub & online Shopify API: radarbg.com/extensions#shopexport
The free tier includes the full Store Inspector and exports up to 25 products per store. Full catalogs (10,000+ products) unlock with a one-time €4.99 / 30-day Radar Pass (never renews) that also unlocks all 323 data tools on radarbg.com.
Disclosure: I build the tool used in this post, and the article was written with AI assistance. If a code sample does not work for you, tell me in the comments and I will fix it.
來源:DEV Community · dev.to