Building a Python Script for Amazon Deal Monitoring with SellerMagnetAPI
In today's competitive e-commerce landscape, staying ahead of the curve is crucial for Amazon businesses and market analysts. Monitoring Amazon deals in real-time can provide invaluable insights for competitive analysis, inventory management, and market research. This blog post will guide you through building a Python script using SellerMagnetAPI to automate this process, enabling you to make data-driven decisions and optimize your business strategies.
Why Monitor Amazon Deals?
Amazon deal monitoring provides several key benefits:
- Competitive Analysis: Track competitor pricing and promotional strategies.
- Inventory Management: Identify trending products and adjust inventory levels accordingly.
- Market Research: Understand market dynamics and consumer behavior.
- Real-time Alerts: Receive immediate notifications about significant price drops or new deals.
Introducing SellerMagnetAPI
SellerMagnetAPI is an enterprise-grade Amazon data API designed to provide businesses with reliable and comprehensive data. Its robust infrastructure and extensive data coverage make it an ideal solution for building sophisticated Amazon monitoring tools. This post focuses exclusively on using SellerMagnetAPI, ensuring a focused and practical approach to building your Amazon deal monitoring script.
Setting up the Environment
Before diving into the code, ensure you have the following prerequisites:
- Python 3.6+ installed.
- A SellerMagnetAPI API key. Sign up for a free trial to get started.
- Required Python libraries:
requests
.
Install the requests
library using pip:
pip install requests
Building the Python Script
We will create a Python script that fetches product data and checks for deals using the Amazon Product Offers endpoint and the Amazon Product Statistics endpoint.
Step 1: Import Libraries and Set Up Credentials
First, import the necessary libraries and set up your API key and the ASIN you want to monitor.
import requests
import json
API_KEY = 'YOUR_API_KEY' # Replace with your actual API key
ASIN = 'B0CL61F39H'
MARKETPLACE_ID = 'ATVPDKIKX0DER'
Step 2: Define the Function to Fetch Product Offers
Create a function to fetch product offer data from SellerMagnetAPI's Amazon Product Offers endpoint.
def get_product_offers(asin, marketplace_id, api_key):
url = 'https://sellermagnet-api.com/amazon-product-offers'
params = {
'asin': asin,
'marketplaceId': marketplace_id,
'api_key': api_key
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
Step 3: Analyze the Response for Deals
Implement logic to analyze the API response and identify if a deal is available.
def analyze_offers_for_deals(offers_data):
if not offers_data or not offers_data['success']:
print("Failed to retrieve offers or request was unsuccessful.")
return False
offers = offers_data['data']['offers']
# Simple logic: Check if any offer is below a certain threshold (e.g., 10% off the buy box price)
buy_box_price = offers_data['data']['buyBox']['totalPrice']
threshold = buy_box_price * 0.9 # 10% discount
for offer in offers:
if offer['totalPrice'] <= threshold:
print(f"Deal found! Offer price: {offer['totalPrice']}, Seller: {offer['sellerName']}")
return True
print("No significant deals found.")
return False
Step 4: Define the Function to Fetch Product Statistics
Create a function to fetch product statistic data from SellerMagnetAPI 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
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
Step 5: Analyze the Response for Sales Rank and Buy Box Fulfillment
Implement logic to analyze the API response and extract key statistics.
def analyze_product_statistics(statistics_data):
if not statistics_data or not statistics_data['success']:
print("Failed to retrieve statistics or request was unsuccessful.")
return
data = statistics_data['data']
sales_rank = data['bestSellerRank']
buy_box_fulfillment = data['buyBoxFulfillment']
print(f"Sales Rank: {sales_rank}")
print(f"Buy Box Fulfillment: {buy_box_fulfillment}")
# You can add more logic here to trigger alerts based on sales rank changes
Step 6: Main Execution Block
Combine the functions to fetch data and analyze it.
if __name__ == '__main__':
offers_data = get_product_offers(ASIN, MARKETPLACE_ID, API_KEY)
if offers_data:
analyze_offers_for_deals(offers_data)
statistics_data = get_product_statistics(ASIN, MARKETPLACE_ID, API_KEY)
if statistics_data:
analyze_product_statistics(statistics_data)
Complete Script
import requests
import json
API_KEY = 'YOUR_API_KEY' # Replace with your actual API key
ASIN = 'B0CL61F39H'
MARKETPLACE_ID = 'ATVPDKIKX0DER'
def get_product_offers(asin, marketplace_id, api_key):
url = 'https://sellermagnet-api.com/amazon-product-offers'
params = {
'asin': asin,
'marketplaceId': marketplace_id,
'api_key': api_key
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
def analyze_offers_for_deals(offers_data):
if not offers_data or not offers_data['success']:
print("Failed to retrieve offers or request was unsuccessful.")
return False
offers = offers_data['data']['offers']
# Simple logic: Check if any offer is below a certain threshold (e.g., 10% off the buy box price)
buy_box_price = offers_data['data']['buyBox']['totalPrice']
threshold = buy_box_price * 0.9 # 10% discount
for offer in offers:
if offer['totalPrice'] <= threshold:
print(f"Deal found! Offer price: {offer['totalPrice']}, Seller: {offer['sellerName']}")
return True
print("No significant deals found.")
return False
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
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
def analyze_product_statistics(statistics_data):
if not statistics_data or not statistics_data['success']:
print("Failed to retrieve statistics or request was unsuccessful.")
return
data = statistics_data['data']
sales_rank = data['bestSellerRank']
buy_box_fulfillment = data['buyBoxFulfillment']
print(f"Sales Rank: {sales_rank}")
print(f"Buy Box Fulfillment: {buy_box_fulfillment}")
# You can add more logic here to trigger alerts based on sales rank changes
if __name__ == '__main__':
offers_data = get_product_offers(ASIN, MARKETPLACE_ID, API_KEY)
if offers_data:
analyze_offers_for_deals(offers_data)
statistics_data = get_product_statistics(ASIN, MARKETPLACE_ID, API_KEY)
if statistics_data:
analyze_product_statistics(statistics_data)
Example Response for Amazon Product Offers
{
"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
}
],
"productLink": "https://www.amazon.com/dp/B0CL61F39H",
"productMainImage": "https://m.media-amazon.com/images/I/31kTNmpm6vL.jpg",
"productTitle": "PlayStation
Example Response for Amazon Product Statistics
{
"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
}
Extending the Script
This script provides a basic framework for monitoring Amazon deals. You can extend it further by:
- Implementing email or SMS alerts using libraries like
smtplib
or services like Twilio. - Scheduling the script to run automatically using cron jobs or DataPipeline.
- Adding more sophisticated deal detection logic, such as tracking price history and identifying seasonal trends using Amazon Product Statistics and Amazon Product Bestseller History.
- Integrating with other data sources to enrich your analysis.
- Utilizing Amazon Search and Amazon Bestsellers endpoints to discover new products and categories to monitor.
- Leveraging Amazon Product Estimate Sales to estimate the sales volume of different products.
Leveraging Other SellerMagnetAPI Endpoints
SellerMagnetAPI offers a range of endpoints that can enhance your Amazon monitoring capabilities:
- Amazon Product Lookup: Retrieve detailed product information, including descriptions, features, and images.
- Amazon Seller Review: Monitor seller feedback and ratings to assess the credibility of sellers offering deals.
- Amazon ASIN Converter: Convert between ASIN and EAN identifiers for comprehensive product tracking using Amazon ASIN/ISBN/EAN Converter.
Conclusion
By building a Python script with SellerMagnetAPI, you can automate Amazon deal monitoring and gain a competitive edge. The provided script offers a foundation for creating a customized solution tailored to your specific business needs. Explore the SellerMagnetAPI Documentation and Code Examples for more advanced features and integrations. Start your free trial today and unlock the power of Amazon data!