Building a Python Dashboard for Amazon Bestseller Monitoring
For businesses navigating the competitive Amazon marketplace, staying ahead means having access to timely, accurate data. Monitoring bestseller ranks, pricing trends, and seller performance is crucial for competitive analysis, inventory management, and making informed strategic decisions. This post will guide you through building a Python dashboard to monitor Amazon bestsellers using the SellerMagnet API. This dashboard will empower you with the insights needed to optimize your Amazon business.
Why Build a Custom Dashboard?
While various tools exist, a custom dashboard offers unparalleled flexibility and control. You can tailor it to your specific needs, track the exact metrics that matter to you, and integrate it seamlessly with your existing systems. With SellerMagnet's enterprise-grade Amazon data API, creating such a dashboard is easier than you might think.
Prerequisites
Before you begin, ensure you have the following:
- Python 3.6+ installed
- A SellerMagnet API key (available at https://sellermagnet-api.com after Try Free)
- Required Python libraries:
requests
,pandas
,plotly
,dash
Install the necessary libraries using pip:
pip install requests pandas plotly dash
Step 1: Fetching Amazon Product Data with SellerMagnet API
The core of our dashboard lies in fetching data from Amazon using the SellerMagnet API. We'll focus on the Amazon Product Statistics endpoint to retrieve key metrics like sales rank and price history.
Here's a Python function to retrieve product statistics:
import requests
import pandas as pd
def get_product_stats(asin, marketplace_id, api_key):
"""Fetches Amazon product statistics using SellerMagnet API."""
url = "https://sellermagnet-api.com/amazon-product-statistics"
params = {
"asin": asin,
"marketplaceId": marketplace_id,
"api_key": api_key,
"graphs": "true" # Request graph URLs for visualization
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
data = response.json()
if data["success"]:
return data["data"]
else:
print(f"Error fetching data for ASIN {asin}: {data.get('errors')}")
return None
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
Example Usage:
asin = "B0CLTBHXWQ" # Example ASIN
marketplace_id = "APJ6JRA9NG5V4" # Example: Amazon.it
api_key = "YOUR_API_KEY" # Replace with your actual API key
product_data = get_product_stats(asin, marketplace_id, api_key)
if product_data:
print(f"Product Title {product_data.get('productTitle')}")
print(f"Current Bestseller Rank: {product_data['bestSellerRank']}")
# Access historical sales rank data
sales_rank_history = product_data['salesRankHistory']
#Access graph URLs
price_trend_graph = product_data['graphs']['priceTrend'] if product_data['graphs'] else None
Example Response:
{
"success": true,
"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
]
]
}
}
}
Step 2: Structuring the Data with Pandas
Pandas is essential for data manipulation and analysis. Let's create a Pandas DataFrame to store and process the data retrieved from the SellerMagnet API.
import pandas as pd
def create_dataframe(product_data):
"""Creates a Pandas DataFrame from the product data."""
if not product_data:
return pd.DataFrame()
# Extract relevant data for the DataFrame
asin = product_data['asin']
product_title = product_data.get('productTitle', 'N/A') #Handle missing product title
best_seller_rank = product_data['bestSellerRank']
sales_rank_history = product_data['salesRankHistory']
# Convert sales rank history to a DataFrame
df = pd.DataFrame(sales_rank_history, columns=['Timestamp', 'Sales Rank'])
df['Timestamp'] = pd.to_datetime(df['Timestamp'])
df['ASIN'] = asin
df['Product Title'] = product_title
df['Best Seller Rank'] = best_seller_rank
return df
Example Usage:
df = create_dataframe(product_data)
if not df.empty:
print(df.head())
else:
print("No data to display.")
Step 3: Visualizing Data with Plotly
Plotly is a powerful library for creating interactive visualizations. We'll use it to create a line chart of the product's sales rank history.
import plotly.express as px
def create_sales_rank_chart(dataframe):
"""Creates an interactive sales rank chart using Plotly."""
if dataframe.empty:
return {}
fig = px.line(dataframe,
x="Timestamp",
y="Sales Rank",
title=f"Sales Rank History for {dataframe['Product Title'].iloc[0]} ({dataframe['ASIN'].iloc[0]})",
labels={"Timestamp": "Date", "Sales Rank": "Rank"})
fig.update_layout(yaxis_range=[dataframe['Sales Rank'].max() * 1.1, 0]) #Invert y-axis for better readability
return fig.to_dict()
Example Usage:
chart = create_sales_rank_chart(df)
Step 4: Building the Dashboard with Dash
Dash is a Python framework for building web applications, especially dashboards. It integrates seamlessly with Plotly for creating interactive data visualizations.
import dash
import dash_core_components as dcc
import dash_html_components as html
# Initialize the Dash app
app = dash.Dash(__name__)
# Define the layout of the dashboard
def create_dashboard_layout(chart_data):
return html.Div(children=[
html.H1(children='Amazon Bestseller Monitoring Dashboard'),
html.Div(children='''
Monitoring product performance on Amazon.
'''),
dcc.Graph(
id='sales-rank-chart',
figure=chart_data
)
])
# Main function to run the dashboard
def run_dashboard(chart_data):
app.layout = create_dashboard_layout(chart_data)
app.run_server(debug=True)
Example Usage:
if __name__ == '__main__':
asin = "B0CLTBHXWQ" # Example ASIN
marketplace_id = "APJ6JRA9NG5V4" # Example: Amazon.it
api_key = "YOUR_API_KEY" # Replace with your actual API key
product_data = get_product_stats(asin, marketplace_id, api_key)
if product_data:
df = create_dataframe(product_data)
if not df.empty:
chart_data = create_sales_rank_chart(df)
run_dashboard(chart_data)
else:
print("No data to display.")
else:
print("Failed to fetch product data.")
Step 5: Enhancements and Further Development
This is just a basic framework. Here are some ways to enhance your dashboard:
- Multiple ASIN Tracking: Allow users to input multiple ASINs and display their data simultaneously.
- Real-time Updates: Implement a DataPipeline to fetch data periodically and update the dashboard in real-time.
- Advanced Analytics: Incorporate more advanced analytics, such as moving averages, trend lines, and anomaly detection.
- Seller Monitoring: Use the Amazon Seller Review endpoint to track seller performance and feedback.
- Offer Analysis: Utilize the Amazon Product Offers endpoint to monitor pricing and availability from different sellers.
- Geolocation: Pass `geo_location` parameter to Amazon Product Offers and Amazon Search
Leveraging Other SellerMagnet API Endpoints
SellerMagnet offers a suite of powerful APIs beyond product statistics. Consider incorporating these into your dashboard:
- Amazon Product Lookup: Retrieve detailed product information.
- Amazon Bestsellers: Track top-selling products in specific categories.
- Amazon ASIN/ISBN/EAN Converter: Convert product identifiers.
- Amazon Product Estimate Sales: Estimate product sales volume.
Conclusion
Building a Python dashboard for Amazon bestseller monitoring is a powerful way to gain a competitive edge. By leveraging the SellerMagnet API, you can automate data collection, visualize key metrics, and make informed decisions to optimize your Amazon business. Start building your dashboard today and unlock the full potential of your Amazon data!