ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Extract Structured Google Shopping Data via API
Tutorial

How to Extract Structured Google Shopping Data via API

Pull structured Google Shopping product data including prices, merchants, ratings, and images using the Scavio API. Build price intelligence feeds in Python.

Get Free API KeyAPI Docs

Google Shopping aggregates product listings from thousands of merchants into a structured comparison format. Extracting this data at scale is valuable for price intelligence platforms, competitive monitoring, and catalog enrichment. The Scavio API returns Google Shopping results in the shopping_results field with product title, price, merchant name, rating, review count, image URL, and product link. This tutorial builds a structured data extraction pipeline that queries Google Shopping for product categories and normalizes the output for analytics.

Prerequisites

  • Python 3.8 or higher
  • requests library installed
  • A Scavio API key
  • Product categories or specific products to monitor

Walkthrough

Step 1: Fetch Google Shopping results

Query the Scavio endpoint for a product. Shopping results appear in the shopping_results array of the response.

Python
def get_shopping_data(product: str) -> list[dict]:
    r = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"query": product, "country_code": "us"}
    )
    r.raise_for_status()
    return r.json().get("shopping_results", [])

Step 2: Normalize the shopping data

Transform raw shopping results into a consistent schema with parsed price values for analysis.

Python
def normalize_item(item: dict) -> dict:
    price_str = item.get("price", "")
    price = float(price_str.replace("$", "").replace(",", "")) if price_str else None
    return {
        "title": item.get("title", ""),
        "price": price,
        "price_raw": price_str,
        "merchant": item.get("source", ""),
        "rating": float(item.get("rating", 0) or 0),
        "reviews": int(item.get("reviews", 0) or 0),
        "link": item.get("link", ""),
        "thumbnail": item.get("thumbnail", ""),
    }

Step 3: Compute price statistics

Calculate min, max, median, and average prices across all merchants for a product.

Python
import statistics

def price_stats(items: list[dict]) -> dict:
    prices = [i["price"] for i in items if i["price"] is not None]
    if not prices:
        return {"min": None, "max": None, "median": None, "mean": None}
    return {
        "min": min(prices),
        "max": max(prices),
        "median": statistics.median(prices),
        "mean": round(statistics.mean(prices), 2),
    }

Step 4: Export structured feed

Write the normalized shopping data to a JSON file suitable for ingestion by analytics tools or databases.

Python
import json

def export_feed(product: str, items: list[dict]) -> None:
    feed = {
        "product": product,
        "item_count": len(items),
        "stats": price_stats(items),
        "items": items,
    }
    with open(f"shopping_{product.replace(' ', '_')}.json", "w") as f:
        json.dump(feed, f, indent=2)
    print(f"Exported {len(items)} items for {product}")

Python Example

Python
import os
import json
import statistics
import requests

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def get_shopping(product: str) -> list[dict]:
    r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
                      json={"query": product, "country_code": "us"})
    r.raise_for_status()
    return r.json().get("shopping_results", [])

def normalize(item: dict) -> dict:
    p = item.get("price", "")
    return {
        "title": item.get("title"), "price": float(p.replace("$", "").replace(",", "")) if p else None,
        "merchant": item.get("source"), "rating": item.get("rating"), "reviews": item.get("reviews"),
    }

if __name__ == "__main__":
    items = [normalize(i) for i in get_shopping("mechanical keyboard")]
    prices = [i["price"] for i in items if i["price"]]
    print(f"Found {len(items)} listings")
    if prices:
        print(f"Price range: ${min(prices):.2f} - ${max(prices):.2f}")
        print(f"Median: ${statistics.median(prices):.2f}")
    for i in sorted(items, key=lambda x: x["price"] or float("inf"))[:5]:
        print(f"  {i['merchant']}: ${i['price']:.2f} - {i['title'][:50]}")

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

async function getShopping(product) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ query: product, country_code: "us" })
  });
  const data = await res.json();
  return (data.shopping_results || []).map(i => ({
    title: i.title, price: i.price ? parseFloat(i.price.replace(/[$,]/g, "")) : null,
    merchant: i.source, rating: i.rating
  }));
}

async function main() {
  const items = await getShopping("mechanical keyboard");
  const prices = items.map(i => i.price).filter(Boolean);
  console.log(`${items.length} listings, $${Math.min(...prices)} - $${Math.max(...prices)}`);
  items.sort((a, b) => (a.price || Infinity) - (b.price || Infinity)).slice(0, 5)
    .forEach(i => console.log(`  ${i.merchant}: $${i.price} - ${i.title?.slice(0, 50)}`));
}
main().catch(console.error);

Expected Output

JSON
Found 15 listings
Price range: $39.99 - $299.99
Median: $89.99
  Amazon: $39.99 - Redragon K552 Mechanical Gaming Keyboard
  Walmart: $49.99 - RK ROYAL KLUDGE RK61 60% Mechanical
  Best Buy: $74.99 - HyperX Alloy Origins Core Mechanical

Related Tutorials

  • How to Fetch Google Shopping Results via API
  • How to Build a Price Comparison Tool for Amazon and Walmart

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8 or higher. requests library installed. A Scavio API key. Product categories or specific products to monitor. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best Google Shopping Data APIs in 2026

Read more
Best Of

Best Google Shopping Data APIs in 2026

Read more
Glossary

Google Shopping Structured Search

Read more
Use Case

Google Ads SERP Extraction

Read more
Solution

Google Ads Data from SERP APIs

Read more
Solution

Get Google Shopping Data Without Proxies

Read more

Start Building

Pull structured Google Shopping product data including prices, merchants, ratings, and images using the Scavio API. Build price intelligence feeds in Python.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy