Python Script for Amazon Product Review Trend Analysis with SellerMagnetAPI

Building a Python Script for Amazon Product Review Trend Analysis with SellerMagnetAPI

By Emma Johnson | July 25, 2025

Building a Python Script for Amazon Product Review Trend Analysis with SellerMagnetAPI

In today's competitive e-commerce landscape, understanding customer sentiment is paramount. For Amazon businesses and market analysts, tracking product review trends offers invaluable insights for competitive analysis, inventory management, and strategic market research. This blog post demonstrates how to build a Python script using the SellerMagnetAPI to automate the process of analyzing Amazon product review trends.

Why Analyze Amazon Product Review Trends?

Monitoring review trends provides a real-time pulse on customer perceptions. Key benefits include:

  • Competitive Analysis: Identify strengths and weaknesses compared to competitors.
  • Inventory Management: Anticipate demand fluctuations based on changing sentiment.
  • Market Research: Uncover unmet needs and emerging opportunities.
  • Reputation Management: Proactively address negative feedback and improve product offerings.

Introducing SellerMagnetAPI

The SellerMagnetAPI offers a robust and reliable solution for accessing real-time Amazon data. Its enterprise-grade infrastructure ensures data accuracy and scalability, making it the ideal choice for businesses of all sizes. We will leverage the Amazon Product Statistics endpoint for this analysis.

Prerequisites

Before we start, ensure you have the following:

  • A SellerMagnetAPI account and API key.
  • Python 3.6 or higher installed.
  • The requests library installed (pip install requests).

Step-by-Step Guide to Building the Python Script

1. Importing Libraries and Setting Up Credentials

First, import the necessary libraries and define your API key and target product ASIN:


import requests
import json

API_KEY = "YOUR_API_KEY"  # Replace with your actual API key
ASIN = "B08N5WRWNW" # Replace with the target product ASIN
MARKETPLACE_ID = "ATVPDKIKX0DER" # Replace with your marketplace ID

2. Defining the API Request Function

Create a function to fetch product statistics from the Amazon Product Statistics endpoint:


def get_product_statistics(asin, marketplace_id, api_key):
    url = "https://sellermagnet-api.com/amazon-product-statistics"
    params = {
        "asin": asin,
        "marketplaceId": marketplace_id,
        "api_key": api_key
    }

    response = requests.get(url, params=params)

    if response.status_code == 200:
        return response.json()
    else:
        print(f"Error: {response.status_code} - {response.text}")
        return None

3. Retrieving and Parsing the Data

Call the function and parse the JSON response to extract review counts over time:


def analyze_review_trend(asin, marketplace_id, api_key):
    data = get_product_statistics(asin, marketplace_id, api_key)
    if data and data["success"]:
        sales_rank_history = data["data"]["salesRankHistory"]
        if sales_rank_history:
            print(f"Sales Rank History for ASIN: {asin}")
            for timestamp, rank in sales_rank_history:
                print(f"  {timestamp}: Rank {rank}")
        else:
            print("No Sales Rank history available for this product.")
    else:
        print("Failed to retrieve product statistics.")

4. Running the Script

Finally, execute the script:


analyze_review_trend(ASIN, MARKETPLACE_ID, API_KEY)

5. Full Code Example


import requests
import json

API_KEY = "YOUR_API_KEY"  # Replace with your actual API key
ASIN = "B08N5WRWNW" # Replace with the target product ASIN
MARKETPLACE_ID = "ATVPDKIKX0DER" # Replace with your marketplace ID

def get_product_statistics(asin, marketplace_id, api_key):
    url = "https://sellermagnet-api.com/amazon-product-statistics"
    params = {
        "asin": asin,
        "marketplaceId": marketplace_id,
        "api_key": api_key
    }

    response = requests.get(url, params=params)

    if response.status_code == 200:
        return response.json()
    else:
        print(f"Error: {response.status_code} - {response.text}")
        return None

def analyze_review_trend(asin, marketplace_id, api_key):
    data = get_product_statistics(asin, marketplace_id, api_key)
    if data and data["success"]:
        sales_rank_history = data["data"]["salesRankHistory"]
        if sales_rank_history:
            print(f"Sales Rank History for ASIN: {asin}")
            for timestamp, rank in sales_rank_history:
                print(f"  {timestamp}: Rank {rank}")
        else:
            print("No Sales Rank history available for this product.")
    else:
        print("Failed to retrieve product statistics.")

analyze_review_trend(ASIN, MARKETPLACE_ID, API_KEY)

6. Code Response Example


{
    "success": true,
    "data": {
        "asin": "B0CLTBHXWQ",
        "amazonPrice": null,
        "bestSellerRank": 15,
        "buyBoxPrice": 41800,
        "buyBoxFulfillment": "FBM",
        "buyBoxSellerIdHistory": [
            [
                "2025-06-14T17:08:00",
                "A2I59UVTUWUFH0"
            ]
        ],
        "salesRankHistory": [
            [
                "2025-06-14T01:58:00",
                15
            ],
            [
                "2025-06-13T23:58:00",
                15
            ],
            [
                "2025-06-13T21:58:00",
                15
            ]
        ],
        "trackingSince": "2024-06-24",
        "graphs": {
          "priceTrend": [
              {
                "timestamp": "2025-06-14T17:08:00",
                "price": 41800
              }
           ],
          "rankTrend": [
              {
                "timestamp": "2025-06-14T01:58:00",
                "rank": 15
              }
           ]
        },
        "metadata": {
            "category": "Playstation",
            "lastUpdated": "2025-06-14T17:08:00"
        }
    },
    "errors": null
}

Advanced Analysis and Use Cases

Visualizing Review Trends

The graphs parameter in the Amazon Product Statistics endpoint enables the generation of visual graphs for historical data, including price and sales rank trends. Use these graphs to quickly identify patterns and anomalies in product performance.


import requests
import json

API_KEY = "YOUR_API_KEY"  # Replace with your actual API key
ASIN = "B08N5WRWNW" # Replace with the target product ASIN
MARKETPLACE_ID = "ATVPDKIKX0DER" # Replace with your marketplace ID

def get_product_statistics(asin, marketplace_id, api_key, graphs=True):
    url = "https://sellermagnet-api.com/amazon-product-statistics"
    params = {
        "asin": asin,
        "marketplaceId": marketplace_id,
        "api_key": api_key,
        "graphs": graphs
    }

    response = requests.get(url, params=params)

    if response.status_code == 200:
        return response.json()
    else:
        print(f"Error: {response.status_code} - {response.text}")
        return None

Combining with Amazon Seller Review Data

Enhance your analysis by incorporating seller review data. Use the Amazon Seller Review endpoint to assess seller performance and its potential impact on product reviews.

Integrating with DataPipeline for Automated Monitoring

Automate your review trend analysis by integrating the script with DataPipeline. Schedule regular data retrieval to maintain an up-to-date view of customer sentiment.

Practical Use Cases

  • Identifying Declining Product Quality: A sudden drop in average rating can indicate quality issues.
  • Measuring the Impact of Marketing Campaigns: Monitor review trends before and after a campaign to gauge its effectiveness.
  • Tracking Competitor Performance: Compare review trends across competing products to identify market leaders.
  • Optimizing Pricing Strategies: Adjust prices based on customer sentiment and perceived value.

Leveraging Other SellerMagnetAPI Endpoints

Enhance your Amazon data analysis with these additional SellerMagnetAPI endpoints:

Conclusion

By leveraging the power of the SellerMagnetAPI and Python, businesses can gain a competitive edge through automated Amazon product review trend analysis. This data-driven approach enables informed decision-making, optimized strategies, and ultimately, improved customer satisfaction. Sign up for a free trial today and unlock the potential of Amazon data!

Check out the Documentation and Code Examples for more details and information.

Back to Blog