Google Shopping results aggregate product listings from thousands of retailers and appear prominently in Google search results. They are a valuable source of competitive pricing intelligence, merchant discovery, and market price benchmarking. The Scavio API returns Google Shopping results in the shopping_results field of SERP responses, including product title, price, merchant, rating, and image URL. This tutorial shows how to extract and analyze Google Shopping data for any product category.
Prerequisites
- Python 3.8 or higher
- requests library installed
- A Scavio API key
- Familiarity with price data analysis
Walkthrough
Step 1: Fetch Google Shopping results
Add "shopping" context to your query or query a product name directly. Google Shopping results appear in shopping_results in the Scavio response.
def get_shopping(product: str) -> list[dict]:
response = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"query": product, "country_code": "us"}
)
response.raise_for_status()
data = response.json()
return data.get("shopping_results", [])Step 2: Extract pricing by merchant
Build a dictionary mapping merchant names to their listed prices for the product.
def prices_by_merchant(items: list[dict]) -> dict:
result = {}
for item in items:
merchant = item.get("source", "Unknown")
price = item.get("price", "N/A")
result[merchant] = price
return resultStep 3: Find the lowest price
Parse prices and identify the merchant offering the lowest listed price.
def lowest_price(items: list[dict]) -> dict | None:
def parse(item):
p = item.get("price", "")
return float(p.replace("$", "").replace(",", "")) if p else float("inf")
return min(items, key=parse, default=None)Step 4: Generate a price intelligence summary
Print a summary of the price range across merchants and highlight the best deal.
items = get_shopping("iPhone 16 Pro")
merchants = prices_by_merchant(items)
best = lowest_price(items)
print(f"Found {len(items)} listings")
print(f"Best price: {best.get('price')} from {best.get('source')}")
for m, p in list(merchants.items())[:5]:
print(f" {m}: {p}")Python Example
import os
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 lowest_price(items: list[dict]) -> dict | None:
def val(item):
p = item.get("price", "")
return float(p.replace("$", "").replace(",", "")) if p else float("inf")
return min(items, key=val, default=None)
if __name__ == "__main__":
items = get_shopping("Sony WH-1000XM5 headphones")
best = lowest_price(items)
print(f"{len(items)} shopping listings found")
if best:
print(f"Lowest: {best.get('price')} at {best.get('source')}")
for item in items[:5]:
print(f" {item.get('source', 'N/A')}: {item.get('price', 'N/A')}")JavaScript Example
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 || [];
}
async function main() {
const items = await getShopping("Sony WH-1000XM5 headphones");
const sorted = items.sort((a, b) => {
const pa = parseFloat((a.price || "").replace(/[$,]/g, "")) || Infinity;
const pb = parseFloat((b.price || "").replace(/[$,]/g, "")) || Infinity;
return pa - pb;
});
console.log(`${items.length} listings found`);
sorted.slice(0, 5).forEach(i => console.log(`${i.source}: ${i.price}`));
}
main().catch(console.error);Expected Output
{
"shopping_results": [
{
"title": "Sony WH-1000XM5 Wireless Headphones",
"price": "$279.00",
"source": "Best Buy",
"rating": "4.8",
"reviews": 9842,
"link": "https://bestbuy.com/...",
"thumbnail": "https://cdn.bestbuy.com/..."
}
]
}