[
  {
    "path": ".gitignore",
    "content": "\n\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\n*.egg-info/\n.installed.cfg\n*.egg\nMANIFEST\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n.hypothesis/\n.pytest_cache/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\nlocal_settings.py\ndb.sqlite3\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Botasaurus stuff:\nbuild/\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# pyenv\n.python-version\n\n# celery beat schedule file\ncelerybeat-schedule\n\n# SageMath parsed files\n*.sage.py\n\n# Environments\n.env\n.venv\nenv/\nvenv/\nENV/\nenv.bak/\nvenv.bak/\n\n# Spyder project settings\n.spyderproject\n.spyproject\n\n# Rope project settings\n.ropeproject\n\n# mkdocs documentation\n/site\n\n# mypy\n.mypy_cache/\n\ntasks/\n\nprofiles/\n\noutput/\n\n\ncreate_cache.py\n\nerror_logs/\n\ngpt/\n.history/\n"
  },
  {
    "path": ".gitpod.yml",
    "content": "image: chetan1111/gitpod-botasaurus:3\n\ntasks:\n  - init: pip install -r requirements.txt"
  },
  {
    "path": "Dockerfile",
    "content": "FROM chetan1111/botasaurus:latest\n\nENV PYTHONUNBUFFERED=1\n\nCOPY requirements.txt .\n\nRUN python -m pip install  -r requirements.txt\n\nRUN mkdir app\nWORKDIR /app\nCOPY . /app\n\nCMD [\"python\", \"main.py\"]"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2023 Chetan Jain\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "![Amazon Scraper Featured Image](https://raw.githubusercontent.com/omkarcloud/amazon-scraper/master/amazon-scraper-featured-image.png)\n\n# Amazon Scraper API\n\nScrape Amazon products, prices, reviews, and categories from 24 marketplaces via a simple REST API. 100 free requests/month.\n\n## Key Features\n\n- Search Amazon products, get product details, browse by category, and fetch top reviews — all via 1 API.\n- 100 free queries per month. No credit card required.\n\nHere's a sample response for a **product search results page**:\n```json\n{\n  \"title\": \"Apple iPhone 15, 128GB, Black - Unlocked (Renewed)\",\n  \"price\": 403.0,\n  \"rating\": 4.1,\n  \"reviews\": 2769,\n  \"asin\": \"B0CMPMY9ZZ\",\n  \"link\": \"https://www.amazon.com/dp/B0CMPMY9ZZ\",\n  \"image_url\": \"https://m.media-amazon.com/images/I/51PtFHUPjBL._AC_UY654_FMwebp_QL65_.jpg\",\n  \"currency\": \"USD\",\n  \"is_best_seller\": false,\n  \"is_amazon_choice\": false,\n  \"is_prime\": false,\n  \"sales_volume\": \"2K+ bought in past month\"\n}\n```\n\n## Get API Key\n\nCreate an account at [omkar.cloud](https://www.omkar.cloud/auth/sign-up?redirect=/api-key) to get your API key.\n\nIt takes just 2 minutes to sign up. You get 100 free requests every month for detailed Amazon data.\n\nThis is a well built product, and your search for the best Amazon Scraper API ends right here. \n\n\n## Quick Start\n\n```bash\ncurl -X GET \"https://amazon-scraper-api.omkar.cloud/amazon/search?query=iPhone%2016\" \\\n  -H \"API-Key: YOUR_API_KEY\"\n```\n\n```json\n{\n  \"results\": [\n    {\n      \"title\": \"Apple iPhone 15, 128GB, Black - Unlocked (Renewed)\",\n      \"price\": 403.0,\n      \"rating\": 4.1,\n      \"reviews\": 2769,\n      \"asin\": \"B0CMPMY9ZZ\",\n      \"link\": \"https://www.amazon.com/dp/B0CMPMY9ZZ\",\n      \"currency\": \"USD\",\n      \"is_best_seller\": false,\n      \"is_amazon_choice\": false,\n      \"is_prime\": false,\n      \"sales_volume\": \"2K+ bought in past month\"\n    }\n  ]\n}\n```\n\n## Quick Start (Python)\n\n```bash\npip install requests\n```\n\n```python\nimport requests\n\n# Search for products\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/search\",\n    params={\"query\": \"iPhone 16\", \"country_code\": \"US\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nprint(response.json())\n```\n\n\n## API Reference\n\n### Product Search\n\n```\nGET https://amazon-scraper-api.omkar.cloud/amazon/search\n```\n\n#### Parameters\n\n| Parameter | Required | Default | Description |\n|-----------|----------|---------|-------------|\n| `query` | Yes | — | Search query. Keywords or ASIN. |\n| `page` | No | `1` | Page number. |\n| `country_code` | No | `US` | Amazon marketplace code. |\n| `sort_by` | No | `relevance` | `relevance`, `lowest_price`, `highest_price`, `reviews`, `newest`, `best_sellers` |\n\n#### Example\n\n```python\nimport requests\n\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/search\",\n    params={\"query\": \"iPhone 16\", \"country_code\": \"US\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nprint(response.json())\n```\n\n#### Response\n\n<details>\n<summary>Sample Response (click to expand)</summary>\n\n```json\n{\n  \"results\": [\n    {\n      \"title\": \"Apple iPhone 15, 128GB, Black - Unlocked (Renewed)\",\n      \"price\": 403.0,\n      \"original_price\": null,\n      \"rating\": 4.1,\n      \"reviews\": 2769,\n      \"asin\": \"B0CMPMY9ZZ\",\n      \"link\": \"https://www.amazon.com/dp/B0CMPMY9ZZ\",\n      \"image_url\": \"https://m.media-amazon.com/images/I/51PtFHUPjBL._AC_UY654_FMwebp_QL65_.jpg\",\n      \"currency\": \"USD\",\n      \"is_best_seller\": false,\n      \"is_amazon_choice\": false,\n      \"is_prime\": false,\n      \"delivery_info\": \"FREE delivery Fri, Feb 13\",\n      \"number_of_offers\": 62,\n      \"lowest_offer_price\": 359.99,\n      \"has_variations\": true,\n      \"sales_volume\": \"2K+ bought in past month\",\n      \"is_climate_friendly\": false\n    }\n  ]\n}\n```\n\n</details>\n\n---\n\n### Products by Category\n\n```\nGET https://amazon-scraper-api.omkar.cloud/amazon/products/category\n```\n\n#### Parameters\n\n| Parameter | Required | Default | Description |\n|-----------|----------|---------|-------------|\n| `category_id` | Yes | — | Amazon category ID (from URL `node=` param). |\n| `page` | No | `1` | Page number. |\n| `country_code` | No | `US` | Amazon marketplace code. |\n| `sort_by` | No | `relevance` | `relevance`, `lowest_price`, `highest_price`, `reviews`, `newest`, `best_sellers` |\n\n#### Example\n\n```python\nimport requests\n\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/products/category\",\n    params={\"category_id\": \"16225007011\", \"country_code\": \"US\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nprint(response.json())\n```\n\n#### Response\n\n<details>\n<summary>Sample Response (click to expand)</summary>\n\n```json\n{\n  \"results\": [\n    {\n      \"title\": \"Apple iPhone 15, 128GB, Black - Unlocked (Renewed)\",\n      \"price\": 403.0,\n      \"original_price\": null,\n      \"rating\": 4.1,\n      \"reviews\": 2769,\n      \"asin\": \"B0CMPMY9ZZ\",\n      \"link\": \"https://www.amazon.com/dp/B0CMPMY9ZZ\",\n      \"image_url\": \"https://m.media-amazon.com/images/I/51PtFHUPjBL._AC_UY654_FMwebp_QL65_.jpg\",\n      \"currency\": \"USD\",\n      \"is_best_seller\": false,\n      \"is_amazon_choice\": false,\n      \"is_prime\": false,\n      \"delivery_info\": \"FREE delivery Fri, Feb 13\",\n      \"number_of_offers\": 62,\n      \"lowest_offer_price\": 359.99,\n      \"has_variations\": true,\n      \"sales_volume\": \"2K+ bought in past month\",\n      \"is_climate_friendly\": false\n    }\n  ]\n}\n```\n\n</details>\n\n---\n\n### Product Details\n\n```\nGET https://amazon-scraper-api.omkar.cloud/amazon/product-details\n```\n\n#### Parameters\n\n| Parameter | Required | Default | Description |\n|-----------|----------|---------|-------------|\n| `asin` | Yes | — | Amazon ASIN (e.g., `B0FWD726XF`). Also accepts product URLs. |\n| `country_code` | No | `US` | Amazon marketplace code. |\n\n#### Example\n\n```python\nimport requests\n\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/product-details\",\n    params={\"asin\": \"B0FWD726XF\", \"country_code\": \"US\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nprint(response.json())\n```\n\n#### Response Fields\n\nReturns 50+ fields including price, rating, description, key features, technical specs, all images/videos, rating distribution, product variants, category hierarchy, brand info, frequently bought together, and top reviews.\n\n<details>\n<summary>Sample Response (click to expand)</summary>\n\n```json\n\n{\n  \"asin\": \"B0FWD726XF\",\n  \"product_name\": \"Apple 2025 MacBook Pro Laptop with M5 chip with 10‑core CPU and GPU: Built for Apple Intelligence, 14.2-inch Liquid Retina XDR Display, 24GB Unified Memory, 1TB SSD Storage, Space Black\",\n  \"link\": \"https://www.amazon.com/dp/B0FWD726XF\",\n  \"slug\": \"Apple-2025-MacBook-Laptop-10%E2%80%91core\",\n  \"parent_asin\": \"B0DLRGKGTV\",\n  \"landing_asin\": \"B0FWD726XF\",\n  \"brand_info\": \"Visit the Apple Store\",\n  \"brand_url\": \"https://www.amazon.com/stores/Apple/page/77D9E1F7-0337-4282-9DB6-B6B8FB2DC98D?lp_asin=B0FWD726XF&ref_=ast_bln\",\n  \"brand_urls\": [\n    \"https://www.amazon.com/stores/Apple/page/77D9E1F7-0337-4282-9DB6-B6B8FB2DC98D?lp_asin=B0FWD726XF&ref_=ast_bln\"\n  ],\n  \"current_price\": 1849.0,\n  \"original_price\": 1999.0,\n  \"unit_price\": null,\n  \"unit_count\": null,\n  \"currency\": \"USD\",\n  \"min_order_quantity\": null,\n  \"country\": \"US\",\n  \"availability\": \"In Stock\",\n  \"condition\": \"Buy new:\",\n  \"number_of_offers\": 6,\n  \"delivery_info\": \"FREE delivery Monday, February 16 Or Prime members get FREE delivery Tomorrow, February 12. Join Prime\",\n  \"estimated_delivery_date\": \"Monday, February 16\",\n  \"rating\": 4.7,\n  \"reviews\": 1167,\n  \"detailed_rating\": {\n    \"1\": 3,\n    \"2\": 0,\n    \"3\": 3,\n    \"4\": 5,\n    \"5\": 89\n  },\n  \"customer_feedback_summary\": null,\n  \"top_reviews\": [\n    {\n      \"review_id\": \"R1H9MVROAP2XKG\",\n      \"product_asin\": \"B0FWD726XF\",\n      \"review_title\": \"Sleek, powerful, and a photographers dream. 11/10\",\n      \"review_text\": \"Okay so I actually had to return this item with amazon because they messed up delivery...\",\n      \"review_link\": \"https://www.amazon.com/gp/customer-reviews/R1H9MVROAP2XKG\",\n      \"rating\": 5,\n      \"review_date\": \"Reviewed in the United States on December 1, 2025\",\n      \"is_verified_purchase\": true,\n      \"helpful_votes\": 32,\n      \"reviewer_name\": \"Catherine Mason\",\n      \"reviewer_id\": \"AF77JTSDDJJG6FXTYJAQOG4B4QFA\",\n      \"reviewer_url\": \"https://www.amazon.com/gp/profile/amzn1.account.AF77JTSDDJJG6FXTYJAQOG4B4QFA\",\n      \"reviewer_avatar\": \"https://m.media-amazon.com/images/S/amazon-avatars-global/default.png\",\n      \"review_images\": [],\n      \"review_video\": null,\n      \"reviewed_variant\": {\n        \"Style\": \"Apple M5 chip\",\n        \"Capacity\": \"16GB Unified Memory, 512GB SSD Storage\",\n        \"Color\": \"Space Black\",\n        \"Set\": \"Without AppleCare+\"\n      },\n      \"is_vine_review\": false\n    },\n    ...\n  ],\n  \"is_bestseller\": false,\n  \"is_amazon_choice\": true,\n  \"is_prime\": true,\n  \"is_climate_friendly\": true,\n  \"sales_volume\": \"1K+ bought in past month\",\n  \"main_image_url\": \"https://m.media-amazon.com/images/I/6112T6g2P-L._AC_SL1500_.jpg\",\n  \"additional_image_urls\": [\n    \"https://m.media-amazon.com/images/I/6112T6g2P-L._AC_SL1500_.jpg\",\n    \"https://m.media-amazon.com/images/I/61SBJYmPyFL._AC_SL1500_.jpg\",\n    \"https://m.media-amazon.com/images/I/81uUolI6viL._AC_SL1500_.jpg\",\n    \"https://m.media-amazon.com/images/I/616eNe+uHRL._AC_.jpg\",\n    \"https://m.media-amazon.com/images/I/81cfIW5+p7L._AC_SL1500_.jpg\",\n    \"https://m.media-amazon.com/images/I/71c2cMlWe5L._AC_SL1500_.jpg\",\n    \"https://m.media-amazon.com/images/I/61EQmd9L4kL._AC_SL1500_.jpg\"\n  ],\n  \"product_videos\": [\n    {\n      \"id\": \"amzn1.vse.video.0882c1076e654eab890412db954d0944\",\n      \"title\": \"MacBook Pro M5 Chip\",\n      \"url\": \"https://m.media-amazon.com/images/S/vse-vms-transcoding-artifact-us-east-1-prod/a60f6616-cd5d-4a84-a49a-b0ca7c22effb/default.jobtemplate.hls.m3u8\",\n      \"height\": 1080,\n      \"width\": 1920,\n      \"thumbnail\": \"https://m.media-amazon.com/images/I/9103IPwwY2L._SX35_SY46._CR0,0,35,46_BG85,85,85_BR-120_PKdp-play-icon-overlay__.png\",\n      \"product_id\": \"B0FWD726XF\",\n      \"parent_id\": \"B0DLRGKGTV\"\n    },\n    {\n      \"id\": \"amzn1.vse.video.007d9729d15a4dc7b533d61249583a76\",\n      \"title\": \"AppleCare+ for Mac\",\n      \"url\": \"https://m.media-amazon.com/images/S/vse-vms-transcoding-artifact-us-east-1-prod/3f731513-0ce4-4f42-ba76-e97deb21bcc7/default.jobtemplate.hls.m3u8\",\n      \"height\": 1080,\n      \"width\": 1920,\n      \"thumbnail\": \"https://m.media-amazon.com/images/I/71N+KnY1REL._SX35_SY46._CR0,0,35,46_BG85,85,85_BR-120_PKdp-play-icon-overlay__.png\",\n      \"product_id\": \"B0FWD726XF\",\n      \"parent_id\": \"B0DLRGKGTV\"\n    }\n  ],\n  \"user_videos\": [],\n  \"video_thumbnail\": \"https://m.media-amazon.com/images/I/9103IPwwY2L.SX522_.png\",\n  \"has_video\": true,\n  \"key_features\": [\n    \"SUPERCHARGED BY M5 — The 14-inch MacBook Pro with M5 brings next-generation speed and powerful on-device AI to personal, professional, and creative tasks. Featuring all-day battery life and a breathtaking Liquid Retina XDR display with up to 1600 nits peak brightness, it's pro in every way.*\",\n    \"HAPPILY EVER FASTER — Along with its faster CPU and unified memory, M5 features a more powerful GPU with a Neural Accelerator built into each core, delivering faster AI performance. So you can blaze through demanding workloads at mind-bending speeds.\",\n    \"BUILT FOR APPLE INTELLIGENCE — Apple Intelligence is the personal intelligence system that helps you write, express yourself, and get things done effortlessly. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*\",\n    \"ALL-DAY BATTERY LIFE — MacBook Pro delivers the same exceptional performance whether it's running on battery or plugged in.\",\n    \"APPS FLY WITH APPLE SILICON — All your favorites, including Microsoft 365 and Adobe Creative Cloud, run lightning fast in macOS.*\",\n    \"IF YOU LOVE IPHONE, YOU'LL LOVE MAC — Mac works like magic with your other Apple devices. View and control what's on your iPhone from your Mac with iPhone Mirroring.* Copy something on iPhone and paste it on Mac. Send texts with Messages or use your Mac to make and answer FaceTime calls.*\",\n    \"BRILLIANT PRO DISPLAY — The 14.2-inch Liquid Retina XDR display features 1600 nits peak brightness, up to 1000 nits sustained brightness, and 1,000,000:1 contrast.*\",\n    \"ADVANCED CAMERA AND AUDIO — Stay perfectly framed and sound great with a 12MP Center Stage camera, three studio-quality mics, and six speakers with Spatial Audio and support for Dolby Atmos.\",\n    \"CONNECT IT ALL — This MacBook Pro features three Thunderbolt 4 ports and a MagSafe 3 charging port, SDXC card slot, HDMI port, and headphone jack. And it supports up to two external displays.\",\n    \"* LEGAL DISCLAIMERS — This is a summary of the main product features. See below to learn more.\"\n  ],\n  \"full_description\": null,\n  \"technical_details\": {\n    \"Product Dimensions\": \"12.31 x 8.71 x 0.61 inches\",\n    \"Item Weight\": \"3.41 pounds\",\n    \"Manufacturer\": \"Apple\",\n    \"ASIN\": \"B0FWD726XF\",\n    \"Item model number\": \"MDE34LL/A\",\n    \"Batteries\": \"1 Lithium Ion batteries required. (included)\",\n    \"Date First Available\": \"October 14, 2025\"\n  },\n  \"product_details\": {\n    \"Brand\": \"Apple\",\n    \"Model Name\": \"MacBook Pro\",\n    \"Screen Size\": \"14.2 Inches\",\n    \"Color\": \"Space Black\",\n    \"Hard Disk Size\": \"1 TB\",\n    \"CPU Model\": \"Unknown\",\n    \"Ram Memory Installed Size\": \"24 GB\",\n    \"Operating System\": \"Mac OS\",\n    \"Special Feature\": \"Backlit Keyboard, Fingerprint Reader\",\n    \"Graphics Card Description\": \"Integrated\"\n  },\n  \"main_category\": {\n    \"id\": \"aps\",\n    \"name\": \"All Departments\"\n  },\n  \"category_hierarchy\": [],\n  \"variation_dimensions\": [\n    \"style\",\n    \"size\",\n    \"color\",\n    \"configuration\"\n  ],\n  \"variants\": {\n    \"style\": [\n      {\n        \"asin\": \"B0FWD726XF\",\n        \"value\": \"Apple M5 chip\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0DLHBGBW3\",\n        \"value\": \"Apple M4 Pro chip\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0DLHCXF81\",\n        \"value\": \"Apple M4 Max chip\",\n        \"is_available\": false\n      }\n    ],\n    \"size\": [\n      {\n        \"asin\": \"B0FWD623D1\",\n        \"value\": \"16GB Unified Memory, 1TB SSD Storage\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0FWD6SKL6\",\n        \"value\": \"16GB Unified Memory, 512GB SSD Storage\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0FWD726XF\",\n        \"value\": \"24GB Unified Memory, 1TB SSD Storage\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0DLHY2BJ6\",\n        \"value\": \"24GB Unified Memory, 512GB SSD Storage\",\n        \"is_available\": false\n      },\n      {\n        \"asin\": \"B0DLHCXF81\",\n        \"value\": \"36GB Unified Memory, 1TB SSD Storage\",\n        \"is_available\": false\n      }\n    ],\n    \"color\": [\n      {\n        \"asin\": \"B0FWD726XF\",\n        \"value\": \"Space Black\",\n        \"photo\": \"https://m.media-amazon.com/images/I/01B-RyYQGML.jpg\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0FWD7QF6M\",\n        \"value\": \"Silver\",\n        \"photo\": \"https://m.media-amazon.com/images/I/01xh++YLubL.jpg\",\n        \"is_available\": true\n      }\n    ],\n    \"configuration\": [\n      {\n        \"asin\": \"B0FWD726XF\",\n        \"value\": \"Without AppleCare+\",\n        \"is_available\": true\n      },\n      {\n        \"asin\": \"B0FWLNSJ1M\",\n        \"value\": \"With AppleCare+ (3 Years)\",\n        \"is_available\": true\n      }\n    ]\n  },\n  \"all_variants\": {\n    \"B0FWLNSJ1M\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0FWD5MR3L\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0DLHDJH98\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWKR7V14\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0DM6YG983\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0FWKTY1NM\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0DM6ZP92H\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0DLHBGBW3\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0DLHY2BJ6\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWD6SKL6\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWKWYYKS\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0FWD623D1\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWD7QF6M\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWKT6VRG\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0DLHGN9P2\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWKV16DL\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    },\n    \"B0FWD726XF\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"24GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0FWD8WBSW\": {\n      \"style\": \"Apple M5 chip\",\n      \"size\": \"16GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0DLHCXF81\": {\n      \"style\": \"Apple M4 Max chip\",\n      \"size\": \"36GB Unified Memory, 1TB SSD Storage\",\n      \"color\": \"Space Black\",\n      \"configuration\": \"Without AppleCare+\"\n    },\n    \"B0DM733GXY\": {\n      \"style\": \"Apple M4 Pro chip\",\n      \"size\": \"24GB Unified Memory, 512GB SSD Storage\",\n      \"color\": \"Silver\",\n      \"configuration\": \"With AppleCare+ (3 Years)\"\n    }\n  },\n  \"has_aplus_content\": false,\n  \"aplus_images\": [],\n  \"has_brand_story\": false,\n  \"frequently_bought_together\": []\n}\n```\n\n</details>\n\n---\n\n### Top Product Reviews\n\n```\nGET https://amazon-scraper-api.omkar.cloud/amazon/product-reviews/top\n```\n\n#### Parameters\n\n| Parameter | Required | Default | Description |\n|-----------|----------|---------|-------------|\n| `asin` | Yes | — | Amazon ASIN. |\n| `country_code` | No | `US` | Amazon marketplace code. |\n\n#### Example\n\n```python\nimport requests\n\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/product-reviews/top\",\n    params={\"asin\": \"B0FWD726XF\", \"country_code\": \"US\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nprint(response.json())\n```\n\n#### Response\n\n<details>\n<summary>Sample Response (click to expand)</summary>\n\n```json\n{\n  \"results\": [\n    {\n      \"review_id\": \"R1H9MVROAP2XKG\",\n      \"product_asin\": \"B0FWD726XF\",\n      \"review_title\": \"Sleek, powerful, and a photographers dream. 11/10\",\n      \"review_text\": \"The battery life is good for how powerful it is. Overall super happy with this laptop. Would buy again every time.\",\n      \"review_link\": \"https://www.amazon.com/gp/customer-reviews/R1H9MVROAP2XKG\",\n      \"rating\": 5,\n      \"review_date\": \"Reviewed in the United States on December 1, 2025\",\n      \"is_verified_purchase\": true,\n      \"helpful_votes\": 32,\n      \"reviewer_name\": \"Catherine Mason\",\n      \"reviewer_id\": \"AF77JTSDDJJG6FXTYJAQOG4B4QFA\",\n      \"reviewer_url\": \"https://www.amazon.com/gp/profile/amzn1.account.AF77JTSDDJJG6FXTYJAQOG4B4QFA\",\n      \"reviewer_avatar\": \"https://m.media-amazon.com/images/S/amazon-avatars-global/default.png\",\n      \"review_images\": [],\n      \"review_video\": null,\n      \"reviewed_variant\": {\n        \"Style\": \"Apple M5 chip\",\n        \"Capacity\": \"16GB Unified Memory, 512GB SSD Storage\",\n        \"Color\": \"Space Black\",\n        \"Set\": \"Without AppleCare+\"\n      },\n      \"is_vine_review\": false\n    }\n  ]\n}\n```\n\n</details>\n\n### Supported Amazon Marketplaces\n\n`US`, `AU`, `BR`, `CA`, `CN`, `FR`, `DE`, `IN`, `IT`, `MX`, `NL`, `SG`, `ES`, `TR`, `AE`, `GB`, `JP`, `SA`, `PL`, `SE`, `BE`, `EG`, `ZA`, `IE`\n\n## Error Handling\n\n```python\nresponse = requests.get(\n    \"https://amazon-scraper-api.omkar.cloud/amazon/search\",\n    params={\"query\": \"iPhone 16\"},\n    headers={\"API-Key\": \"YOUR_API_KEY\"}\n)\n\nif response.status_code == 200:\n    data = response.json()\nelif response.status_code == 401:\n    # Invalid API key\n    pass\nelif response.status_code == 429:\n    # Rate limit exceeded\n    pass\n```\n\n## FAQs\n\n### What data does the API return?\n\n**Product Search** returns per product:\n- Title, price, original price, currency\n- Star rating, review count, sales volume\n- ASIN, product URL, image URL\n- Best Seller, Amazon's Choice, and Prime badges\n- Delivery info, number of offers, lowest offer price\n\n**Product Details** returns 50+ fields including:\n- Full description, key features, technical specs\n- All product images and videos\n- Rating distribution breakdown\n- Product variations (size, color, etc.)\n- Category hierarchy, brand info\n- Frequently bought together items\n- Customer feedback summary and top reviews\n\n**Top Reviews** returns per review:\n- Review title, text, rating, and date\n- Verified purchase status, helpful vote count\n- Reviewer name, avatar, and profile link\n- Review images and videos\n\n\nAll in structured JSON. Ready to use in your app.\n\n### How accurate is the data?\n\nData is pulled from Amazon in real time. Every API call fetches live data — not cached or stale results. Prices, availability, ratings, and reviews reflect what's on Amazon right now.\n\n### What's the difference between Product Search and Products by Category?\n\n**Product Search** finds products matching a keyword or ASIN — like typing into the Amazon search bar.\n\n**Products by Category** returns all products within a specific Amazon category (e.g., \"Electronics\" or \"Books > Science Fiction\"). Pass a `category_id` from the Amazon URL, get a paginated list of every product in that category.\n\nUse Search when you know what you're looking for. Use Category when you want to explore or monitor an entire product segment.\n\n## Rate Limits\n\n| Plan | Price | Requests/Month |\n|------|-------|----------------|\n| Free | $0 | 100 |\n| Starter | $16 | 15,000 |\n| Grow | $48 | 75,000 |\n| Scale | $148 | 300,000 |\n\n## Questions? We have answers.\n\nReach out anytime. We will solve your query within 1 working day.\n\n[![Contact Us on WhatsApp about Amazon Scraper](https://raw.githubusercontent.com/omkarcloud/assets/master/images/whatsapp-us.png)](https://api.whatsapp.com/send?phone=918178804274&text=I%20have%20a%20question%20about%20the%20Amazon%20Scraper%20API.)\n\n[![Contact Us on Email about Amazon Scraper](https://raw.githubusercontent.com/omkarcloud/assets/master/images/ask-on-email.png)](mailto:happy.to.help@omkar.cloud?subject=Amazon%20Scraper%20API%20Question)\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Security Policy for the Amazon Scraper Project\n\n## Disclaimer\n\nBy using Amazon Scraper, you agree to comply with all applicable local and international laws related to data scraping, copyright, and privacy. The developers of Amazon Scraper will not be held liable for any misuse of this software. It is the user's sole responsibility to ensure adherence to all relevant laws regarding data scraping, copyright, and privacy, and to use Amazon Scraper in an ethical and legal manner, in line with both local and international regulations.\n\n## 1. Reporting a Vulnerability\n\nWe take the privacy and security of the Amazon Scraper Project very seriously. If you have discovered a security vulnerability or have concerns about the project, we appreciate your assistance in responsibly disclosing it to us.\n\nTo report a security issue or express a concern, please email Chetan Jain at [chetan@omkar.cloud](mailto:chetan@omkar.cloud). We will promptly respond to your concerns.\n\n## 2. Use at Your Own Risk\n\nThis project is provided for ethical and legal purposes only. It must be used in compliance with all relevant local and international laws and is not intended for unauthorized or illegal use.\n\n## 3. Contact\n\nFor questions regarding this security policy or the security of the Amazon Scraper Project, please contact [chetan@omkar.cloud](mailto:chetan@omkar.cloud).\n\nThe information in this `SECURITY.md` is provided \"as is,\" without any kind of warranty."
  },
  {
    "path": "advanced.md",
    "content": "## 🤔 Advanced Questions\n\n### ❓ I don't have Python installed. How can I run the scraper?\n\nYou can easily run the scraper in Gitpod, a browser-based development environment. Set it up in just 5 minutes by following these steps:\n\n1. Visit [this link](https://gitpod.io/#https://github.com/omkarcloud/amazon-scraper) and sign up using your GitHub account.\n   \n   ![Gitpod Amazon Scraper Sign Up](https://raw.githubusercontent.com/omkarcloud/assets/master/images/open-in-gitpod.png)\n  \n2. Once signed up, open it in Gitpod.   \n\n   ![Gitpod Amazon Scraper Continue](https://raw.githubusercontent.com/omkarcloud/assets/master/images/gitpod-continue.png)\n\n3. In the terminal, run the following command to start scraping:\n   ```bash\n   python main.py\n   ```\n  \n4. Once the scraper has finished running, download the data from the `output` folder.\n   ![Data Amazon Scraper Download](https://raw.githubusercontent.com/omkarcloud/assets/master/images/download-data.png)\n\n### ❓ Need More Help or Have Additional Questions?\n\nFor further help, contact us on WhatsApp. We'll be happy to help you out.\n\n[![Contact Us on WhatsApp about Amazon Scraper](https://raw.githubusercontent.com/omkarcloud/assets/master/images/whatsapp-us.png)](https://api.whatsapp.com/send?phone=918295042963&text=Hi,%20I%20would%20like%20to%20learn%20more%20about%20your%20products.)\n\n## Love It? [Star It! ⭐](https://github.com/omkarcloud/amazon-scraper/stargazers)\n\n## Made with ❤️ using [Botasaurus Web Scraping Framework](https://github.com/omkarcloud/botasaurus)"
  },
  {
    "path": "cache/get_product/a77e2b6d09fe1229ea74e803a284d424.json",
    "content": "{\n    \"data\": {\n        \"title\": \"Late 2019 Apple MacBook Pro with 2.6GHz Intel Core i7 (16-Inch, 16GB RAM, 512GB Storage) - Silver (Renewed)\",\n        \"description\": \"Late 2019 Apple MacBook Pro with 2.6GHz Intel Core i7 (16-Inch, 16GB RAM, 512GB Storage) - Silver (Renewed)\",\n        \"price\": 875.0,\n        \"seller\": \"JemJem\",\n        \"features\": [\n            \"Ninth-generation 6-Core Intel Core i7 Processor\",\n            \"Stunning 16-inch Retina Display with True Tone technology\",\n            \"Touch Bar and Touch ID\",\n            \"Amd Radeon Pro 5300M Graphics with GDDR6 memory\",\n            \"Ultrafast SSD\",\n            \"Intel UHD Graphics 630\",\n            \"Six-speaker system with force-cancelling woofers\",\n            \"Four Thunderbolt 3 (USB-C) ports\",\n            \"Up to 11 hours of battery life\",\n            \"802.11AC Wi-Fi\"\n        ],\n        \"rating\": 4.3,\n        \"reviews\": 111,\n        \"images\": [\n            \"https://m.media-amazon.com/images/I/619L9jf3-rL._AC_SL1500_.jpg\",\n            \"https://m.media-amazon.com/images/I/71u7ZoxwLkL._AC_SL1500_.jpg\",\n            \"https://m.media-amazon.com/images/I/919EXGgh2aL._AC_SL1500_.jpg\",\n            \"https://m.media-amazon.com/images/I/91yAgiEZqjL._AC_SL1500_.jpg\",\n            \"https://m.media-amazon.com/images/I/71XSEMx26HL._AC_SL1500_.jpg\",\n            \"https://m.media-amazon.com/images/I/51k92mFqIcL._AC_SL1500_.jpg\"\n        ],\n        \"alternatives\": [],\n        \"delivery_status\": \"FREE delivery Thursday, January 4. \",\n        \"questions_answered_count\": 21,\n        \"videos_count\": 0\n    },\n    \"error\": null\n}"
  },
  {
    "path": "cache/search/97e2eb5cf27ecd24880993346e62705b.json",
    "content": "{\n    \"data\": {\n        \"count\": 18,\n        \"results\": [\n            {\n                \"title\": \"2020 MacBook Air Laptop M1 Chip, 13\\u201d Retina Display, 8GB RAM, 256GB SSD Storage, Backlit Keyboard, FaceTime HD Camera, Touch ID. Works with iPhone/iPad; Gold\",\n                \"link\": \"https://www.amazon.com/gp/bestsellers/pc/13896615011/ref=sr_bs_0_13896615011_1\",\n                \"currency\": \"$\",\n                \"price\": 949,\n                \"rating\": 4,\n                \"reviews\": 19039,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/71vFKBpKakL._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": true,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2023 MacBook Air Laptop with M2 chip: 15.3-inch Liquid Retina Display, 16GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera, Touch ID. Works with iPhone/iPad; Midnight\",\n                \"link\": \"https://www.amazon.com/sspa/click?ie=UTF8&spc=MToyNTI5ODI1NDYwMzcwMDA6MTcwNDA5MjUyOTpzcF9hdGY6MzAwMDY1ODg5ODQyMzAyOjowOjo&url=%2FApple-2023-MacBook-Laptop-chip%2Fdp%2FB0CDJL36W4%2Fref%3Dsr_1_2_sspa%3Fkeywords%3Dmacbook%26qid%3D1704092529%26sr%3D8-2-spons%26sp_csd%3Dd2lkZ2V0TmFtZT1zcF9hdGY%26psc%3D1\",\n                \"currency\": \"$\",\n                \"price\": 1499,\n                \"rating\": 4,\n                \"reviews\": 1300,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/81EHBhjC-+L._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2023 MacBook Air Laptop with M2 chip: 15.3-inch Liquid Retina Display, 16GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera, Touch ID. Works with iPhone/iPad; Midnight\",\n                \"link\": \"https://www.amazon.com/Apple-2023-MacBook-Laptop-chip/dp/B0CDJL36W4/ref=sr_1_3?keywords=macbook&qid=1704092529&sr=8-3\",\n                \"currency\": \"$\",\n                \"price\": 1499,\n                \"rating\": 4,\n                \"reviews\": 1300,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/81EHBhjC-+L._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2020 MacBook Air Laptop M1 Chip, 13\\u201d Retina Display, 8GB RAM, 256GB SSD Storage, Backlit Keyboard, FaceTime HD Camera, Touch ID. Works with iPhone/iPad; Silver\",\n                \"link\": \"https://www.amazon.com/gp/bestsellers/pc/13896615011/ref=sr_bs_3_13896615011_1\",\n                \"currency\": \"$\",\n                \"price\": 949,\n                \"rating\": 4,\n                \"reviews\": 19039,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/71TPda7cwUL._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": true,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2023 MacBook Pro Laptop M3 chip with 8\\u2011core CPU, 10\\u2011core GPU: 14.2-inch Liquid Retina XDR Display, 8GB Unified Memory, 1TB SSD Storage. Works with iPhone/iPad; Silver\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-Laptop-8%E2%80%91core-10%E2%80%91core/dp/B0CM5LZWJ1/ref=sr_1_5?keywords=macbook&qid=1704092529&sr=8-5\",\n                \"currency\": \"$\",\n                \"price\": 1748,\n                \"rating\": 4,\n                \"reviews\": 29,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/61HUaSA6c0L._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2022 MacBook Pro Laptop with M2 chip: 13-inch Retina Display, 8GB RAM, 512GB \\u200b\\u200b\\u200b\\u200b\\u200b\\u200b\\u200bSSD \\u200b\\u200b\\u200b\\u200b\\u200b\\u200b\\u200bStorage, Touch Bar, Backlit Keyboard, FaceTime HD Camera. Works with iPhone and iPad; Silver\",\n                \"link\": \"https://www.amazon.com/2022-Apple-MacBook-Laptop-chip/dp/B0B3C8XMXM/ref=sr_1_6?keywords=macbook&qid=1704092529&sr=8-6\",\n                \"currency\": \"$\",\n                \"price\": 1430,\n                \"rating\": 4,\n                \"reviews\": 1206,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/61bX2AoGj2L._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2022 MacBook Air Laptop with M2 chip: 13.6-inch Liquid Retina Display, 8GB RAM, 256GB SSD Storage, Backlit Keyboard, 1080p FaceTime HD Camera. Works with iPhone and iPad; Silver\",\n                \"link\": \"https://www.amazon.com/2022-Apple-MacBook-Laptop-chip/dp/B0B3CDZLTB/ref=sr_1_7?keywords=macbook&qid=1704092529&sr=8-7\",\n                \"currency\": \"$\",\n                \"price\": 1049,\n                \"rating\": 4,\n                \"reviews\": 2343,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/71eXNIDUGjL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"Apple MacBook Air with Intel Core i5, 1.6GHz, (13-inch, 4GB,128GB SSD) - Silver (Renewed)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-MJVE2LL-13-inch-Refurbished/dp/B013HD3INW/ref=sr_1_8?keywords=macbook&qid=1704092529&sr=8-8\",\n                \"currency\": \"$\",\n                \"price\": 249,\n                \"rating\": 4,\n                \"reviews\": 1973,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/6157eU56s2L._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"13.3\\\" MacBook Air with Retina Display - MWT92LL/A\",\n                \"link\": \"https://www.amazon.com/Apple-13-3-MacBook-Retina-Display/dp/B09KW8NRHZ/ref=sr_1_9?keywords=macbook&qid=1704092529&sr=8-9\",\n                \"currency\": \"$\",\n                \"price\": 1199,\n                \"rating\": 0,\n                \"reviews\": 0,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/31WRiCGHeZL._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"Late 2019 Apple MacBook Pro with 2.6GHz Intel Core i7 (16-Inch, 16GB RAM, 512GB Storage) - Silver (Renewed)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-16-Inch-Storage-2-6GHz/dp/B08CZT64VP/ref=sr_1_10?keywords=macbook&qid=1704092529&sr=8-10\",\n                \"currency\": \"$\",\n                \"price\": 875,\n                \"rating\": 4,\n                \"reviews\": 111,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/619L9jf3-rL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2023 MacBook Pro Laptop M3 chip with 8\\u2011core CPU, 10\\u2011core GPU: 14.2-inch Liquid Retina XDR Display, 16GB Unified Memory, 512GB SSD Storage, Space Gray (Z1C80001D)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-Laptop-8%E2%80%91core-10%E2%80%91core/dp/B0CN9RFFVT/ref=sr_1_11?keywords=macbook&qid=1704092529&sr=8-11\",\n                \"currency\": \"$\",\n                \"price\": 1759,\n                \"rating\": 0,\n                \"reviews\": 0,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/61lsexTCOhL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2018 Apple MacBook Pro with 2.3GHz Intel Core i5 (13-inch, 8GB RAM, 256GB SSD Storage) (QWERTY English) Space Gray (Renewed)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-13-inch-Storage-English/dp/B07P6C16BC/ref=sr_1_12?keywords=macbook&qid=1704092529&sr=8-12\",\n                \"currency\": \"$\",\n                \"price\": 472,\n                \"rating\": 4,\n                \"reviews\": 687,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/51NUmIQeUzL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"MacBook Air 13.3\\\" with Retina Display, M1 Chip with 8-Core CPU and 7-Core GPU, 16GB Memory, 512GB SSD, Space Gray, Late 2020\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-Air-Retina-Display/dp/B08VF621Z4/ref=sr_1_13?keywords=macbook&qid=1704092529&sr=8-13\",\n                \"currency\": \"$\",\n                \"price\": 1362,\n                \"rating\": 4,\n                \"reviews\": 157,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/51KhexN7YkL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2022 13\\\" MacBook Air M2, 16GB RAM, 1TB Storage - Midnight (Z160000B6)\",\n                \"link\": \"https://www.amazon.com/Apple-2022-MacBook-16GB-Storage/dp/B0BBXRK4WH/ref=sr_1_14?keywords=macbook&qid=1704092529&sr=8-14\",\n                \"currency\": \"$\",\n                \"price\": 1699,\n                \"rating\": 4,\n                \"reviews\": 10,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/719C6bJv8jL._AC_UY218_.jpg\",\n                \"is_prime\": true,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"Apple MacBook Air MD711LL/A 11.6-inch Laptop - Intel Core i5 1.3GHz - 4GB RAM - 128GB SSD (Renewed)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-MD711LL-11-6-Inch-Refurbished/dp/B01550MWHI/ref=sr_1_15?keywords=macbook&qid=1704092529&sr=8-15\",\n                \"currency\": \"$\",\n                \"price\": 299,\n                \"rating\": 4,\n                \"reviews\": 2032,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/71Z3zEs2vYL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2020 MacBook Pro M1 Chip (13-inch, 8GB RAM, 256GB SSD Storage) - Space Gray\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-13-inch-256GB-Storage/dp/B08N5N6RSS/ref=sr_1_16?keywords=macbook&qid=1704092529&sr=8-16\",\n                \"currency\": \"\",\n                \"price\": 0,\n                \"rating\": 4,\n                \"reviews\": 7029,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/71an9eiBxpL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"Apple MacBook Air MD761LL/A 13.3-Inch Laptop (OLD VERSION) (Renewed)\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-MD761LL-13-3-Inch-Refurbished/dp/B00M4LWW0Y/ref=sr_1_17?keywords=macbook&qid=1704092529&sr=8-17\",\n                \"currency\": \"$\",\n                \"price\": 289,\n                \"rating\": 3,\n                \"reviews\": 91,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/11rXkb9f7DL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            },\n            {\n                \"title\": \"2023 MacBook Pro Laptop M3 Pro chip with 12\\u2011core CPU, 18\\u2011core GPU: 14.2-inch Liquid Retina XDR Display, 18GB Unified Memory, 1TB SSD Storage. Works with iPhone/iPad; Space Black\",\n                \"link\": \"https://www.amazon.com/Apple-MacBook-Laptop-12%E2%80%91core-18%E2%80%91core/dp/B0CM5KK44S/ref=sr_1_18?keywords=macbook&qid=1704092529&sr=8-18\",\n                \"currency\": \"$\",\n                \"price\": 2369,\n                \"rating\": 4,\n                \"reviews\": 39,\n                \"featured_image\": \"https://m.media-amazon.com/images/I/61RJn0ofUsL._AC_UY218_.jpg\",\n                \"is_prime\": false,\n                \"is_best_seller\": false,\n                \"is_amazon_choice\": false\n            }\n        ]\n    },\n    \"error\": null\n}"
  },
  {
    "path": "docker-compose.yaml",
    "content": "version: \"3\"\nservices:\n    bot-1:\n      restart: \"no\"\n      shm_size: 800m\n      build:\n        dockerfile: Dockerfile\n        context: .\n      volumes:\n        - ./output:/app/output\n        - ./tasks:/app/tasks\n        - ./profiles:/app/profiles\n        - ./profiles.json:/app/profiles.json\n        - ./local_storage.json:/app/local_storage.json"
  },
  {
    "path": "local_storage.json",
    "content": "{\n    \"count\": 47,\n    \"credits_used\": 55\n}"
  },
  {
    "path": "main.py",
    "content": "from src import Amazon\n\nqueries = [\n  \"Macbook\",\n]\n\nAmazon.search(queries)"
  },
  {
    "path": "profiles.json",
    "content": "{}"
  },
  {
    "path": "requirements.txt",
    "content": "botasaurus\ncasefy\n"
  },
  {
    "path": "src/__init__.py",
    "content": "from .amazon_scraper import Amazon"
  },
  {
    "path": "src/amazon_scraper.py",
    "content": "from typing import List,Optional, Union, Dict\nfrom botasaurus import bt\nfrom .write_output import write_output\n\nfrom .search import FAILED_DUE_TO_CREDITS_EXHAUSTED, FAILED_DUE_TO_NO_KEY,FAILED_DUE_TO_NOT_SUBSCRIBED, FAILED_DUE_TO_UNKNOWN_ERROR, get_product, search\n\n\ndef clean_data(social_details):\n    success, credits_exhausted, not_subscribed, unknown_error, no_key = [], [], [], [], []\n\n    for detail in social_details:\n        if detail.get(\"error\") is None:\n            success.append(detail)\n        elif detail[\"error\"] == FAILED_DUE_TO_CREDITS_EXHAUSTED:\n            credits_exhausted.append(detail)\n        elif detail[\"error\"] == FAILED_DUE_TO_NOT_SUBSCRIBED:\n            not_subscribed.append(detail)\n        elif detail[\"error\"] == FAILED_DUE_TO_UNKNOWN_ERROR:\n            unknown_error.append(detail)\n        elif detail[\"error\"] == FAILED_DUE_TO_NO_KEY:\n            no_key.append(detail)\n\n    return success, credits_exhausted, not_subscribed, unknown_error, no_key\n\ndef print_data_errors(credits_exhausted, not_subscribed, unknown_error, no_key):\n    \n    if credits_exhausted:\n        name = \"queries\" if len(credits_exhausted) > 1 else \"query\"\n        print(f\"Could not get data for {len(credits_exhausted)} {name} due to credit exhaustion. Please consider upgrading your plan by visiting https://rapidapi.com/Chetan11dev/api/amazon-product-scraper8/pricing to continue scraping data.\")\n\n    if not_subscribed:\n        name = \"queries\" if len(not_subscribed) > 1 else \"query\"\n        print(f\"Could not get data for {len(not_subscribed)} {name} as you are not subscribed to Amazon Scraper API. Please subscribe to a free plan by visiting https://rapidapi.com/Chetan11dev/api/amazon-product-scraper8/pricing\")\n\n    if unknown_error:\n        name = \"queries\" if len(unknown_error) > 1 else \"query\"\n        print(f\"Could not get data for {len(unknown_error)} {name} due to Unknown Error.\")\n\n    if no_key:\n        name = \"queries\" if len(no_key) > 1 else \"query\"\n        print(f\"Could not get data for {len(no_key)} {name} as you are not subscribed to Amazon Scraper API. Please subscribe to a free plan by visiting https://rapidapi.com/Chetan11dev/api/amazon-product-scraper8/pricing\")\n\n      \nclass Amazon:\n    \n    @staticmethod\n    def search(query:  Union[str, List[str]],  key: Optional[str] =None,  use_cache: bool = True) -> Dict:\n        \"\"\"\n        Function to scrape data from Amazon.\n        :param use_cache: Boolean indicating whether to use cached data.\n        :return: List of dictionaries with the scraped data.\n        \"\"\"\n        cache = use_cache\n        if isinstance(query, str):\n            query = [query]  \n        \n        max = None\n\n        query = [{\"query\":query_query, \"max\": max} for query_query in query]\n        result = []\n        for item in query:\n            # TODO: max fixes\n            data = item\n            metadata = {\"key\": key}\n            \n            result_item = search(data, cache=cache, metadata=metadata)\n            \n            success, credits_exhausted, not_subscribed, unknown_error, no_key = clean_data([result_item])\n            print_data_errors(credits_exhausted, not_subscribed, unknown_error, no_key)\n\n            if success:\n                data = result_item.get('data')\n                if not data:\n                    data = {}\n\n                result_item = data.get('results', [])\n                result.extend(result_item)\n                write_output(item['query'], result_item,None)\n\n        if result:\n            # bt.write_json(result, \"result\")\n            write_output('_all',result, None, lambda x:x)\n        \n        search.close()\n\n        return result\n\n    @staticmethod\n    def get_products(asin:  Union[str, List[str]],  key: Optional[str] =None,  use_cache: bool = True) -> Dict:\n        \"\"\"\n        Function to scrape data from Amazon.\n        :param use_cache: Boolean indicating whether to use cached data.\n        :return: List of dictionaries with the scraped data.\n        \"\"\"\n        cache = use_cache\n        if isinstance(asin, str):\n            asin = [asin]  \n        \n        asin = [{\"asin\":query_query} for query_query in asin]\n        result = []\n        for item in asin:\n            # TODO: max fixes\n            data = item\n            metadata = {\"key\": key}\n            \n            result_item = get_product(data, cache=cache, metadata=metadata)\n            \n            success, credits_exhausted, not_subscribed, unknown_error, no_key = clean_data([result_item])\n            print_data_errors(credits_exhausted, not_subscribed, unknown_error, no_key)\n\n            if success:\n                data = result_item.get('data')\n                if not data:\n                    data = {}\n\n                result_item = data\n                result.append(result_item)\n                # write_output(item['query'], result_item,None)\n\n        if result:\n            # bt.write_json(result, \"result\")\n            write_output('products',result, None, lambda x:x)\n        \n        search.close()\n\n        return result    "
  },
  {
    "path": "src/search.py",
    "content": "\nfrom botasaurus import bt\nfrom botasaurus.cache import DontCache\nfrom botasaurus import cl\nfrom time import sleep\nfrom botasaurus import *\nfrom .utils import   default_request_options\nimport requests\n\nFAILED_DUE_TO_CREDITS_EXHAUSTED = \"FAILED_DUE_TO_CREDITS_EXHAUSTED\"\nFAILED_DUE_TO_NOT_SUBSCRIBED = \"FAILED_DUE_TO_NOT_SUBSCRIBED\"\nFAILED_DUE_TO_NO_KEY = \"FAILED_DUE_TO_NO_KEY\"\nFAILED_DUE_TO_UNKNOWN_ERROR = \"FAILED_DUE_TO_UNKNOWN_ERROR\"\n\ndef update_credits():\n    credits_used  = bt.LocalStorage.get_item(\"credits_used\", 0)\n    bt.LocalStorage.set_item(\"credits_used\", credits_used + 1)\n\ndef do_request(data, retry_count=3):\n    \n    params = data[\"params\"]\n\n\n    link = params[\"link\"]\n    key = data[\"key\"]\n    # print(params)\n    # print(\"link\", link)\n    if retry_count == 0:\n        print(f\"Failed to get data, after 3 retries\")\n        return {\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_UNKNOWN_ERROR, \n                    }\n\n    \n\n    headers = {\n        \"X-RapidAPI-Key\": key,\n    \t\"X-RapidAPI-Host\": \"amazon-product-scraper8.p.rapidapi.com\"\n    }\n\n    \n    response = requests.get(link, headers=headers)\n    response_data = response.json()\n    if response.status_code == 200 or response.status_code == 404:\n        \n        message = response_data.get(\"message\", \"\")\n        if \"API doesn't exists\" in message:\n            return {\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_UNKNOWN_ERROR\n                    }\n\n        update_credits()\n        # print(response_data)\n        # bt.write_json(response_data, \"response.json\")\n        if response.status_code  == 404:\n            print(f\"No data found\")\n            \n            return {\n                \"data\": response_data,\n                \"error\": None\n            }\n\n        return {\n            \"data\": response_data,\n            \"error\": None\n        }\n    else:\n\n        message = response_data.get(\"message\", \"\")\n        \n        if \"exceeded the MONTHLY quota\" in message:\n            return  {\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_CREDITS_EXHAUSTED\n                    }\n        elif \"exceeded the rate limit per second for your plan\" in message or \"many requests\" in message:\n            sleep(2)\n            return do_request(data, retry_count - 1)\n        elif \"You are not subscribed to this API.\" in message:\n            return {\n                        \"data\": None,\n                        \"error\": FAILED_DUE_TO_NOT_SUBSCRIBED\n                    }\n\n        print(f\"Error: {response.status_code}\", response_data)\n        \n        return  {\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_UNKNOWN_ERROR, \n                    }\n\n@request(**default_request_options)\ndef search(_, data, metadata):\n    if not metadata.get('key'):\n         return  DontCache({\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_NO_KEY\n                    })\n    max_items = data['max']\n    url = \"https://amazon-product-scraper8.p.rapidapi.com/search/\"\n    qp = {\"query\": data['query']}\n    params = {**qp, 'link':cl.join_link(url, query_params=qp)}\n\n    request_data = {**metadata, \"params\": params}\n    result = do_request(request_data)\n    initial_results = cl.select(result, 'data', 'results', default=[])\n    \n    if not cl.select(result, 'error'):\n        more_results = cl.select(result, 'data', 'results', default=[])\n        print(f\"Got {len(more_results)} more results\")\n\n    while cl.select(result, 'data', 'next') and (max_items is None or len(initial_results) < max_items):\n        next = cl.select(result, 'data', 'next')\n\n        params = {**qp, 'link':next}\n        request_data = {**metadata, \"params\": params}\n        result = do_request(request_data)\n        if result.get('error'):\n            break\n        more_results = cl.select(result, 'data', 'results', default=[])\n        print(f\"Got {len(more_results)} more results\")\n        initial_results.extend(more_results)\n\n\n    if cl.select(result, 'error'):\n        return DontCache(result)\n    else: \n        if max_items is not None:\n            initial_results = initial_results[:max_items]\n\n        result['data']['results'] = initial_results\n        return result\n\n\n@request(**default_request_options)\ndef get_product(_, data, metadata):\n    if not metadata.get('key'):\n         return  DontCache({\n                        \"data\":  None,\n                        \"error\":FAILED_DUE_TO_NO_KEY\n                    })\n    \n    url = \"https://amazon-product-scraper8.p.rapidapi.com/product/\"\n    qp = {\"asin\": data['asin']}\n    params = {**qp, 'link':cl.join_link(url, query_params=qp)}\n\n    request_data = {**metadata, \"params\": params}\n    result = do_request(request_data)\n    return result\n\n"
  },
  {
    "path": "src/utils.py",
    "content": "\ndefault_browser_options = {\n    \"block_images\": True,\n    \"reuse_driver\": True,\n    \"keep_drivers_alive\": True,\n    \"close_on_crash\": True,  # When Ready for Production change to True\n    \"headless\": True,        # When Ready change to True\n    'output': None, # When Ready for Production Uncomment\n}\n\n# max 5 retries add\ndefault_request_options = {\n    \"close_on_crash\": True,  # When Ready for Production change to True\n    'output': None, # When Ready for Production Uncomment\n    \"raise_exception\":True, \n}"
  },
  {
    "path": "src/write_output.py",
    "content": "from botasaurus import bt\nfrom botasaurus.decorators import print_filenames\nfrom .write_output_utils import kebab_case, make_folders\n\n\ndef create_json(path, data):\n    bt.write_json(data, path, False )\n\n\ndef create_csv(path, data):\n    bt.write_csv(data, path, False )\n\ndef format(query_kebab, entity_type, type):\n    return f\"{query_kebab}.{type}\"\n\ndef create(data, selected_fields, csv_path, json_path, query_kebab,entity_type):\n        written = []\n        \n        fname = json_path + format(query_kebab, entity_type,\"json\",) \n        create_json(fname, data)\n        written.append(fname)\n\n        fname = csv_path + format(query_kebab, entity_type,\"csv\",) \n        create_csv(fname, data)\n        written.append(fname)\n\n        print_filenames(written)\n\ndef write_output(query, data, entity_type,transformer = kebab_case):\n\n    query_kebab = transformer(query)\n    make_folders(query_kebab)\n\n    csv_path = f\"output/{query_kebab}/csv/\" \n    json_path = f\"output/{query_kebab}/json/\"\n\n    create(data,[],  csv_path, json_path, query_kebab,entity_type)\n"
  },
  {
    "path": "src/write_output_utils.py",
    "content": "from botasaurus.decorators_utils import create_directory_if_not_exists\nfrom casefy import kebabcase\n\n\ndef kebab_case(s):\n    return kebabcase(s)\n\ndef make_folders(query_kebab):\n  create_directory_if_not_exists(f\"output/{query_kebab}/\")\n  create_directory_if_not_exists(f\"output/{query_kebab}/json/\")\n  create_directory_if_not_exists(f\"output/{query_kebab}/csv/\")\n\ndef format(query_kebab, type, name):\n    return f\"{name}-of-{query_kebab}.{type}\"\n\n"
  }
]