# ApifyAmazonScanner (`chuckling_hemp/apifyamazonscanner`) Actor

- **URL**: https://apify.com/chuckling\_hemp/apifyamazonscanner.md
- **Developed by:** [Matt Cook](https://apify.com/chuckling_hemp) (community)
- **Categories:** Developer tools, Automation, Agents
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Product Scraper (Apify actor)

Scrapes **Amazon product data based on URL and country, without the Amazon API**:
reviews, prices, descriptions, ASINs, ratings, images, Best Sellers Rank, and the
full product-information tables.

Feed it any mix of Amazon URLs — search results, category / browse-node pages,
Best Sellers pages, or product detail pages — and/or a bare search keyword plus a
country, and it writes one JSON record per product to the run's dataset.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `categoryOrProductUrls` | `[{ url }]` | — | Search (`/s?k=…`), category (`/b?node=…`), Best Sellers (`/gp/bestsellers/…`), or product (`/dp/ASIN`) URLs. Bare ASINs also accepted. Aliases: `startUrls`, `productUrls`. |
| `search` | string | — | Bare keyword; searched on the `country` marketplace. Aliases: `keyword`, `searchKeywords`, `keywords`, `queries`. |
| `country` | string | `US` | Marketplace for bare keywords + proxy geolocation. 23 marketplaces supported (US, GB/UK, DE, FR, IT, ES, CA, JP, IN, MX, BR, AU, NL, SE, PL, TR, AE, SG, SA, BE, IE, EG, ZA). **A URL's own domain always wins** — `country` then only steers the proxy. |
| `maxItems` | int | `100` | Total product cap for the run. Alias: `maxResults`. |
| `maxItemsPerStartUrl` | int | `0` (off) | Per-start-URL cap. Alias: `maxProductsPerStartUrl`. |
| `maxSearchPagesPerStartUrl` | int | `5` | Result pages walked per search/category URL (Amazon serves ≤ ~20). |
| `scrapeProductDetails` | bool | `true` | OFF = shallow, fast listing-only records (no dp-page visits). |
| `scrapeReviews` | bool | `true` | Alias: `includeReviews`. Requires details ON. |
| `maxReviews` | int | `20` | Per product. Amazon caps anonymous review pages at ~10 (~100 reviews); where the reviews pages are login-walled (increasingly common since late 2024) the actor keeps the product page's top reviews instead. |
| `reviewsSort` | `helpful`|`recent` | `helpful` | Review page order. |
| `proxyConfiguration` | proxy | Apify RESIDENTIAL | Amazon blocks datacenter IPs quickly — keep residential. |

Robot-check pages are detected (captcha form, block-page markers) and retried on a
fresh session/IP automatically; requests that still fail salvage what's already
known (listing-row data, on-page reviews) instead of dropping the product.

### Output (one record per product)

```jsonc
{
  "asin": "B0TESTMUG1",
  "url": "https://www.amazon.com/dp/B0TESTMUG1",
  "title": "Bigfoot Sasquatch Coffee Mug, 15 oz Ceramic",
  "brand": "CryptidWorks",
  "price": 18.99,
  "priceRaw": "$18.99",
  "currency": "USD",
  "listPrice": 24.99,
  "rating": 4.6,
  "reviewsCount": 1234,
  "inStock": true,
  "availability": "In Stock",
  "featureBullets": ["15 oz ceramic mug…", "Dishwasher and microwave safe"],
  "description": "Start every morning with the legend himself…",
  "image": "https://m.media-amazon.com/images/I/71test._AC_SL1500_.jpg",
  "images": ["…hi-res first…"],
  "breadcrumbs": ["Home & Kitchen", "Mugs"],
  "bsr": 12345,
  "bestsellerRanks": [{ "rank": 12345, "category": "Home & Kitchen" }, { "rank": 678, "category": "Coffee Mugs" }],
  "attributes": { "Brand": "CryptidWorks", "Material": "Ceramic", "ASIN": "B0TESTMUG1" },
  "reviews": [
    {
      "id": "R1TEASER001", "title": "Best mug I own", "rating": 5,
      "body": "Sturdy, funny…", "author": "Jane D.",
      "date": "March 3, 2025", "country": "United States",
      "verified": true, "helpfulVotes": 12, "variant": "Color: Forest Green"
    }
  ],
  "sponsored": false,
  "domain": "amazon.com",
  "country": "US",
  "scrapedAt": "2026-07-05T12:00:00.000Z"
}
```

The field names (`asin`, `title`, `brand`, `price`, `rating`, `reviewsCount`,
`bsr`, `url`, `image`) line up with what the common Amazon actors emit, so
consumers built for those (including the Suppliers app's
`src/ai/amazon-scan.ts` normalizer) read this actor's output unchanged.

### Develop / test / deploy

```bash
npm install
npm test                    # fixture-pinned parser tests, no network

## local run against real Amazon (uses your logged-in `apify` CLI for proxy):
apify run --purge --input '{"search":"bigfoot mug","country":"US","maxItems":5,"maxReviews":5}'

## deploy to your Apify account:
apify login
apify push
```

Once pushed, point the Suppliers app at it by setting
`APIFY_AMAZON_ACTOR=<your-apify-username>/amazon-product-scraper` on Render
(the actor name comes from `.actor/actor.json`; the app's default is a
third-party store actor — this makes the Amazon market scan run on your own
actor and your own proxy budget).

### Design notes

- **CheerioCrawler, no browser** — every page shape used (search grid, dp page,
  reviews pages, bestseller grid) renders its data server-side, so plain HTTP is
  \~10× cheaper than a headless browser. Bestseller grids lazy-load beyond ~30
  items per page; the actor takes both static pages (`pg=1,2`) which covers the
  Top-100 lists' server-rendered portion.
- **Fallback selector chains everywhere** — Amazon A/B-tests layouts; every field
  reads primary + legacy selectors (`test/fixtures/` pins them).
- **Reviews strategy** — dp-page top reviews are captured first (always
  available), then the dedicated `/product-reviews/` pages are walked up to
  `maxReviews` / Amazon's ~10-page anonymous cap; a login-walled reviews page
  degrades gracefully to the top reviews rather than losing the product.
- **Budgeting** — a `scheduled` counter reserves dataset slots at listing time so
  the crawler never fans out to hundreds of dp pages it won't use; `maxItems`
  triggers a graceful `crawler.stop()`.

# Actor input Schema

## `categoryOrProductUrls` (type: `array`):

Any mix of Amazon URLs: search results (<code>/s?k=…</code>), category or browse-node pages (<code>/b?node=…</code>), Best Sellers pages (<code>/gp/bestsellers/…</code>), or product detail pages (<code>/dp/ASIN</code>). The marketplace domain in each URL wins over the Country setting.

## `search` (type: `string`):

A bare keyword to search for. Used when no URLs are given (or in addition to them); the search runs on the marketplace chosen by <b>Country</b>. Aliases accepted from other actors' inputs: <code>keyword</code>, <code>searchKeywords</code>, <code>keywords</code>.

## `country` (type: `string`):

Which country's Amazon to scrape when the input is a bare keyword, and which country the proxy should exit from. When a full URL is given, its domain decides the marketplace and this only steers the proxy geolocation.

## `maxItems` (type: `integer`):

Stop after this many products have been saved across the whole run.

## `maxItemsPerStartUrl` (type: `integer`):

Cap the number of products taken from each start URL / keyword. 0 = no per-URL cap (only the total cap applies).

## `maxSearchPagesPerStartUrl` (type: `integer`):

How many result pages to walk per search/category start URL (Amazon serves at most ~7–20).

## `scrapeProductDetails` (type: `boolean`):

ON: every product found on a listing page is opened to extract the full record (description, feature bullets, images, BSR, attributes, reviews). OFF: listing pages are scraped shallowly (title / price / rating / review count / image only) — much faster and cheaper.

## `scrapeReviews` (type: `boolean`):

Collect customer reviews for each product (the on-page top reviews, extended via the product-reviews pages when accessible). Requires product details ON.

## `maxReviews` (type: `integer`):

Cap on reviews collected per product. Note: Amazon only exposes ~100 reviews per product to anonymous sessions (10 pages), and in some regions review pages beyond the product page require login — the actor then keeps the product page's top reviews.

## `reviewsSort` (type: `string`):

Order in which Amazon serves the review pages being scraped.

## `proxyConfiguration` (type: `object`):

Amazon blocks datacenter IPs quickly — residential proxy strongly recommended.

## Actor input object example

```json
{
  "categoryOrProductUrls": [
    {
      "url": "https://www.amazon.com/s?k=bigfoot+mug"
    }
  ],
  "search": "bigfoot mug",
  "country": "US",
  "maxItems": 100,
  "maxItemsPerStartUrl": 0,
  "maxSearchPagesPerStartUrl": 5,
  "scrapeProductDetails": true,
  "scrapeReviews": true,
  "maxReviews": 20,
  "reviewsSort": "helpful",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "categoryOrProductUrls": [
        {
            "url": "https://www.amazon.com/s?k=bigfoot+mug"
        }
    ],
    "search": "bigfoot mug",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("chuckling_hemp/apifyamazonscanner").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 = {
    "categoryOrProductUrls": [{ "url": "https://www.amazon.com/s?k=bigfoot+mug" }],
    "search": "bigfoot mug",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("chuckling_hemp/apifyamazonscanner").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 '{
  "categoryOrProductUrls": [
    {
      "url": "https://www.amazon.com/s?k=bigfoot+mug"
    }
  ],
  "search": "bigfoot mug",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call chuckling_hemp/apifyamazonscanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,chuckling_hemp/apifyamazonscanner"
        }
    }
}
```

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/cRcanrLX9h4PGoEz3/builds/PszL4J0MTkMzNzf2q/openapi.json
