DEV Community

Bachir Djoukbala
Bachir Djoukbala

Posted on

How to export every product from any Shopify store to CSV with Python (products.json)

Most Shopify stores expose their full catalog as JSON at /products.json. No HTML parsing, no API key. It is paginated (250 per page), so you loop until a page comes back empty.

import httpx, csv

def products(domain):
    out, page = [], 1
    while True:
        r = httpx.get(f"https://{domain}/products.json",
                      params={"limit": 250, "page": page},
                      follow_redirects=True, timeout=20,
                      headers={"User-Agent": "Mozilla/5.0"})
        r.raise_for_status()
        items = r.json()["products"]
        if not items:
            break
        out += items
        page += 1
    return out

ps = products("allbirds.com")
print(len(ps))   # 324 at the time of writing

with open("products.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["title", "vendor", "price", "available", "url"])
    for x in ps:
        v = x["variants"][0]
        w.writerow([x["title"], x["vendor"], v["price"],
                    any(v["available"] for v in x["variants"]),
                    f"https://allbirds.com/products/{x['handle']}"])
Enter fullscreen mode Exit fullscreen mode

Each product also carries variants (sku, price, compare_at_price, availability), images, tags, product_type and updated_at, so you can compute discounts (compare_at_price vs price) or spot new arrivals.

Caveats: some stores disable or password-protect the endpoint (you get a 404 or 401), and hammering a store is rude, so add a delay and keep volumes small.

Disclosure: I built a hosted version of this on Apify, Shopify Store Data Monitor. It tracks price drops, restocks and new products across many stores on a schedule, so you don't have to keep your own diffing script running. If you just need to know which stores run Shopify and how to contact them, see Shopify Store Leads Enricher.

Top comments (0)