Python script for Amazon deal performance tracking with SellerMagnet API

Building a Python Script for Amazon Deal Performance Tracking

By Alex Rodriguez | July 10, 2025

Building a Python Script for Amazon Deal Performance Tracking

In the dynamic world of e-commerce, staying ahead requires precise, real-time data. For Amazon businesses and market analysts, tracking deal performance is crucial for competitive analysis, inventory management, and market research. This post guides you through building a Python script leveraging the power of SellerMagnet's Amazon data API to monitor and analyze Amazon deal performance effectively.

Why Track Amazon Deal Performance?

Understanding how deals perform provides invaluable insights. It enables businesses to:

  • Optimize Pricing Strategies: Identify optimal price points by analyzing deal impact on sales rank.
  • Monitor Competitors: Track competitor deals and adjust strategies accordingly.
  • Improve Inventory Management: Predict demand surges driven by deals.
  • Conduct Market Research: Identify trends and opportunities in the Amazon marketplace.

Leveraging SellerMagnet’s Amazon Data API

SellerMagnet offers an enterprise-grade Amazon data API providing comprehensive data for informed decision-making. We'll utilize the Amazon Product Statistics endpoint for this project.

Prerequisites

  • Python 3.6+
  • An active SellerMagnet API subscription (including API key)
  • Libraries: requests, json

Step-by-Step Guide

1. Setting Up the Environment

Install the necessary Python libraries:


pip install requests
2. Writing the Python Script

Here’s a Python script example to fetch product statistics using SellerMagnet’s API:


import requests
import json

API_KEY = 'YOUR_API_KEY' # Replace with your actual API key
ASIN = 'B0CLTBHXWQ'  # Example ASIN
MARKETPLACE_ID = 'APJ6JRA9NG5V4' # Example Marketplace ID

def get_product_statistics(asin, marketplace_id, api_key):
    url = f'https://sellermagnet-api.com/amazon-product-statistics?asin={asin}&marketplaceId={marketplace_id}&api_key={api_key}'
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise HTTPError for bad responses (4xx or 5xx)
        data = response.json()
        return data
    except requests.exceptions.RequestException as e:
        print(f"Error occurred: {e}")
        return None

if __name__ == '__main__':
    product_data = get_product_statistics(ASIN, MARKETPLACE_ID, API_KEY)

    if product_data and product_data['success']:
        print(json.dumps(product_data, indent=4))
    else:
        print("Failed to retrieve product statistics.")

Replace 'YOUR_API_KEY', 'B0CLTBHXWQ', and 'APJ6JRA9NG5V4' with your actual API key, the ASIN you want to track, and the appropriate Marketplace ID.

3. Understanding the Response

The API returns a JSON response containing detailed product statistics. Here's a sample response:


{
  "data": {
    "asin": "B0CLTBHXWQ",
    "productTitle": "Playstation 5 Console Edizione Digital Slim",
    "buyBoxPrice": 41800,
    "buyBoxFulfillment": "FBM",
    "buyBoxSellerIdHistory": [
      [
        "2025-06-14 17:08:00",
        "A2I59UVTUWUFH0"
      ]
    ],
    "categoryTree": [
      {
        "catId": 412603031,
        "name": "Videogiochi"
      },
      {
        "catId": 20904349031,
        "name": "PlayStation 5"
      },
      {
        "catId": 20904364031,
        "name": "Console"
      }
    ],
    "graphs": {
      "amazonAsSellerPriceHistory": "https://sellermagnet-api-webspace.s3.eu-central-1.amazonaws.com/amazon/api/charts/B0CLTBHXWQ/1749913774/B0CLTBHXWQ_amazon_price_1749913773.png",
      "lowestFBAPriceHistory": "https://sellermagnet-api-webspace.s3.eu-central-1.amazonaws.com/amazon/api/charts/B0CLTBHXWQ/1749913776/B0CLTBHXWQ_fba_price_1749913773.png",
      "lowestFBMPriceHistory": "https://sellermagnet-api-webspace.s3.eu-central-1.amazonaws.com/amazon/api/charts/B0CLTBHXWQ/1749913775/B0CLTBHXWQ_fbm_price_1749913773.png",
      "monthlySoldHistory": "https://sellermagnet-api-webspace.s3.eu-central-1.amazonaws.com/amazon/api/charts/B0CLTBHXWQ/1749913778/B0CLTBHXWQ_monthly_sold_1749913773.png",
      "productRatingHistory": "https://sellermagnet-api-webspace.s3.eu-central-1.amazonaws.com/amazon/api/charts/B0CLTBHXWQ/1749913777/B0CLTBHXWQ_rating_1749913773.png"
    },
    "listedSince": "2023-12-30 01:00:00",
    "lowestFBAPrice": 44999,
    "lowestFBMPrice": 41700,
    "marketplaceId": "APJ6JRA9NG5V4",
    "marketplaceNewPriceHistory": [
      [
        "2025-06-14",
        41700
      ]
    ],
    "offers": {
      "A11IL2PNWYJU7H": {
        "isFBA": true,
        "lastUpdated": "2025-06-14 17:08:00",
        "priceHistory": [
          [
            "2025-06-14 06:22:00",
            44999,
            0
          ]
        ],
        "stockHistory": [
          [
            "2025-05-29 11:32:00",
            1
          ]
        ]
      },
      "A12FLY25DT7QO0": {
        "isFBA": false,
        "lastUpdated": "2025-06-14 17:08:00",
        "priceHistory": [
          [
            "2025-06-09 15:32:00",
            41800,
            0
          ]
        ],
        "stockHistory": [
          [
            "2025-06-14 13:34:00",
            49
          ]
        ]
      },
      "A18KSDUE00UP6J": {
        "isFBA": false,
        "lastUpdated": "2025-06-14 17:08:00",
        "priceHistory": [
          [
            "2025-05-29 11:32:00",
            42890,
            0
          ]
        ],
        "stockHistory": [
          [
            "2025-05-30 18:30:00",
            3
          ]
        ]
      }
    },
    "productReviewAverage": 4.7,
    "productTotalReviews": 3129,
    "rootCategory": {
      "id": 412603031,
      "name": "Videogiochi"
    },
    "stats": {
      "amazonAsSellerPriceHistory": [
        [
          "2025-06-14",
          44999
        ]
      ],
      "buyBoxPriceHistory": [
        [
          "2025-06-13",
          41700
        ]
      ],
      "monthlySoldHistory": [
        [
          "2025-06",
          1000
        ]
      ],
      "productRatingCountHistory": [
        [
          "2025-06-14 15:28:00",
          3129
        ]
      ],
      "productRatingHistory": [
        [
          "2025-02-02 01:30:00",
          4.7
        ]
      ],
      "salesRankHistory": [
        [
          "2025-06-14 01:58:00",
          15
        ]
      ]
    }
  },
  "success": true
}
4. Analyzing the Data

The JSON response provides a wealth of information. Focus on these key metrics for deal performance:

  • buyBoxPrice: The current price in the Buy Box, reflecting deal pricing.
  • salesRankHistory: Historical sales rank data to measure the impact of deals over time.
  • buyBoxSellerIdHistory: Changes in Buy Box ownership, indicating competitive responses.
  • graphs: Image URLs for price and sales rank history charts for quick visual analysis.

You can further enhance the analysis by integrating this script with DataPipeline to schedule periodic data collection.

Advanced Use Cases

  • Competitor Monitoring: Use the Amazon Search endpoint to find competitor products and track their deal performance.
  • Inventory Optimization: Combine sales rank data with Amazon Product Offers to estimate stock levels and optimize inventory.
  • Real-time Alerts: Implement thresholds for sales rank changes and receive alerts when a deal significantly impacts performance.

Additional SellerMagnet API Endpoints

Conclusion

By building a Python script with SellerMagnet’s Amazon data API, you can gain a competitive edge through real-time deal performance tracking. This enables data-driven decisions, optimized strategies, and improved business outcomes. Start building your script today and unlock the power of Amazon data!

Explore Documentation and Code Examples for more ways to use SellerMagnet's API.

Back to Blog