Python script for Amazon deal alerts using SellerMagnetAPI

How to Build a Python Script for Amazon Deal Alerts with SellerMagnetAPI

By John Smith | July 09, 2025

Build an Amazon Deal Alert System with Python and SellerMagnetAPI

Are you an Amazon business owner or market analyst looking for a competitive edge? Staying ahead of price fluctuations and emerging deals is crucial for optimizing inventory, refining pricing strategies, and gaining a comprehensive market overview. This post guides you through creating a Python script to monitor Amazon deals using the SellerMagnetAPI, a robust solution for accessing real-time Amazon data.

Why Use SellerMagnetAPI for Amazon Deal Alerts?

SellerMagnetAPI provides enterprise-grade access to Amazon data, offering reliability and scalability for businesses of all sizes. Unlike basic web scraping methods, our Structured Data API delivers clean, structured data, eliminating the need for complex parsing and maintenance. This allows you to focus on analyzing the data and making informed decisions. Plus, you can create a DataPipeline to fully automate and schedule your data retrievals.

Key Benefits:

  • Real-Time Data: Access up-to-the-minute information on product prices, sales ranks, and offers.
  • Structured Data: Receive data in a consistent, predictable format for easy integration with your systems.
  • Scalability: Handle large volumes of data without performance bottlenecks.
  • Reliability: Count on stable, consistent data delivery, minimizing disruptions to your workflow.

Prerequisites

Before you begin, ensure you have the following:

  • A SellerMagnetAPI account with a valid API key (Try Free).
  • Python 3.6 or higher installed.
  • The requests library installed (pip install requests).

Step-by-Step Guide to Building Your Amazon Deal Alert Script

Step 1: Import Necessary Libraries

Start by importing the requests library for making HTTP requests and the json library for handling JSON responses.


import requests
import json

Step 2: Define API Credentials and Target ASINs

Set your API key and the Amazon Standard Identification Numbers (ASINs) for the products you want to monitor. You can retrieve the ASINs by using the Amazon Product Lookup or Amazon Search API endpoints.


API_KEY = 'YOUR_API_KEY'
MARKETPLACE_ID = 'ATVPDKIKX0DER'  # Example: Amazon.com
ASINS = ['B08N5WRWNW', 'B07XJ8C5F7', 'B09G9J5HPZ'] # Replace with your desired ASINs

Step 3: Fetch Product Data using SellerMagnetAPI

Use the Amazon Product Statistics endpoint to retrieve product information, including price, sales rank, and review counts. This endpoint allows you to track changes over time, which is essential for identifying deals.


def get_product_statistics(asin, api_key, marketplace_id):
    url = f'https://sellermagnet-api.com/amazon-product-statistics?asin={asin}&marketplaceId={marketplace_id}&api_key={api_key}'
    response = requests.get(url)
    response.raise_for_status()  # Raise HTTPError for bad responses (4xx or 5xx)
    return response.json()

Example Request:


curl 'https://sellermagnet-api.com/amazon-product-statistics?asin=B08N5WRWNW&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY'

Example Response:


{
  "success": true,
  "data": {
    "asin": "B08N5WRWNW",
    "amazonPrice": 5999,
    "bestSellerRank": 123,
    "buyBoxPrice": 5999,
    "buyBoxFulfillment": "FBA",
    "buyBoxSellerIdHistory": [
      [
        "2024-07-04T12:00:00",
        "A123456789012"
      ]
    ],
    "salesRankHistory": [
      [
        "2024-07-04T12:00:00",
        123
      ]
    ],
    "trackingSince": "2023-01-01"
  }
}

Step 4: Implement Deal Alert Logic

Define a function to check if a product's price has dropped below a certain threshold or by a specific percentage. This is where you implement your deal alert criteria.


def check_for_deal(product_data, price_threshold, percentage_drop):
    current_price = product_data['data']['buyBoxPrice']
    initial_price = product_data['data']['amazonPrice']

    if current_price <= price_threshold:
        return True, f'Price below threshold: {current_price}'

    if initial_price and (initial_price - current_price) / initial_price >= percentage_drop:
        return True, f'Price dropped by {percentage_drop*100}%'

    return False, None

Step 5: Run the Script and Send Alerts

Iterate through the list of ASINs, fetch product data, and check for deals. If a deal is found, send an alert (e.g., via email or Slack). Remember to implement error handling to catch any issues with the API requests.


def main():
    PRICE_THRESHOLD = 5000  # Price in cents
    PERCENTAGE_DROP = 0.10  # 10% price drop

    for asin in ASINS:
        try:
            product_data = get_product_statistics(asin, API_KEY, MARKETPLACE_ID)
            is_deal, message = check_for_deal(product_data, PRICE_THRESHOLD, PERCENTAGE_DROP)

            if is_deal:
                print(f'DEAL ALERT! ASIN: {asin} - {message}')
                # Implement your alert sending mechanism here (e.g., email, Slack)
            else:
                print(f'No deal found for ASIN: {asin}')

        except requests.exceptions.RequestException as e:
            print(f'Error fetching data for ASIN {asin}: {e}')
        except KeyError as e:
            print(f'Error parsing data for ASIN {asin}: Missing key {e}')
        except Exception as e:
            print(f'An unexpected error occurred for ASIN {asin}: {e}')

if __name__ == "__main__":
    main()

Enhancements and Use Cases

  • Historical Data Analysis: Use the Amazon Product Statistics API to analyze historical price trends and identify seasonal deals. You can even generate visually graphs for history data.
  • Competitor Monitoring: Track competitor products to identify pricing strategies and react accordingly.
  • Inventory Management: Trigger alerts when a product's price drops, indicating a potential opportunity to replenish inventory at a lower cost.
  • Integration with Other APIs: Combine data from the Amazon Product Offers API to get detailed information on seller offers and availability. You can also use the Amazon Seller Review API to perform seller analysis.
  • ASIN/EAN Conversion: Translate product codes using the Amazon ASIN/ISBN/EAN Converter for broader product coverage.
  • Estimate Sales: Use the Amazon Product Estimate Sales API to estimate product sales, improving inventory forecasting.

Geolocation Considerations

For region-specific deals, use the geo_location parameter with the Amazon Product Offers and Amazon Search endpoints. This allows you to tailor your alerts to specific geographic locations, ensuring relevance for your target market.

Legal Compliance and Best Practices

  • Terms of Service: Always adhere to Amazon's terms of service and avoid overloading their servers.
  • Data Privacy: Respect user data privacy and comply with relevant regulations (e.g., GDPR).
  • Rate Limiting: Implement rate limiting in your script to avoid being throttled by the API.

Conclusion

By leveraging the SellerMagnetAPI, you can create a sophisticated Amazon deal alert system that empowers your business with real-time insights. This allows for informed decision-making, optimized inventory management, and a significant competitive advantage. Sign up for a free trial today and unlock the power of Amazon data!

Explore our Documentation for more details, and check out our Code Examples for more inspiration. Stay informed about API Status and discover more resources like Free Downloads and our comprehensive Glossary. Visit our Blog for the latest updates, and don't hesitate to Contact us for any assistance. Pricing options are available to suit your business needs. Login or Try Free today!

Back to Blog