# Amazon Best Sellers Scraper (`happitap/amazon-best-sellers-scraper`) Actor

Extracts real-time product listings from Amazon's Best Sellers pages with structured data including title, ASIN, rank, price, ratings, reviews, and more. Perfect for eCommerce competitor analysis, product research, and trend monitoring.

- **URL**: https://apify.com/happitap/amazon-best-sellers-scraper.md
- **Developed by:** [HappiTap](https://apify.com/happitap) (community)
- **Categories:** E-commerce, Integrations, Developer tools
- **Features:** Limited permissions
- **Stats:** 130 total users, 1 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Amazon Best Sellers Scraper

An Apify actor that extracts real-time product listings from Amazon's "Best Sellers" pages, which feature the most popular items by category based on sales rank.

### What It Does

This scraper extracts structured data from Amazon Best Sellers pages including:

| Field | Description |
|-------|-------------|
| `title` | Product name/title |
| `asin` | Amazon Standard Identification Number |
| `rank` | Best seller rank in category |
| `category` | The category/subcategory the product belongs to |
| `price` | Current product price |
| `rating` | Average user rating (e.g., 4.5) |
| `reviewCount` | Total number of user reviews |
| `url` | Direct product URL on Amazon |
| `imageUrl` | Product image thumbnail |
| `sponsored` | Whether it's a sponsored/listed product |

### Use Cases

- **eCommerce Competitor Analysis**: Find top-performing products in your niche or monitor competing listings
- **Product Research for Dropshipping / Amazon FBA**: Discover high-demand products in real time
- **Trend Monitoring**: Track how best seller rankings change over time
- **Price Tracking Tools**: Get price and review fluctuations for best-selling products

### Input

The actor accepts the following input format:

```json
{
  "startUrls": [
    { "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics" }
  ],
  "category": "Electronics",
  "maxProducts": 50
}
```

#### Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `startUrls` | Array | Yes | - | Array of objects with `url` property pointing to Amazon Best Sellers pages |
| `category` | String | No | `''` | Category name for the products (auto-detected if not provided) |
| `maxProducts` | Number | No | `100` | Maximum number of products to extract per page |

#### Supported Amazon Best Sellers URLs

The scraper works with any Amazon Best Sellers page. Here are some examples:

- **Main Best Sellers**: `https://www.amazon.com/Best-Sellers/zgbs`
- **Electronics**: `https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics`
- **Books**: `https://www.amazon.com/Best-Sellers-Books/zgbs/books`
- **Home & Kitchen**: `https://www.amazon.com/Best-Sellers-Home-Kitchen/zgbs/home-garden`
- **Sports & Outdoors**: `https://www.amazon.com/Best-Sellers-Sports-Outdoors/zgbs/sporting-goods`
- **Toys & Games**: `https://www.amazon.com/Best-Sellers-Toys-Games/zgbs/toys-and-games`

### Output

The actor outputs structured data for each product found:

```json
{
  "title": "Echo Dot (5th Gen)",
  "asin": "B09B8V1LZ3",
  "rank": 1,
  "category": "Electronics",
  "price": "$49.99",
  "rating": 4.6,
  "reviewCount": 12500,
  "url": "https://www.amazon.com/dp/B09B8V1LZ3",
  "imageUrl": "https://m.media-amazon.com/images/I/61ZRU9gnbxL._AC_UL320_.jpg",
  "sponsored": false,
  "scrapedAt": "2024-01-01T00:00:00.000Z"
}
```

### Example Usage

#### Basic Electronics Best Sellers

```json
{
  "startUrls": [
    { "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics" }
  ],
  "category": "Electronics",
  "maxProducts": 100
}
```

#### Multiple Categories

```json
{
  "startUrls": [
    { "url": "https://www.amazon.com/Best-Sellers-Books/zgbs/books" },
    { "url": "https://www.amazon.com/Best-Sellers-Home-Kitchen/zgbs/home-garden" }
  ],
  "maxProducts": 50
}
```

#### Top 10 Products Only

```json
{
  "startUrls": [
    { "url": "https://www.amazon.com/Best-Sellers-Sports-Outdoors/zgbs/sporting-goods" }
  ],
  "category": "Sports & Outdoors",
  "maxProducts": 10
}
```

### How It Works

1. **Page Navigation**: Uses Puppeteer to load Amazon Best Sellers pages with stealth mode
2. **Product Detection**: Identifies product containers using multiple CSS selectors for maximum compatibility
3. **Data Extraction**: Extracts all required fields using robust selectors that handle Amazon's dynamic layout
4. **Data Validation**: Ensures only products with valid ASINs and titles are included
5. **Structured Output**: Returns clean, structured data ready for analysis

### Features

- **Robust Extraction**: Multiple fallback selectors to handle Amazon's changing page structure
- **Stealth Mode**: Uses Puppeteer with stealth plugins to avoid detection
- **Proxy Support**: Built-in proxy rotation for reliable scraping
- **Error Handling**: Graceful error handling with detailed logging
- **Data Validation**: Ensures data quality with validation checks

### Installation

1. Clone this repository
2. Install dependencies: `npm install`
3. Run the actor: `npm start`

### Development

- `npm start` - Run the actor
- `npm run format` - Format code with Prettier
- `npm run lint` - Run ESLint
- `npm run lint:fix` - Fix ESLint issues

### Architecture

- `src/main.js` - Main entry point and input validation
- `src/routes.js` - Request routing
- `src/handlers/amazonBestSellers.js` - Amazon Best Sellers scraping logic
- `src/puppeteerLauncher.js` - Puppeteer browser configuration with stealth mode

### Notes

- The scraper is designed to be respectful of Amazon's servers and includes appropriate delays
- Results may vary based on Amazon's page structure changes
- The scraper automatically handles different Amazon page layouts and product formats
- All extracted data is timestamped for tracking purposes

# Actor input Schema

## `startUrls` (type: `array`):

Array of Amazon Best Sellers URLs to scrape. Each URL should be an object with a 'url' property pointing to Amazon Best Sellers pages.

## `category` (type: `string`):

Category name for the products (e.g., 'Electronics', 'Books', 'Home & Kitchen'). If not provided, will be auto-detected from the page.

## `maxProducts` (type: `integer`):

Maximum number of products to extract per page

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics"
    }
  ],
  "category": "",
  "maxProducts": 5
}
```

# Actor output Schema

## `products` (type: `string`):

Complete list of scraped Amazon Best Sellers products with all details

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics"
        }
    ],
    "maxProducts": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("happitap/amazon-best-sellers-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": [{ "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics" }],
    "maxProducts": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("happitap/amazon-best-sellers-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics"
    }
  ],
  "maxProducts": 5
}' |
apify call happitap/amazon-best-sellers-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,happitap/amazon-best-sellers-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/jm4192gDoX7CHY7IB/builds/7XRSAsdIzUJXcxsjI/openapi.json
