Building a Python Tool for Amazon Competitor Price Trend Analysis with SellerMagnetAPI
In today's dynamic e-commerce landscape, Amazon businesses and market analysts need robust tools to monitor competitor pricing strategies effectively. Understanding price trends allows for informed decision-making in areas like competitive analysis, inventory management, and market research. This post demonstrates how to build a Python-based tool leveraging the SellerMagnetAPI to analyze Amazon competitor price trends.
Why Use SellerMagnetAPI for Price Trend Analysis?
The SellerMagnetAPI provides enterprise-grade Amazon data, enabling businesses to access real-time and historical pricing information. By utilizing the API, you can automate data collection, streamline analysis, and gain valuable insights into competitor strategies. Avoid the complexities and legal pitfalls of Amazon Web Scraping with a reliable and structured data source.
Prerequisites
Before diving into the code, ensure you have the following:
- A SellerMagnetAPI account and API key (Try Free).
- Python 3.6+ installed.
- The
requests
library:pip install requests
Step-by-Step Guide to Building the Tool
1. Setting Up the Python Environment
Create a new Python script (e.g., amazon_price_tracker.py
) and import the necessary libraries:
import requests
import json
2. Defining the Core Function to Fetch Product Statistics
The primary function will use the Amazon Product Statistics endpoint to retrieve historical price data for a given ASIN.
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,
"graphs": "true" # Enables price trend graphs
}
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
Here's an example request using the curl
command:
curl --get 'https://sellermagnet-api.com/amazon-product-statistics'
--data-urlencode 'asin=B0CLTBHXWQ'
--data-urlencode 'marketplaceId=APJ6JRA9NG5V4'
--data-urlencode 'api_key=YOUR_API_KEY'
--data-urlencode 'graphs=true'
Example 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
}
3. Analyzing Price Trends
Once you retrieve the data, you can analyze the salesRankHistory
and other fields to identify price trends. Here’s how to extract the price history:
def analyze_price_trend(data):
if data and data["success"] and data["data"] and data["data"]["stats"]["buyBoxPriceHistory"]:
price_history = data["data"]["stats"]["buyBoxPriceHistory"]
for timestamp, price in price_history:
print(f"Timestamp: {timestamp}, Price: {price / 100}") # Display price in dollars
else:
print("No price history available or invalid data.")
4. Integrating with Additional Endpoints
Enhance your analysis by incorporating other SellerMagnetAPI endpoints:
- Amazon Product Lookup: Get detailed product information.
- Amazon Product Offers: List current offers and seller details.
- Amazon Seller Review: Fetch review details for a specific seller to assess their credibility.
For example, use Amazon Product Lookup to get product details:
def get_product_details(asin, marketplace_id, api_key):
url = "https://sellermagnet-api.com/amazon-product-lookup"
params = {
"asin": asin,
"marketplaceId": marketplace_id,
"api_key": api_key
}
try:
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
Example Response:
{
"data": {
"productInfo": {
"additionalDetails": {
"ASIN": "B0CL61F39H",
"Batteries": "1 Lithium Ion batteries required. (included)",
"Best Sellers Rank": "Nr. 31 in Video Games Nr. 1 in PlayStation 5 Consoles",
"Customer Rating": "4.7 out of 5 stars",
"Date First Available": "December 10, 2023",
"Item Weight": "10.6 pounds",
"Item model number": "CFI-2015",
"Manufacturer": "Sony",
"Number of Reviews": "7,092 ratings",
"Product Dimensions": "14 x 17 x 7 inches; 10.6 Pounds",
"Release date": "December 10, 2023",
"Type of item": "Video Game"
},
"asin": "B0CL61F39H",
"bestsellerRanks": {
"main_category": {
"name": "Video Games",
"rank": 31
},
"subcategory": {
"name": "PlayStation",
"rank": 1
}
},
"bulletPoints": [
"Model Number CFI-2000",
"Includes DualSense Wireless Controller, 1TB SSD, Disc Drive, 2 Horizontal Stand Feet, HDMI Cable, AC power cord, USB cable, printed materials, ASTRO\u2019s PLAYROOM (Pre-installed game)",
"Vertical Stand sold separately"
],
"buyBoxInfo": {
"currencyCode": "USD",
"currencyName": "United States Dollar",
"currencySymbol": "$",
"price": 444.99,
"sellerId": "A3853PJW50SJG8"
},
"categories": {
"bestsellerCategory": [
{
"id": "20972781011",
"index": 1,
"name": "PlayStation 5",
"url": "https://www.amazon.com/b/ref=dp_bc_2?ie=UTF8&node=20972781011"
},
{
"id": "20972796011",
"index": 2,
"name": "Consoles",
"url": "https://www.amazon.com/b/ref=dp_bc_3?ie=UTF8&node=20972796011"
}
],
"rootCategory": {
"id": "468642",
"name": "Video Games",
"url": "https://www.amazon.com/computer-video-games-hardware-accessories/b/ref=dp_bc_1?ie=UTF8&node=468642"
}
},
"description": [
"Model Number CFI-2000",
"Includes DualSense Wireless Controller, 1TB SSD, Disc Drive, 2 Horizontal Stand Feet, HDMI Cable, AC power cord, USB cable, printed materials, ASTRO\u2019s PLAYROOM (Pre-installed game)",
"Vertical Stand sold separately",
"The PS5 console unleashes new gaming possibilities that you never anticipated. Experience lightning fast loading with an ultra-high speed SSD, deeper immersion with support for haptic feedback, adaptive triggers, and 3D Audio*, and an all-new generation of incredible PlayStation games. Lightning Speed - Harness the power of a custom CPU, GPU, and SSD with Integrated I/O that rewrite the rules of what a PlayStation console can do. Stunning Games - Marvel at incredible graphics and experience new PS5 features. Play a back catalog of supported PS4 games. Breathtaking Immersion - Discover a deeper gaming experience with support for haptic feedback, adaptive triggers, and 3D Audio technology. Vertical stand sold separately. *3D audio via built-in TV speakers or analog/USB stereo headphones. Set up and latest system software update required."
],
"details": {
"ASIN": "B0CL61F39H",
"Batteries": "1 Lithium Ion batteries required. (included)",
"Date First Available": "December 10, 2023",
"Item Weight": "10.6 pounds",
"Item model number": "CFI-2015",
"Manufacturer": "Sony",
"Platform": "PlayStation 5",
"Product Dimensions": "14 x 17 x 7 inches; 10.6 Pounds",
"Release date": "December 10, 2023",
"Type of item": "Video Game"
},
"hasAPlusContent": true,
"images": [
"https://m.media-amazon.com/images/I/41ECK5cY-2L._SL1000_.jpg",
"https://m.media-amazon.com/images/I/41srF-iY93L._SL1000_.jpg",
"https://m.media-amazon.com/images/I/41tVr19I3zL._SL1000_.jpg",
"https://m.media-amazon.com/images/I/41HMaO9jO3L._SL1000_.jpg",
"https://m.media-amazon.com/images/I/61e8hPmeoYL._SL1000_.jpg",
"https://m.media-amazon.com/images/I/61Gj1Kc5R5L._SL1000_.jpg",
"https://m.media-amazon.com/images/I/61r6PutKGwL._SL1000_.jpg",
"https://m.media-amazon.com/images/I/717Id5h1fhL._SL1000_.jpg"
],
"link": "https://www.amazon.com/dp/B0CL61F39H",
"listedSinceDate": "2023-12-10",
"mainImage": "https://m.media-amazon.com/images/I/31kTNmpm6vL.jpg",
"marketplaceId": "ATVPDKIKX0DER",
"reviews": {
"averageRating": 4.7,
"reviewSummary": "4.7 out of 5 stars",
"totalReviews": 7092
},
"title": "PlayStation\u00ae5 console (slim)",
"variations": [
{
"asin": "B0F6968Y5G",
"attributes": {
"Pattern Name": "PS5 w/ Black Ops Bundle",
"Style": "PlayStation\u00ae5 Digital Edition (slim)"
}
},
{
"asin": "B0CL5KNB9M",
"attributes": {
"Pattern Name": "PS5 Only",
"Style": "PlayStation\u00ae5 Digital Edition (slim)"
}
},
{
"asin": "B0CL61F39H",
"attributes": {
"Pattern Name": "PS5 Only",
"Style": "PlayStation\u00ae5 console (slim)"
}
},
{
"asin": "B0F691TJTP",
"attributes": {
"Pattern Name": "PS5 w/ Black Ops Bundle",
"Style": "PlayStation\u00ae5 console (slim)"
}
},
{
"asin": "B0FD54CGQ8",
"attributes": {
"Pattern Name": "PS5 w/ $100 PlayStation Store GC",
"Style": "PlayStation\u00ae5 Digital Edition (slim)"
}
},
{
"asin": "B0FD4WGVH5",
"attributes": {
"Pattern Name": "PS5 w/ $100 PlayStation Store GC",
"Style": "PlayStation\u00ae5 console (slim)"
}
}
],
"videos": [
"https://m.media-amazon.com/S/vse-vms-transcoding-artifact-us-east-1-prod/8af0ddf1-55f5-4e71-9463-39602c3edbae/default.jobtemplate.hls.m3u8",
"https://m.media-amazon.com/S/vse-vms-transcoding-artifact-us-east-1-prod/50938d5c-2a9b-427a-b766-21b7cd63502e/default.jobtemplate.hls.m3u8"
]
}
},
"success": true
}
5. Putting It All Together
Here’s the complete script:
import requests
import json
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,
"graphs": "true"
}
try:
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
def analyze_price_trend(data):
if data and data["success"] and data["data"] and data["data"]["stats"]["buyBoxPriceHistory"]:
price_history = data["data"]["stats"]["buyBoxPriceHistory"]
for timestamp, price in price_history:
print(f"Timestamp: {timestamp}, Price: {price / 100}") # Display price in dollars
else:
print("No price history available or invalid data.")
def get_product_details(asin, marketplace_id, api_key):
url = "https://sellermagnet-api.com/amazon-product-lookup"
params = {
"asin": asin,
"marketplaceId": marketplace_id,
"api_key": api_key
}
try:
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
if __name__ == "__main__":
asin = "B0CLTBHXWQ" # Example ASIN
marketplace_id = "APJ6JRA9NG5V4" # Example Marketplace ID
api_key = "YOUR_API_KEY" # Replace with your actual API key
product_data = get_product_statistics(asin, marketplace_id, api_key)
if product_data:
analyze_price_trend(product_data)
product_details = get_product_details(asin, marketplace_id, api_key)
if product_details:
print(json.dumps(product_details, indent=2))
Remember to replace "YOUR_API_KEY"
with your actual SellerMagnetAPI key.
Practical Use Cases
- Competitive Pricing Strategy: Monitor competitor price changes to adjust your pricing dynamically.
- Inventory Management: Predict future demand based on price trends and optimize inventory levels.
- Market Research: Identify market opportunities by analyzing pricing data across different product categories.
Enhancements and Further Exploration
- Data Visualization: Integrate libraries like
matplotlib
orseaborn
to visualize price trends. - Automated Reporting: Schedule the script to run periodically and generate reports. Use DataPipeline to automate.
- Geolocation: The Amazon Product Offers and Amazon Search endpoints supports geolocation, allowing you to fetch local prices for detailed analysis.
- ASIN Conversion: Use the Amazon ASIN/ISBN/EAN Converter to identify the ASIN from other identifiers.
- Estimated Sales: Use the Amazon Product Estimate Sales to estimate product sales volumes.
- Bestseller Analysis: Use the Amazon Bestsellers API to identify top products in each category and track their Amazon Product Bestseller History.
Conclusion
By following this guide, you can create a powerful Python tool for analyzing Amazon competitor price trends using the SellerMagnetAPI. This tool enables you to make data-driven decisions, optimize pricing strategies, and stay ahead in the competitive e-commerce market. Explore the Documentation and Code Examples for more insights.