Tutorial

How to Replace Your Amazon Scraper with Search API

Migrate from fragile Selenium or Puppeteer Amazon scrapers to the Scavio API. Get structured product data without bot detection or proxy management.

Amazon scrapers built with Selenium or Puppeteer break constantly. Bot detection updates, CAPTCHA challenges, and layout changes mean you spend more time maintaining the scraper than using the data. The Scavio API provides structured Amazon product data through a stable endpoint that handles all the extraction complexity. This tutorial migrates a typical Amazon scraping setup to API calls, showing the before-and-after for product search, ASIN lookup, and price extraction. Each API call costs $0.005 with no proxy costs.

Prerequisites

  • Python 3.9+ installed
  • requests library installed
  • A Scavio API key from scavio.dev
  • An existing Amazon scraper to migrate (optional)

Walkthrough

Step 1: Compare the old scraper vs. API approach

See how a typical Selenium Amazon scraper looks versus the equivalent API call. The API version is shorter, faster, and does not break.

Python
import os, requests

SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'}
URL = 'https://api.scavio.dev/api/v1/search'

# OLD: Selenium scraper (30+ lines, breaks monthly)
# from selenium import webdriver
# driver = webdriver.Chrome()
# driver.get(f'https://amazon.com/s?k={query}')
# time.sleep(3)  # Wait for page load
# products = driver.find_elements(By.CSS_SELECTOR, '[data-component-type="s-search-result"]')
# ... parse each product, handle pagination, CAPTCHAs, etc.

# NEW: API call (5 lines, stable)
def search_amazon(query: str, num: int = 5) -> list:
    resp = requests.post(URL, headers=H,
        json={'platform': 'amazon', 'query': query, 'marketplace': 'US', 'num_results': num})
    resp.raise_for_status()
    return resp.json().get('products', resp.json().get('organic_results', []))

results = search_amazon('wireless earbuds')
print(f'Found {len(results)} products')
for r in results[:3]:
    print(f'  {r.get("title", "")[:60]}')
    print(f'  Price: {r.get("price", "N/A")} | Rating: {r.get("rating", "N/A")}')

Step 2: Migrate ASIN lookup to API

Replace direct ASIN page scraping with an API call. The API returns structured price, rating, review count, and availability data.

Python
def lookup_asin(asin: str) -> dict:
    """Look up a specific ASIN's product data."""
    resp = requests.post(URL, headers=H,
        json={'platform': 'amazon', 'query': asin, 'marketplace': 'US'})
    resp.raise_for_status()
    data = resp.json()
    product = data.get('product', data)
    return {
        'asin': asin,
        'title': product.get('title', ''),
        'price': product.get('price', ''),
        'rating': product.get('rating', ''),
        'reviews': product.get('reviews_count', 0),
        'availability': product.get('availability', ''),
    }

product = lookup_asin('B09G9FPHY6')
for k, v in product.items():
    print(f'  {k}: {v}')

Step 3: Batch migrate multiple ASINs

Migrate a list of ASINs from your scraper queue to API lookups. Add rate limiting to stay within your plan's credit budget.

Python
import time

def batch_lookup(asins: list, delay: float = 0.3) -> list:
    results = []
    for asin in asins:
        try:
            product = lookup_asin(asin)
            results.append(product)
            print(f'[OK] {asin}: {product["price"]} - {product["title"][:40]}')
        except Exception as e:
            print(f'[ERR] {asin}: {e}')
            results.append({'asin': asin, 'error': str(e)})
        time.sleep(delay)
    success = sum(1 for r in results if 'error' not in r)
    print(f'\nBatch complete: {success}/{len(asins)} succeeded')
    print(f'Cost: ${len(asins) * 0.005:.3f}')
    return results

asins = ['B09G9FPHY6', 'B07FZ8S74R', 'B08N5WRWNW']
batch_lookup(asins)

Python Example

Python
import os, requests, time

SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'}

def search_amazon(query, num=5):
    resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'amazon', 'query': query, 'marketplace': 'US', 'num_results': num})
    return resp.json().get('products', resp.json().get('organic_results', []))

def lookup_asin(asin):
    resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'amazon', 'query': asin, 'marketplace': 'US'})
    return resp.json().get('product', resp.json())

results = search_amazon('wireless earbuds')
print(f'{len(results)} products found')
for r in results[:3]:
    print(f'  {r.get("title", "")[:50]} | {r.get("price", "N/A")}')

JavaScript Example

JavaScript
const SCAVIO_KEY = process.env.SCAVIO_API_KEY;

async function searchAmazon(query) {
  const resp = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ platform: 'amazon', query, marketplace: 'US', num_results: 5 })
  });
  const data = await resp.json();
  return data.products || data.organic_results || [];
}

async function lookupAsin(asin) {
  const resp = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ platform: 'amazon', query: asin, marketplace: 'US' })
  });
  return (await resp.json()).product || {};
}

searchAmazon('wireless earbuds').then(r => {
  r.slice(0, 3).forEach(p => console.log(`${p.title?.slice(0, 50)} | ${p.price}`));
});

Expected Output

JSON
Found 5 products
  Sony WF-1000XM5 Truly Wireless Noise Cancelling Ea
  Price: $248.00 | Rating: 4.6
  Apple AirPods Pro 2nd Generation with USB-C
  Price: $189.99 | Rating: 4.7
  Samsung Galaxy Buds3 Pro
  Price: $159.99 | Rating: 4.4

[OK] B09G9FPHY6: $29.99 - Echo Dot (5th Gen) | Smart speaker
[OK] B07FZ8S74R: $24.99 - Fire TV Stick 4K with Alexa Voice
[OK] B08N5WRWNW: $89.99 - Kindle Paperwhite (11th Generatio

Batch complete: 3/3 succeeded
Cost: $0.015

Related Tutorials

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.9+ installed. requests library installed. A Scavio API key from scavio.dev. An existing Amazon scraper to migrate (optional). 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.

Start Building

Migrate from fragile Selenium or Puppeteer Amazon scrapers to the Scavio API. Get structured product data without bot detection or proxy management.