How to scrape Amazon product data using Python (+ no-code)

Learn how to use Amazon Product Scraper to retrieve product data from Amazon in a Python script via API integration.

Scraping Amazon product data can be daunting due to constantly changing page layouts, anti-bot measures, and deeply structured product information. This is one of those situations where managing custom scraping scripts is much harder due to maintenance issues than adopting a ready-to-use solution.

In this guide, you’ll learn how to bypass those challenges thanks to Amazon Product Scraper - a cloud-based Amazon data extraction tool. You’ll see how to use it visually on the Apify platform, as well as integrate it into Python to retrieve Amazon product data via API.

Specifically, you’ll be guided through the following steps:

  1. Python project setup
  2. Select the Actor (Amazon Product Scraper) from Apify Store
  3. Test the scraper with the UI (no code needed)
  4. Set up the API integration
  5. Prepare your Python script for Amazon product data scraping integration
  6. Retrieve and set your Apify API token
  7. Complete code
Apify logo
Need data from many e-commerce websites?
Check out E-commerce Scraping Tool. It collects data from category and product URLs from multiple websites in one run, giving you a single deduplicated dataset.
Try it for free

Why scraping Amazon is so challenging

As an Amazon user, you know that while the basic user interactions are consistent across products, each product page can display very different types of information.

Some pages include images and videos to showcase the product, others feature detailed descriptions with additional media, and some even include comparison tables highlighting different variants.

An example of a highly complex Amazon product page with a lot of custom info elements
An example of a highly complex Amazon product page with a lot of custom info elements

This variability poses a major challenge for web scraping because it’s difficult to define data parsing rules that can work across all product pages. Developing a scraper that can handle all those variations reliably requires writing numerous custom rules and logic to cover every possible edge case.

This dramatically increases maintenance costs. On top of that, Amazon actively blocks web scraping bots, often stopping automated requests after only a few attempts by showing error pages or triggering Amazon CAPTCHA challenges:

An example of the Amazon CAPTCHA
An example of the Amazon CAPTCHA

Taken together, these challenges make it much more practical to rely on a cloud-based Amazon scraper accessible via API. Such a service handles IP rotation, CAPTCHA solving, and - most importantly - manages edge cases and ongoing maintenance for you.

How to scrape Amazon product data via API in Python

In this step-by-step section, you’ll see how to use an Apify Actor to scrape Amazon via API. If you’re not familiar, an Apify Actor is a cloud-based scraper that runs on the Apify platform.

Apify currently offers over 960 Actors for Amazon scraping. Here, you’ll see how to connect to one of those Actors via API to programmatically scrape Amazon product data in a Python script.

Prerequisites

To follow this tutorial, make sure you have:

This tutorial uses Python for scraping Amazon product data, so you’ll also need:

1. Python project setup

If you don’t already have a Python project set up, follow these steps to create one.

Begin by creating a new folder for your Amazon product data scraper:

mkdir amazon-product-scraper

Navigate into the folder and set up a virtual environment inside it:

cd amazon-product-scraper
python -m venv .venv

Load the project in your Python IDE and create a new file named scraper.py. That’s where you’ll add the API-based scraping logic.

To activate the virtual environment on Windows, run this command in the IDE's terminal:

.venv\Scripts\activate

Equivalently, on Linux/macOS, execute:

source .venv/bin/activate

2. Select the Actor (Amazon Product Scraper) from Apify Store

To get started with Amazon product data scraping via API, log in to your Apify account, reach Apify Console, and select Apify Store from the left-hand menu:

Selecting Apify Store menu
Selecting Apify Store menu

On Apify Store, search for “Amazon” and press Enter:

Searching for “Amazon” on Apify Store
Searching for “Amazon” on Apify Store

As you can see, there are over 960 Amazon scraping Actors available. Since you’re specifically interested in product data, select Amazon Product Scraper:

Selecting Amazon Product Scraper
Selecting Amazon Product Scraper

You’ll then be redirected to the Actor page for the Amazon Product Scraper Actor:

Amazon Product Scraper in Console
Amazon Product Scraper in Console
📌
Note: Using this Actor requires a $40 monthly rental fee, which is deducted from your prepaid balance. However, you can still try it free for 14 days. If you’re on Apify’s free monthly plan, during the trial period you’ll only pay usage costs, which are deducted from the $5 monthly credit included in the plan.

3. Test the scraper with the UI (no code needed)

The goal of this scraping tutorial is to retrieve Amazon product data via API, through an Apify Actor. But before doing that, let’s first test the chosen Actor in Apify Console to make sure it works as expected.

First, click the Start button to begin renting the Actor:

Amazon Product Scraper - Start button
Clicking the Start button

Then, confirm by pressing the Rent Actor button:

Amazon Product Scraper - Rent Actor button
Clicking the Rent Actor button

You’ll now be able to launch the Actor directly in Apify Console by clicking Save & Start:

Amazon Product Scraper UI
Note the Save & Start button

Before doing so, configure the Actor with a specific product URL. For example, enter the URL of the Nintendo Switch 2 Amazon product page in the Enter one or more Amazon category or product URLs input field. Then, click Save & Start to launch the Actor:

Amazon Product Scraper UI
Clicking the Save & Start button to launch the Actor

This is what you should see:

The Actor execution in the Apify platform
The Actor execution in the Apify platform

Once the Actor finishes, you’ll view the scraped product data in the Output tab. The table displays exactly the product information extracted from the provided URL. For a closer look, switch to the All fields view and scroll horizontally through the table row:

Amazon Product Scraper output overview
Switching to the All fields view

All the data in the table's row matches what’s shown on the Nintendo Switch 2 Amazon product page:

Amazon product page with Nintendo Switch 2 System
The target Amazon product page

As you can see, Amazon Product Scraper works perfectly and retrieves product data as intended. This is a no-code approach to Amazon product scraping.

💡
Note: By changing the input URLs, you can use this Actor to scrape Amazon product data in different scenarios (e.g., product search pages, category pages, multiple product URLs at once, etc.). Once the data is retrieved, you can easily export it from Apify Console to formats like JSON, CSV, XML, Excel, HTML Table, RSS, or JSONL.

4. Set up the API integration

Now that you’ve confirmed the Actor works correctly, it’s time to configure it so you can call it via API.

On Amazon Product Scraper page, open the API dropdown in the top-right corner and select the API clients option:

Apify Console - API clients option
Selecting the API clients option

This will open the following modal:

The API clients modal in Apify Console
The API clients modal

The modal provides a ready-to-use code snippet for calling the selected Actor via API with the Apify API client. By default, it displays the Node.js version of the snippet. Since you’ll be working in Python, switch to the Python tab:

The Python tab for the API Clients modal
The Python tab for the API Clients modal

Finally, copy the Python snippet and paste it into your scraper.py file. Keep the modal open, as we’ll come back to it shortly.

5. Prepare your Python script for Amazon product data scraping integration

If you look at the code snippet copied from Apify Console, you’ll see it relies on the apify-client Python library. To install it, in your activated virtual environment, run:

pip install apify_client

In the snippet, you’ll also notice a placeholder for your Apify API token. That's a secret required to authenticate API calls made by the Apify API client.

The best practice is to never hard-code secrets directly in your code. Instead, you should store them in environment variables. To do that, we’ll use the python-dotenv library, which lets you load environment variables from a .env file.

In your activated environment, install it with:

pip install python-dotenv

Next, create a .env file in your project’s root folder. Your project should look like this:

amazon-product-scraper/
├── .venv/
├── .env       # <-----
└── scraper.py

Add the APIFY_API_TOKEN environment variable to the .env file:

APIFY_API_TOKEN="YOUR_APIFY_API_TOKEN"

"YOUR_APIFY_API_TOKEN" is just a placeholder for your Apify API token. You’ll see how to retrieve the actual value and set it in the next step.

Now, update scraper.py to load environment variables from .env and read the APIFY_API_TOKEN env:

from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()

# Read the required env
APIFY_API_TOKEN = os.getenv("APIFY_API_TOKEN")

The load_dotenv() function loads envs from the .env file, and os.getenv() lets you read them in your code.

Finally, pass the Apify API token to the client constructor:

client = ApifyClient(APIFY_API_TOKEN)

# ...

Your Amazon scraper is now properly configured for secure authentication.

6. Retrieve and set your Apify API token

The next step is to retrieve your Apify API token and add it to your .env file. This is the final piece needed to complete the Amazon scraping integration.

Back in the Amazon Product Scraper's API clients modal, click the Manage tokens button:

Manage tokens button in the Amazon Product Scraper Actor’s API clients modal
Clicking the Manage tokens button

You’ll be redirected to the API & Integrations tab of the Settings page. Here, click the Copy to clipboard icon on the Default API token created on sign up section:

Copying your Apify API token

Now, paste the token into your .env file like this:

APIFY_API_TOKEN="PASTE_YOUR_TOKEN_HERE"

Be sure to replace PASTE_YOUR_TOKEN_HERE with the actual token you just copied.

7. Complete code

Below's the complete scraper.py Python script that scrapes Amazon product data by calling an Actor via the Apify API:

from apify_client import ApifyClient
from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()

# Read the required env
APIFY_API_TOKEN = os.getenv("APIFY_API_TOKEN")

# Initialize the ApifyClient with your API token
client = ApifyClient(APIFY_API_TOKEN)

# Prepare the Actor input
run_input = {
    "categoryOrProductUrls": [{ "url": "https://www.amazon.com/s?k=keyboard" }],
    "maxItemsPerStartUrl": 100,
    "proxyCountry": "AUTO_SELECT_PROXY_COUNTRY",
    "maxSearchPagesPerStartUrl": 9999,
    "maxOffers": 0,
    "scrapeSellers": False,
    "ensureLoadedProductDescriptionFields": False,
    "useCaptchaSolver": False,
    "scrapeProductVariantPrices": False,
    "scrapeProductDetails": True,
    "locationDeliverableRoutes": [
        "PRODUCT",
        "SEARCH",
        "OFFERS",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("BG3WDrGdteHgZgbPK").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

Instead, your .env file should look like this:

APIFY_API_TOKEN="apify_api_XXXXXXXXXXXXXXXXXXXXX"

The run_input object defines the configuration supported by the Actor, as well as the input Amazon product page URLs. In the example above, the input is the “keyboard” search results page on Amazon, and the output is limited to 100 products.

For a simpler configuration, you can set up the Actor directly in the Input tab of Apify Console. Then, click the JSON button to see the configuration in JSON format:

Getting the Actor's input configuration in JSON
Getting the Actor's input configuration in JSON

That JSON can easily be converted into a Python run_input object.

Run the Amazon product data scraping script with:

python scraper.py

The execution may take a while, so be patient.

In the terminal, after the execution logs, you should see an output like this:

[
    {
        "title": "Retro Wireless Keyboard with Round Keycaps, 2.4GHz Full-Size USB Cute Wireless Keyboard Mouse for Computer, Desktop, Laptop and Computer (Pink-Colorful)",
        "url": "https://www.amazon.com/dp/B0D7H2FXG5",
        "asin": "B0D7H2FXG5",
        "originalAsin": "B0D7H2FXG5",
        "price": {
            "value": 19.99,
            "currency": "$"
        },
        "inStock": true,
        "inStockText": "In Stock",
        "listPrice": null,
        "brand": "XISOGUU",
        "author": null,
        "shippingPrice": null,
        "stars": 4.2,
        // Omitted for brevity...
    },
    // 98 remaining products...
    {
        "title": "TECKNET Gaming Keyboard, USB Wired Computer Keyboard, 15-Zone RGB Illumination, IP32 Water Resistance, 25 Anti-ghosting Keys, All-Metal Panel (Whisper Quiet Gaming Switch)",
        "url": "https://www.amazon.com/dp/B0D17C3ZVJ",
        "asin": "B0D17C3ZVJ",
        "originalAsin": "B0D17C3ZVJ",
        "price": {
            "value": 29.89,
            "currency": "$"
        },
        "inStock": true,
        "inStockText": "In Stock  Only 2 left in stock - order soon.",
        "listPrice": {
            "value": 39.99,
            "currency": "$"
        },
        "brand": "TECKNET",
        "author": null,
        "shippingPrice": null,
        "stars": 4.4,
        // Omitter for brevity...
    }
]

In detail, the script will return up to 100 Amazon products that match the keyword search. These correspond to the products shown on the search results page on Amazon. The output contains the same product details you see on that page, but in a structured format.

Once the run completes, the dataset is available in your Apify account for 6 days by default. You can find it under the Storage > Datasets section of your account:

The dataset produced by the Actor’s run

You can view the results in tabular format or as raw JSON, and export the dataset to several formats.

Et voilà! Your scraper is ready.

Next steps

This tutorial has walked you through the basics of scraping Amazon product information via Apify API. To take your scraper to the next level, consider these advanced techniques:

Conclusion

This project demonstrated how an always-up-to-date Apify Actor makes it possible to collect data from platforms that are otherwise difficult to scrape due to advanced anti-bot protections and constantly changing page structures - just like Amazon.

Feel free to explore other Actors and Apify SDKs to further expand your automation toolkit.

Frequently asked questions

Why scrape Amazon product data?

Scraping Amazon product data allows you to cover several use cases, from monitoring prices and tracking competitors to analyzing customer reviews and gathering product information at scale. That data supports smarter decision-making, dynamic pricing, market research, and many other scenarios.

Yes, it's legal to scrape Amazon as long as you only extract publicly available data. Also, be responsible by avoiding excessive requests that could overload or throttle their servers.

How to scrape Amazon product data in Python?

To scrape Amazon product data in Python, considering the high variability of product pages, it’s recommended to rely on a dedicated scraping solution. Such a solution is always up to date to handle all edge cases and deal with anti-bot bypasses for you.

On this page

Build the scraper you want

No credit card required

Start building