# Amazon-Search-Scraper (`nishanth_kj/amazon-search-scraper`) Actor

- **URL**: https://apify.com/nishanth\_kj/amazon-search-scraper.md
- **Developed by:** [Nishanth](https://apify.com/nishanth_kj) (community)
- **Categories:** E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 🛒 Amazon Product Scraper

Amazon Product Scraper is a powerful and fast Apify actor that uses Playwright and Google Chrome to extract live product details directly from Amazon search results or individual product pages.

### 🌟 Features

- **Keyword Search**: Extract product listings based on any search term.
- **Direct ASIN / URL**: Extract deep metadata from a single Amazon product page.
- **Live Playwright Data**: Uses real headless Google Chrome to bypass basic blocks and grab dynamic DOM data.
- **Clean Output**: Data is structured and delivered in JSON format suitable for e-commerce monitoring.

### 📥 Input Configuration

When running this actor, you need to configure the input. The actor takes a simple JSON object:

| Field | Type | Required | Default | Description |
| ----- | ---- | -------- | ------- | ----------- |
| `query` | String | *Conditional* | None | The keyword to search for (e.g. "Bluetooth Keyboard"). |
| `url` | String | *Conditional* | None | Direct link to a specific Amazon search results page. |
| `asin` | String | *Conditional* | None | Optional ASIN keywords. |
| `country` | String | No | `US` | Two-letter country code. |
| `page` | Integer | No | `1` | Page number to start scraping from. |
| `max_results`| Integer | No | `20` | Maximum number of products to scrape from search results. |
| `proxy_url` | String | No | None | Optional custom proxy URL. |

*Note: You must provide at least one of `query`, `url`, or `asin`.*

#### Example Input:

```json
{
  "query": "Bluetooth Keyboard",
  "country": "US",
  "page": 1,
  "max_results": 20
}
```

### 📤 Output Configuration

The actor stores its results in the default Apify Dataset. The output will always be wrapped in a `products` array to ensure consistent data structures.

#### Example Output:

```json
{
  "products": [
    {
      "asin": "B08N5WRWNW",
      "title": "Logitech K380 Bluetooth Keyboard",
      "price": 39.99,
      "rating": "4.6 out of 5 stars",
      "image": "https://m.media-amazon.com/images/I/sample.jpg",
      "url": "https://www.amazon.com/dp/B08N5WRWNW"
    }
  ]
}
```

### 🚀 How to Run Locally

If you are a developer and want to test this actor directly on your machine without using Docker, there are two easy
methods:

#### Method 1: Python Entrypoint (Fastest)

Just run the Python entrypoint script directly. If no input configuration file is found, it will safely prompt you in the terminal.

1. Ensure you have `uv` and Python installed.
2. Run the actor using the command:
   ```bash
   python main.py
   # or using uv
   uv run python main.py
   ```
3. Enter your search query into the terminal prompt.

#### Method 2: Simulate Apify using `INPUT.json`

To test exactly how it runs on the Apify platform, you can create a local JSON file that the Apify SDK automatically
parses.

1. Create a file at `storage/key_value_stores/default/INPUT.json` inside the Actor directory.
2. Add your input JSON, for example:
   ```json
   {
     "query": "Bluetooth Keyboard",
     "max_results": 5
   }
   ```
3. Run the actor using the command:
   ```bash
   python main.py
   # or using uv
   uv run python main.py
   ```
4. The scraper will silently read the JSON file and dump the results into `storage/datasets/default/`.

#### 🐳 Building with Docker

If you want to build the Docker image locally to test the exact environment Apify uses:

Because Apify projects use the root folder for context, you must run the build command from the root directory of the project, pointing it to the `.actor/Dockerfile`:

```bash
docker build -t amazon-scraper -f .actor/Dockerfile .
```

### 💬 Support

If you find any bugs or have feature requests, please reach out via the Apify platform!

# Actor input Schema

## `query` (type: `string`):

Product keywords to search for.

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

Two letter country code (e.g. US, UK).

## `page` (type: `integer`):

Page number to start scraping from.

## `max_results` (type: `integer`):

Limit the number of products scraped.

## Actor input object example

```json
{
  "query": "keyboard",
  "country": "US",
  "page": 1,
  "max_results": 20
}
```

# Actor output Schema

## `results` (type: `string`):

An array of all scraped Amazon products.

## `productsJson` (type: `string`):

A JSON file containing all scraped products.

# 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 = {
    "query": "keyboard",
    "country": "US",
    "page": 1,
    "max_results": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("nishanth_kj/amazon-search-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 = {
    "query": "keyboard",
    "country": "US",
    "page": 1,
    "max_results": 20,
}

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

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

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

```

## CLI example

```bash
echo '{
  "query": "keyboard",
  "country": "US",
  "page": 1,
  "max_results": 20
}' |
apify call nishanth_kj/amazon-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=nishanth_kj/amazon-search-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/4BcbOvCd6HDP7bPJ8/builds/Df2ZQSUN0835hv7ka/openapi.json
