Building a Python Tool for Amazon Sales Forecasting
For businesses operating on Amazon, accurate sales forecasting is critical for optimizing inventory, managing resources, and staying ahead of the competition. This blog post explores how to build a Python tool for Amazon sales forecasting using the SellerMagnet API, an enterprise-grade solution for accessing real-time Amazon data. By leveraging SellerMagnet’s robust API, businesses can gain valuable insights into product performance, market trends, and competitive landscapes, empowering data-driven decision-making.
Why Sales Forecasting Matters for Amazon Businesses
Effective sales forecasting on Amazon provides several key benefits:
- Inventory Optimization: Predict demand to avoid stockouts and excess inventory.
- Competitive Analysis: Monitor competitor performance and adjust strategies accordingly.
- Resource Allocation: Plan marketing campaigns, staffing, and logistics based on anticipated sales.
- Market Research: Identify emerging trends and opportunities in the Amazon marketplace.
SellerMagnet's API delivers the data needed to achieve these benefits.
Leveraging SellerMagnet's API for Sales Forecasting
SellerMagnet offers a suite of powerful API endpoints that provide access to a wealth of Amazon data. Let's explore some key endpoints and how they can be used for sales forecasting.
1. Amazon Product Statistics
The Amazon Product Statistics endpoint provides detailed statistics for a specific Amazon product, including sales rank and review counts. This historical data is invaluable for identifying trends and patterns that can be used to predict future sales.
Endpoint: /amazon-product-statistics
Method: GET
Parameters:
asin
(required): Product ASIN (e.g., "B08N5WRWNW")marketplaceId
(required): Marketplace ID (e.g., "A1PA6795UKMFR9")api_key
(required): Your API keygraphs
(optional): Generate visually graphs for history data
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-product-statistics?asin=B08N5WRWNW&marketplaceId=A1PA6795UKMFR9&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"data": {
"asin": "B0CLTBHXWQ",
"amazonPrice": 41800,
"bestSellerRank": 15,
"buyBoxPrice": 41800,
"buyBoxFulfillment": "FBM",
"buyBoxSellerIdHistory": [
[
"2025-06-14 17:08:00",
"A2I59UVTUWUFH0"
]
],
"salesRankHistory": [
[
"2025-06-14 01:58:00",
15
]
],
"trackingSince": "2023-12-30",
"graphs": {
"priceTrend": [
{
"timestamp": "2025-06-14T00:00:00",
"price": 41800
}
],
"rankTrend": [
{
"timestamp": "2025-06-14T00:00:00",
"rank": 15
}
]
},
"metadata": {
"category": "Videogiochi",
"lastUpdated": "2025-06-14T17:08:00"
}
}
}
2. Amazon ASIN Converter
The Amazon ASIN Converter endpoint allows you to convert between ASIN and EAN identifiers. This is useful for cross-referencing product data from different sources and ensuring consistency in your forecasting models.
Endpoint: /amazon-asin-converter
Method: GET
Parameters:
asin
(required): ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")marketplaceId
(required): Marketplace ID (e.g., "A1PA6795UKMFR9")conversion_direction
(required): Conversion direction: "asin-to-ean" or "ean-to-asin"api_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-asin-converter?asin=B08N5WRWNW&marketplaceId=A1PA6795UKMFR9&conversion_direction=asin-to-ean&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"data": {
"asin": "B0CLTBHXWQ",
"eanList": [
"0711719577294"
],
"listedSince": "2023-12-30 01:00:00",
"productTitle": "Playstation 5 Console Edizione Digital Slim"
}
}
3. Get Amazon Seller Review
Understanding seller performance can impact product sales. The Get Amazon Seller Review endpoint provides insights into seller ratings and reviews, which can be used to assess the reliability and trustworthiness of sellers offering the products you are tracking.
Endpoint: /amazon-seller-review
Method: GET
Parameters:
sellerId
(required): Seller ID (e.g., "A1B2C3D4E5F6G7")marketplaceId
(required): Marketplace ID (e.g., "A1PA6795UKMFR9")api_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-seller-review?sellerId=A1CWSGXIR635I6&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"data": {
"marketplace": {
"ATVPDKIKX0DER": {
"last5Reviews": [
{
"dateRated": "By gary kraus on June 5, 2025.",
"reviewText": "great",
"starRating": "5 out of 5 stars"
}
],
"sellerFeedback": {
"30": {
"rating": "3.3",
"reviewsCount": "7"
},
"lifetime": {
"rating": "4.5",
"reviewsCount": "1,535"
}
}
}
},
"sellerId": "A1CWSGXIR635I6"
}
}
4. Get Amazon Product
The Get Amazon Product endpoint provides comprehensive product information, including details, descriptions, and categories. This data is useful for understanding the features and attributes of the products you are forecasting.
Endpoint: /amazon-product-lookup
Method: GET
Parameters:
asin
(required): Product ASIN (e.g., 'B08N5WRWNW')marketplaceId
(required): Marketplace ID (e.g., 'A1PA6795UKMFR9')api_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-product-lookup?asin=B0CL61F39H&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"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"
},
"asin": "B0CL61F39H",
"bestsellerRanks": {
"main_category": {
"name": "Video Games",
"rank": 31
}
},
"bulletPoints": [
"Model Number CFI-2000",
"Includes DualSense Wireless Controller, 1TB SSD, Disc Drive"
],
"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"
}
],
"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"
],
"details": {
"ASIN": "B0CL61F39H",
"Batteries": "1 Lithium Ion batteries required. (included)",
"Date First Available": "December 10, 2023",
"Item Weight": "10.6 pounds"
},
"hasAPlusContent": true,
"images": [
"https://m.media-amazon.com/images/I/41ECK5cY-2L._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
m5 console (slim)",
"variations": [
{
"asin": "B0F6968Y5G",
"attributes": {
"Pattern Name": "PS5 w/ Black Ops Bundle",
"Style": "PlayStation
m5 Digital Edition (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"
]
}
}
}
5. Get Amazon Product Offers
The Get Amazon Product Offers endpoint lists offers for a product, including price, seller, condition, and inventory details. Tracking these offers over time can provide insights into pricing trends and competitive dynamics.
Endpoint: /amazon-product-offers
Method: GET
Parameters:
asin
(required): Product ASIN (e.g., 'B08N5WRWNW')marketplaceId
(required): Marketplace ID (e.g., 'A1PA6795UKMFR9')geo_location
(optional): Detailed Geo Location ZIP CODEapi_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-product-offers?asin=B0CL61F39H&marketplaceId=ATVPDKIKX0DER&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"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
m5 console (slim)"
}
}
6. Get Amazon Bestsellers
The Get Amazon Bestsellers endpoint fetches top-selling products in a specific category. Tracking bestseller rankings over time can help identify products with sustained demand and strong sales potential.
Endpoint: /amazon-bestsellers
Method: GET
Parameters:
category_id
(required): Category ID (e.g., "electronics")marketplaceId
(required): Marketplace ID (e.g., "A1PA6795UKMFR9")count
(optional): Number of results (max 50, default 30)api_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-bestsellers?category_id=electronics&marketplaceId=A1PA6795UKMFR9&api_key=YOUR_API_KEY'
Example Response:
{
"category": "electronics",
"bestsellers": [
{
"asin": "B08N5WRWNW",
"rank": 1,
"title": "Top Product"
}
]
}
7. Amazon Product Search Estimated Sells
The Amazon Product Search Estimated Sells endpoint provides estimated sales data for an Amazon product by ASIN. This endpoint is crucial for understanding the sales volume and market demand for specific products.
Endpoint: /amazon-product-search-estimated-sells
Method: GET
Parameters:
asin
(required): Product ASIN (e.g., "B08N5WRWNW")marketplaceId
(required): Marketplace ID (e.g., "A1PA6795UKMFR9")api_key
(required): Your API key
Example Request:
curl --location --request GET 'https://sellermagnet-api.com/amazon-product-search-estimated-sells?asin=B08N5WRWNW&marketplaceId=A1PA6795UKMFR9&api_key=YOUR_API_KEY'
Example Response:
{
"success": true,
"data": {
"asin": "B08N5WRWNW",
"estimated_monthly_sales": 121
}
}
Building the Python Forecasting Tool
Here’s a basic outline of how you can build a Python tool using SellerMagnet’s API:
- Set up your environment: Install the necessary Python libraries (e.g.,
requests
,pandas
,scikit-learn
). - Fetch historical data: Use the Amazon Product Statistics endpoint to retrieve historical sales rank, price, and review data for your products of interest.
- Data cleaning and preprocessing: Clean and format the data for analysis, handling missing values and outliers.
- Feature engineering: Create relevant features such as moving averages, seasonal indices, and trend indicators.
- Model selection: Choose an appropriate forecasting model (e.g., ARIMA, Exponential Smoothing, Regression).
- Model training: Train the model using the historical data.
- Forecast generation: Generate sales forecasts for the desired time horizon.
- Evaluation and refinement: Evaluate the model’s performance and refine it as needed.
Python Code Example (Illustrative):
import requests
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
# Function to fetch product statistics from SellerMagnet API
def get_product_stats(asin, marketplace_id, api_key):
url = f'https://sellermagnet-api.com/amazon-product-statistics?asin={asin}&marketplaceId={marketplace_id}&api_key={api_key}'
response = requests.get(url)
data = response.json()
if data['success']:
return data['data']
else:
print(f"Error fetching data for ASIN: {asin}")
return None
# Example usage
asin = 'B08N5WRWNW'
marketplace_id = 'A1PA6795UKMFR9'
api_key = 'YOUR_API_KEY'
product_data = get_product_stats(asin, marketplace_id, api_key)
if product_data:
# Extract sales rank history
sales_rank_history = product_data['salesRankHistory']
# Convert to pandas DataFrame
df = pd.DataFrame(sales_rank_history, columns=['timestamp', 'sales_rank'])
df['timestamp'] = pd.to_datetime(df['timestamp'])
df.set_index('timestamp', inplace=True)
# Basic linear regression model (example)
X = df.index.map(pd.Timestamp.toordinal).values.reshape(-1, 1)
y = df['sales_rank'].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression()
model.fit(X_train, y_train)
# Predict future sales rank
future_dates = pd.to_datetime(['2025-07-01', '2025-07-08', '2025-07-15'])
future_X = [date.toordinal() for date in future_dates]
future_X = pd.DataFrame(future_X)
predicted_sales_rank = model.predict(future_X)
print("Predicted Sales Rank:")
for i, date in enumerate(future_dates):
print(f"{date.strftime('%Y-%m-%d')}: {predicted_sales_rank[i]:.2f}")
Note: This is a simplified example for demonstration purposes. Real-world sales forecasting models may require more sophisticated techniques and data preprocessing.
Practical Use Cases
- Seasonal Demand Forecasting: Identify seasonal patterns in sales data to optimize inventory levels during peak seasons (e.g., holidays, back-to-school).
- New Product Launch Forecasting: Predict initial sales volumes for new products based on historical data from similar products.
- Promotional Campaign Planning: Forecast the impact of promotional campaigns on sales to optimize timing and budget allocation.
Conclusion
By building a Python tool that leverages SellerMagnet's API, Amazon businesses can gain a competitive edge through accurate and data-driven sales forecasting. The ability to predict future sales trends enables better inventory management, resource allocation, and strategic decision-making. Explore SellerMagnet’s Documentation and Pricing to get started today.
Consider leveraging our DataPipeline features to automate the process of fetching and processing data from SellerMagnet's API, ensuring your forecasting models are always up-to-date. This will allow you to focus on analyzing the insights and making informed business decisions.