npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@posty5/amazon-product-scraper

v1.0.0

Published

Scrape Amazon product information — name, price, images, rating, reviews, estimated sales. Optional currency conversion.

Downloads

92

Readme

@posty5/amazon-product-scraper

Scrape Amazon product pages and extract structured product data — name, price, images, rating, reviews, estimated sales. Optional currency conversion with user-provided exchange rates. Built with Axios and Cheerio.

npm version license


🌟 What is @posty5/amazon-product-scraper?

@posty5/amazon-product-scraper is a TypeScript package that scrapes Amazon product pages and returns structured data. It supports:

  1. Single Scrape — Scrape one product URL and get all its data
  2. Batch Scrape — Scrape multiple products with concurrency and delay control
  3. Currency Conversion — Optionally convert prices using your own exchange rate map

Extracted Product Data:

interface Product {
  name?: string;
  description?: string;
  images: string[];
  price?: number;
  currency?: string;
  rating?: number;
  reviews_count?: number;
  estimated_sales?: number;
}

Use Cases:

  • 🛒 Price monitoring and comparison
  • 📊 Market research and product analytics
  • 💰 Multi-currency product catalogs
  • 📈 Sales estimation and trend tracking
  • 🔍 Product data aggregation

📦 Installation

npm install @posty5/amazon-product-scraper

🚀 Quick Start

Scrape a Single Product

import { scrapeProduct } from '@posty5/amazon-product-scraper';

const result = await scrapeProduct({
  url: 'https://www.amazon.com/dp/B0D2Q9317K',
});

if (result.status === 'ok') {
  console.log(result.product);
}

Scrape with Currency Conversion

import { scrapeProduct } from '@posty5/amazon-product-scraper';

const result = await scrapeProduct({
  url: 'https://www.amazon.com/dp/B0D2Q9317K',
  targetCurrency: 'EGP',
  currencyRates: { USD: 1, EGP: 50.5, EUR: 0.92 },
});

// Price is automatically converted from USD → EGP
console.log(result.product?.price);    // 2525 (50 * 50.5)
console.log(result.product?.currency); // "EGP"

Batch Scrape

import { scrapeProducts } from '@posty5/amazon-product-scraper';

const batch = await scrapeProducts({
  urls: [
    'https://www.amazon.com/dp/B0D2Q9317K',
    'https://www.amazon.com/dp/B0BSHF7WHW',
  ],
  concurrency: 1,
  delayMs: 3000,
});

console.log(`${batch.succeeded}/${batch.total} succeeded`);

📚 API Reference

scrapeProduct(config)

Scrape a single Amazon product page.

Returns: Promise<ScrapeResult>

import { scrapeProduct } from '@posty5/amazon-product-scraper';

const result = await scrapeProduct({
  url: 'https://www.amazon.com/dp/B0D2Q9317K',
  locale: 'ar_EG',
  targetCurrency: 'EGP',
  currencyRates: { USD: 1, EGP: 50.5 },
  timeout: 20000,
  maxRetries: 2,
  captchaBackoffMs: 10000,
});

console.log(result);
// {
//   url: 'https://www.amazon.com/dp/B0D2Q9317K',
//   status: 'ok',
//   product: {
//     name: 'Product Name...',
//     description: 'Product description...',
//     images: ['https://...', 'https://...'],
//     price: 2525,
//     currency: 'EGP',
//     rating: 4.5,
//     reviews_count: 1234,
//     estimated_sales: 5000,
//   }
// }

scrapeProducts(config)

Scrape multiple Amazon product pages with concurrency and delay control.

Returns: Promise<ScrapeBatchResult>

import { scrapeProducts } from '@posty5/amazon-product-scraper';

const batch = await scrapeProducts({
  urls: [
    'https://www.amazon.com/dp/B0D2Q9317K',
    'https://www.amazon.com/dp/B0BSHF7WHW',
    'https://www.amazon.de/dp/B0EXAMPLE',
  ],
  locale: 'en_US',
  concurrency: 2,
  delayMs: 3000,
  targetCurrency: 'USD',
  currencyRates: { USD: 1, EUR: 0.92, GBP: 0.79 },
});

console.log(batch);
// {
//   total: 3,
//   succeeded: 2,
//   failed: 1,
//   results: [
//     { url: '...', status: 'ok', product: { ... } },
//     { url: '...', status: 'ok', product: { ... } },
//     { url: '...', status: 'error', error: 'Captcha detected...' },
//   ]
// }

⚙️ Configuration

Scrape Options (ScrapeProductConfig)

Used by scrapeProduct().

| Option | Type | Default | Description | |---|---|---|---| | url | string | (required) | Amazon product URL | | locale | string | 'en_US' | Accept-Language locale (e.g. 'ar_EG', 'de_DE') | | targetCurrency | string | — | Target currency ISO code for price conversion | | currencyRates | CurrencyRates | — | Exchange rate map (required when targetCurrency is set) | | timeout | number | 20000 | Request timeout in milliseconds | | maxRetries | number | 1 | Maximum retries on captcha detection | | captchaBackoffMs | number | 10000 | Backoff in ms before retrying after captcha |

Batch Options (ScrapeProductsConfig)

Used by scrapeProducts(). Includes all options from ScrapeProductConfig (except url) plus:

| Option | Type | Default | Description | |---|---|---|---| | urls | string[] | (required) | Array of Amazon product URLs | | concurrency | number | 1 | Number of products to scrape in parallel | | delayMs | number | 3000 | Delay in ms between batches |


💱 Currency Conversion

Currency conversion is optional and fully controlled by you. The package never makes external API calls for exchange rates — you provide the rates yourself.

How It Works

  1. The scraper detects the currency from the product page (symbols, codes, URL domain)
  2. If you provide targetCurrency + currencyRates, the price is converted automatically
  3. If you don't provide them, the price is returned in the original currency

Providing Exchange Rates

// All rates relative to the same base (e.g. USD = 1)
const rates = {
  USD: 1,
  EUR: 0.92,
  GBP: 0.79,
  EGP: 50.5,
  SAR: 3.75,
  AED: 3.67,
  JPY: 149.5,
  INR: 83.1,
};

const result = await scrapeProduct({
  url: 'https://www.amazon.de/dp/B0EXAMPLE',  // Price in EUR
  targetCurrency: 'USD',
  currencyRates: rates,
});
// Price is converted: EUR → USD

Supported Currencies

The following currencies are auto-detected from Amazon product pages:

| Region | Currencies | |---|---| | Americas | USD, CAD, BRL, MXN | | Europe | EUR, GBP, SEK, NOK, DKK, CHF, PLN, CZK, HUF, RON, TRY | | Middle East | SAR, EGP, AED, QAR, KWD, BHD, OMR, JOD, ILS | | Asia Pacific | JPY, INR, KRW, CNY, TWD, HKD, SGD, AUD, NZD, PKR, PHP, THB, MYR, IDR, VND | | Africa | ZAR |


🔧 Advanced Usage

Utility Functions

The package also exports individual utility functions for advanced use:

import {
  detectCurrency,    // Detect currency from price text + URL
  convertPrice,      // Convert between currencies using a rate map
  parseProduct,      // Parse cheerio-loaded HTML
  isCaptchaPage,     // Check if HTML is a captcha page
  buildAcceptLanguage, // Build Accept-Language header from locale
} from '@posty5/amazon-product-scraper';

Detect Currency Manually

import { detectCurrency } from '@posty5/amazon-product-scraper';

detectCurrency('$49.99', 'https://www.amazon.com/dp/...');   // 'USD'
detectCurrency('€49.99');                                     // 'EUR'
detectCurrency('EGP 500');                                    // 'EGP'
detectCurrency('A$79.99');                                    // 'AUD'
detectCurrency('$49.99', 'https://www.amazon.ca/dp/...');    // 'CAD'

Convert Price Manually

import { convertPrice } from '@posty5/amazon-product-scraper';

const rates = { USD: 1, EUR: 0.92, EGP: 50.5 };

convertPrice(100, 'USD', 'EGP', rates);  // 5050
convertPrice(92,  'EUR', 'USD', rates);  // 100

Using with Different Amazon Domains

The scraper works with any Amazon domain. Use the locale option for proper language headers:

// Amazon US (English)
await scrapeProduct({ url: 'https://www.amazon.com/dp/B0EXAMPLE' });

// Amazon Germany (German)
await scrapeProduct({ url: 'https://www.amazon.de/dp/B0EXAMPLE', locale: 'de_DE' });

// Amazon Japan (Japanese)
await scrapeProduct({ url: 'https://www.amazon.co.jp/dp/B0EXAMPLE', locale: 'ja_JP' });

// Amazon Egypt (Arabic)
await scrapeProduct({ url: 'https://www.amazon.eg/dp/B0EXAMPLE', locale: 'ar_EG' });

// Amazon Saudi Arabia (Arabic)
await scrapeProduct({ url: 'https://www.amazon.sa/dp/B0EXAMPLE', locale: 'ar_SA' });

📂 Project Structure

src/
├── index.ts              # Public API — exports functions + types
├── test-app.ts           # Runnable test app
├── config/
│   ├── types.ts          # All TypeScript interfaces
│   ├── resolve.ts        # Default filling & validation
│   └── index.ts          # Barrel export
├── scraper/
│   ├── http.ts           # User-agent rotation, axios fetch, retry
│   ├── parser.ts         # Cheerio HTML → Product extraction
│   ├── captcha.ts        # Bot-page detection
│   └── index.ts          # Barrel export
└── currency/
    ├── detect.ts         # Price text → ISO currency code
    ├── convert.ts        # Pure currency conversion
    └── index.ts          # Barrel export

🧪 Test App

A built-in test app demonstrates all features:

npm run test-app

The test app runs three scenarios:

  1. Scrape a single product (no currency conversion)
  2. Scrape a single product with USD → EGP conversion
  3. Batch scrape multiple products

💻 Requirements

  • Node.js: >= 18.0.0
  • TypeScript: Full type definitions included
  • Dependencies: axios, cheerio

📖 Resources


🆘 Support


🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Submit a pull request

📄 License

MIT License - see LICENSE file for details.


Made with ❤️ by the Posty5 team