Python Tool for Amazon Competitor Inventory Analysis with SellerMagnetAPI

Building a Python Tool for Amazon Competitor Inventory Analysis with SellerMagnetAPI

By John Smith | July 25, 2025

Building a Python Tool for Amazon Competitor Inventory Analysis with SellerMagnetAPI

In today's competitive e-commerce landscape, understanding your competitors' inventory levels on Amazon is crucial for effective market analysis and strategic decision-making. This blog post will guide you through building a Python tool using the SellerMagnetAPI to analyze competitor inventory on Amazon. This approach provides businesses with an enterprise-grade solution for competitive analysis, inventory management, and market research, enabling informed decisions and optimized strategies.

Why Competitor Inventory Analysis Matters

Knowing your competitors' stock levels can provide invaluable insights:

  • Market Demand: Gauge overall demand for a product category.
  • Supply Chain Disruptions: Identify potential disruptions impacting your competitors.
  • Pricing Strategy: Understand how inventory levels influence pricing decisions.
  • Competitive Advantage: Adjust your inventory and marketing strategies to capitalize on competitor stockouts.

Introducing SellerMagnetAPI

SellerMagnetAPI offers a robust and reliable solution for accessing real-time Amazon data, including product statistics, pricing, and seller information. Its enterprise-grade infrastructure ensures accurate and scalable data retrieval, making it ideal for businesses of all sizes. Let's explore how to leverage SellerMagnetAPI to build our competitor inventory analysis tool.

Setting Up Your Python Environment

Before we begin, ensure you have Python installed and set up. Install the `requests` library, which we'll use to make API calls:

pip install requests

Using the Amazon Product Offers Endpoint

The Amazon Product Offers endpoint is key to obtaining competitor inventory data. This endpoint returns a list of offers for a specific product, including the seller's inventory, price, and fulfillment method.

Example Request

Here’s how to use the /amazon-product-offers endpoint:

GET https://sellermagnet-api.com/amazon-product-offers?asin=B0CL61F39H&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY

Python Code Example

Here’s the Python code to fetch and parse the offers:


import requests

def get_amazon_product_offers(asin, marketplace_id, api_key):
    url = f"https://sellermagnet-api.com/amazon-product-offers?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()

# Replace with your actual ASIN, marketplace ID, and API key
asin = "B0CL61F39H"
marketplace_id = "ATVPDKIKX0DER"
api_key = "YOUR_API_KEY"

try:
    product_offers = get_amazon_product_offers(asin, marketplace_id, api_key)
    if product_offers['success']:
        for offer in product_offers['data']['offers']:
            seller_id = offer['sellerId']
            seller_name = offer['sellerName']
            inventory = offer['inventory']
            price = offer['totalPrice']
            print(f"Seller ID: {seller_id}, Seller Name: {seller_name}, Inventory: {inventory}, Price: {price}")
    else:
        print("Error fetching product offers:", product_offers)
except requests.exceptions.RequestException as e:
    print("Request failed:", e)
except KeyError as e:
    print("KeyError:", e)
    print("Response Structure:", product_offers) # Debug the response structure

Response Example

The response from the API will look like this:


{
  "data": {
    "asin": "B0CL61F39H",
    "buyBox": {
      "condition": "New",
      "deliveryDate": "2025-06-28",
      "fulfillmentType": "FBA",
      "inventory": 30,
      "positivePercentage": 0,
      "priceWithoutShipping": 499,
      "sellerId": "Amazon",
      "sellerName": "Amazon",
      "shippingPrice": 0,
      "totalPrice": 499,
      "totalReviews": 0
    },
    "currency": {
      "code": "USD",
      "name": "United States Dollar",
      "symbol": "$"
    },
    "marketplaceId": "ATVPDKIKX0DER",
    "offers": [
      {
        "condition": "New",
        "deliveryDate": "2025-06-28",
        "fulfillmentType": "FBA",
        "inventory": 30,
        "positivePercentage": 0,
        "priceWithoutShipping": 499,
        "sellerId": "Amazon",
        "sellerName": "Amazon",
        "shippingPrice": 0,
        "totalPrice": 499,
        "totalReviews": 0
      },
      {
        "condition": "Used - Very Good",
        "deliveryDate": "2025-07-07",
        "fulfillmentType": "FBM",
        "inventory": 10,
        "positivePercentage": 78,
        "priceWithoutShipping": 409.99,
        "sellerId": "A17J18A7XABQI9",
        "sellerName": "PRICE 2 SAVE",
        "shippingPrice": 0,
        "totalPrice": 409.99,
        "totalReviews": 6892
      },
      // More offers...
    ],
    "productLink": "https://www.amazon.com/dp/B0CL61F39H",
    "productMainImage": "https://m.media-amazon.com/images/I/31kTNmpm6vL.jpg",
    "productTitle": "PlayStation®5 console (slim)"
  },
  "success": true
}

Analyzing Seller Reviews with the Amazon Seller Review Endpoint

Understanding the reputation of your competitors can offer additional insights. Utilize the Amazon Seller Review endpoint to gather feedback data.

Example Request

GET https://sellermagnet-api.com/amazon-seller-review?sellerId=A17J18A7XABQI9&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY

Python Code Example


import requests

def get_amazon_seller_review(seller_id, marketplace_id, api_key):
    url = f"https://sellermagnet-api.com/amazon-seller-review?sellerId={seller_id}&marketplaceId={marketplace_id}&api_key={api_key}"
    response = requests.get(url)
    response.raise_for_status()
    return response.json()

# Replace with your actual seller ID, marketplace ID, and API key
seller_id = "A17J18A7XABQI9"
marketplace_id = "ATVPDKIKX0DER"
api_key = "YOUR_API_KEY"

try:
    seller_review = get_amazon_seller_review(seller_id, marketplace_id, api_key)
    if seller_review['success']:
        feedback = seller_review['data']['marketplace'][marketplace_id]['sellerFeedback']
        print(f"Seller ID: {seller_id}")
        print(f"30 Days Rating: {feedback['30']['rating']}, Reviews: {feedback['30']['reviewsCount']}")
        print(f"90 Days Rating: {feedback['90']['rating']}, Reviews: {feedback['90']['reviewsCount']}")
    else:
        print("Error fetching seller review:", seller_review)
except requests.exceptions.RequestException as e:
    print("Request failed:", e)
except KeyError as e:
    print("KeyError:", e)
    print("Response Structure:", seller_review)

Response Example


{
  "data": {
    "marketplace": {
      "ATVPDKIKX0DER": {
        "last5Reviews": [
          {
            "dateRated": "By gary kraus on June 5, 2025.",
            "reviewText": "great",
            "starRating": "5 out of 5 stars"
          },
          {
            "dateRated": "By Amazon Customer on June 5, 2025.",
            "reviewText": "Ok",
            "starRating": "5 out of 5 stars"
          },
          {
            "dateRated": "By Graciela Castañeda on May 21, 2025.",
            "reviewText": "Excelente",
            "starRating": "5 out of 5 stars"
          }
        ],
        "sellerFeedback": {
          "30": {
            "rating": "3.3",
            "reviewsCount": "7"
          },
          "90": {
            "rating": "3.6",
            "reviewsCount": "30"
          },
          "365": {
            "rating": "3.9",
            "reviewsCount": "114"
          },
          "lifetime": {
            "rating": "4.5",
            "reviewsCount": "1,535"
          }
        }
      }
    },
    "sellerId": "A1CWSGXIR635I6"
  },
  "success": true
}

Enhancing Your Analysis with Additional SellerMagnetAPI Endpoints

To further refine your competitive analysis, consider integrating other SellerMagnetAPI endpoints:

Practical Use Cases

  • Inventory Replenishment: Monitor competitor stock levels to anticipate demand spikes and optimize your replenishment strategy.
  • Pricing Adjustments: Identify opportunities to adjust pricing based on competitor availability and pricing strategies.
  • Marketing Campaigns: Target marketing efforts towards products where competitors are experiencing stockouts.
  • Product Development: Identify gaps in the market by analyzing competitor product offerings and inventory levels.

Advanced Features

  • Data Persistence: Store retrieved data in a database for historical analysis and trend identification.
  • Alerting System: Implement an alerting system that notifies you when competitor inventory levels drop below a certain threshold.
  • Visualization: Create dashboards to visualize competitor inventory data and trends.

Legal Compliance and Ethical Considerations

When conducting competitor analysis, it's crucial to adhere to ethical practices and legal guidelines. Ensure that you're not violating any terms of service or scraping data in a way that could harm the target website. SellerMagnetAPI is designed to provide data in a compliant manner, but it's your responsibility to use it ethically.

Conclusion

Building a Python tool for Amazon competitor inventory analysis with SellerMagnetAPI empowers businesses to gain a competitive edge through data-driven insights. By leveraging the API's comprehensive data and integrating it into a custom tool, you can optimize your inventory management, pricing strategies, and marketing efforts. SellerMagnetAPI offers a reliable, scalable, and enterprise-grade solution for all your Amazon data needs. Get started today and unlock the power of data to drive your business forward. Don't forget to check our Pricing plans and Try Free!

Back to Blog