Building a Python Dashboard for Amazon Sales Metrics with SellerMagnetAPI
For Amazon businesses and market analysts, real-time data is the lifeblood of strategic decision-making. This blog post guides you through building a powerful Python dashboard to visualize and analyze your Amazon sales metrics using the SellerMagnetAPI. This dashboard will provide critical insights for competitive analysis, inventory management, and market research. Let’s dive in!
Why Build a Custom Dashboard?
While Amazon provides some built-in analytics, a custom dashboard offers several advantages:
- Granular Control: Tailor the metrics and visualizations to your specific business needs.
- Data Integration: Combine Amazon data with other sources for a holistic view.
- Automation: Automate data retrieval and dashboard updates for efficiency.
- Competitive Advantage: Gain deeper insights and react faster to market changes.
Prerequisites
Before we start, ensure you have the following:
- A SellerMagnetAPI account and API key.
- Python 3.6+ installed.
- Required Python libraries:
pandas
,plotly
,requests
, anddash
. Install them using pip:
pip install pandas plotly requests dash
Step 1: Setting Up Your Python Environment
Create a new Python file (e.g., amazon_dashboard.py
) and import the necessary libraries:
import pandas as pd
import plotly.express as px
import requests
import dash
import dash_core_components as dcc
import dash_html_components as html
Step 2: Fetching Amazon Product Statistics
We'll use the Amazon Product Statistics endpoint to retrieve sales rank and review counts for a specific ASIN. This is vital for monitoring product performance and spotting trends.
def get_product_stats(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" # Enable graph data
}
response = requests.get(url, params=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
# Example usage
asin = "B08N5WRWNW" # Replace with your desired ASIN
marketplace_id = "ATVPDKIKX0DER" # Replace with your Marketplace ID (US)
api_key = "YOUR_API_KEY" # Replace with your SellerMagnetAPI API key
product_data = get_product_stats(asin, marketplace_id, api_key)
if product_data["success"]:
print("Successfully fetched product statistics.")
print(product_data["data"].keys())
else:
print("Error fetching product statistics:", product_data.get("errors", "Unknown error"))
Here's what the API response looks like:
{
"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 3: Creating DataFrames for Visualization
Use pandas
to structure the data for plotting:
def create_dataframe(product_data):
# Sales Rank History
sales_rank_data = product_data["data"]["stats"]["salesRankHistory"]
df_sales_rank = pd.DataFrame(sales_rank_data, columns=["Timestamp", "Sales Rank"])
df_sales_rank["Timestamp"] = pd.to_datetime(df_sales_rank["Timestamp"])
# Rating History
rating_data = product_data["data"]["stats"]["productRatingHistory"]
df_rating = pd.DataFrame(rating_data, columns=["Timestamp", "Rating"])
df_rating["Timestamp"] = pd.to_datetime(df_rating["Timestamp"])
return df_sales_rank, df_rating
df_sales_rank, df_rating = create_dataframe(product_data)
Step 4: Building Interactive Charts with Plotly
Create interactive charts for sales rank and rating using plotly.express
:
def create_sales_rank_chart(df_sales_rank):
fig_sales_rank = px.line(
df_sales_rank,
x="Timestamp",
y="Sales Rank",
title="Sales Rank Over Time",
labels={"Sales Rank": "Sales Rank", "Timestamp": "Date"},
)
fig_sales_rank.update_layout(xaxis_title="Date", yaxis_title="Sales Rank")
return fig_sales_rank
def create_rating_chart(df_rating):
fig_rating = px.line(
df_rating,
x="Timestamp",
y="Rating",
title="Rating Over Time",
labels={"Rating": "Rating", "Timestamp": "Date"},
)
fig_rating.update_layout(xaxis_title="Date", yaxis_title="Rating")
return fig_rating
fig_sales_rank = create_sales_rank_chart(df_sales_rank)
fig_rating = create_rating_chart(df_rating)
Step 5: Constructing the Dashboard with Dash
Use Dash to create an interactive web-based dashboard:
app = dash.Dash(__name__)
app.layout = html.Div([
html.H1("Amazon Sales Metrics Dashboard", style={'textAlign': 'center'}),
dcc.Graph(id='sales-rank-chart', figure=fig_sales_rank),
dcc.Graph(id='rating-chart', figure=fig_rating)
])
if __name__ == '__main__':
app.run_server(debug=True)
Step 6: Running the Dashboard
Save the file and run it from your terminal:
python amazon_dashboard.py
Open your web browser and navigate to http://127.0.0.1:8050/
to view your interactive dashboard.
Advanced Use Cases and Further Exploration
This is just a starting point. You can extend this dashboard to include:
- Multiple ASINs: Compare metrics across different products.
- Additional Metrics: Integrate data from Amazon Product Offers, Amazon Product Lookup and Amazon Seller Review.
- Automated Updates: Use DataPipeline to schedule regular data updates.
- Geolocation Data: Analyze sales performance by region using the
geo_location
parameter in the Amazon Product Offers and Amazon Search endpoints. - Competitor Analysis: Track competitor ASINs to identify market trends.
Consider integrating additional SellerMagnetAPI endpoints like:
- Amazon ASIN/ISBN/EAN Converter: Ensure accurate product identification.
- Amazon Product Estimate Sales: Get insight into estimated monthly sales volume.
- Amazon Bestsellers: See the top-selling products in any category.
Conclusion
Building a custom Python dashboard using the SellerMagnetAPI empowers you with the data-driven insights necessary to thrive in the competitive Amazon marketplace. By leveraging the flexibility and power of Python, you can create a tailored solution that provides a significant competitive advantage. Start building your dashboard today and unlock the full potential of your Amazon data!
Ready to get started? Sign up for a free trial at SellerMagnetAPI and explore the possibilities!