SellerMagnetAPI Code Examples
Robust, production-ready code examples for integrating SellerMagnetAPI’s Amazon Scraper API, with JSON schemas, response examples, and snippets in multiple languages.
Endpoint Code Examples
Explore production-ready code examples for SellerMagnetAPI endpoints, including JSON schemas, response examples, and snippets in Python, Node.js, cURL, Ruby, Java, and Go.
Amazon Product Statistics
Use Case
Fetch detailed analytics for an Amazon product, such as sales trends and ranking, to inform pricing or inventory decisions. Ideal for market research tools.
Endpoint: /amazon-product-statistics
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
asin | text | Yes | Product ASIN (e.g., "B08N5WRWNW") |
marketplaceId | text | Yes | Marketplace ID (e.g., "A1PA6795UKMFR9") |
api_key | text | Yes | Your API key |
graphs | text | No | Generate visually graphs for history data |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "The response schema for Amazon item tracking data, including core item details, historical data, and optional extensions for graphs or metadata.",
"properties": {
"data": {
"additionalProperties": true,
"description": "Core data object with item tracking details and optional extensions.",
"properties": {
"amazonPrice": {
"description": "The current price of the item on Amazon (in cents), or null if not available.",
"type": [
"number",
"null"
]
},
"asin": {
"description": "The Amazon Standard Identification Number (ASIN) for the item, a 10-character alphanumeric identifier.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"bestSellerRank": {
"description": "The current best seller rank of the item in its category.",
"minimum": 1,
"type": "integer"
},
"buyBoxFulfillment": {
"description": "The fulfillment method for the Buy Box. Possible values: \u0027FBM\u0027 (Fulfilled by Merchant), \u0027FBA\u0027 (Fulfilled by Amazon), \u0027AMZ\u0027 (sold directly by Amazon).",
"enum": [
"FBM",
"FBA",
"AMZ"
],
"type": "string"
},
"buyBoxPrice": {
"description": "The current price of the item in the Buy Box (in cents).",
"minimum": 0,
"type": "integer"
},
"buyBoxSellerIdHistory": {
"description": "A chronological list of Buy Box seller changes, including timestamps and seller IDs.",
"items": {
"description": "A tuple of [timestamp, sellerId] representing a Buy Box seller change.",
"items": [
{
"description": "The timestamp when the Buy Box seller was recorded, in ISO 8601 format.",
"format": "date-time",
"type": "string"
},
{
"description": "The seller ID for the Buy Box at the given timestamp, or \u0027-1\u0027 if no seller held the Buy Box.",
"type": "string"
}
],
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"type": "array"
},
"graphs": {
"additionalProperties": true,
"description": "Placeholder for graph-related data, allowing flexibility for additional visualization types.",
"properties": {
"priceTrend": {
"description": "Data points for visualizing price trends over time.",
"items": {
"properties": {
"price": {
"description": "The price at the given timestamp (in cents).",
"minimum": 0,
"type": "integer"
},
"timestamp": {
"description": "The timestamp for the price data point.",
"format": "date-time",
"type": "string"
}
},
"required": [
"timestamp",
"price"
],
"type": "object"
},
"type": "array"
},
"rankTrend": {
"description": "Data points for visualizing sales rank trends over time.",
"items": {
"properties": {
"rank": {
"description": "The sales rank at the given timestamp.",
"minimum": 1,
"type": "integer"
},
"timestamp": {
"description": "The timestamp for the rank data point.",
"format": "date-time",
"type": "string"
}
},
"required": [
"timestamp",
"rank"
],
"type": "object"
},
"type": "array"
}
},
"type": [
"object",
"null"
]
},
"metadata": {
"additionalProperties": true,
"description": "Flexible metadata field for additional item or tracking information.",
"properties": {
"category": {
"description": "The Amazon category of the item (e.g., \u0027Electronics\u0027).",
"type": "string"
},
"lastUpdated": {
"description": "The timestamp when the data was last updated.",
"format": "date-time",
"type": "string"
}
},
"type": [
"object",
"null"
]
},
"salesRankHistory": {
"description": "A chronological list of the item\u0027s sales rank changes, including timestamps and rank values.",
"items": {
"description": "A tuple of [timestamp, salesRank] representing a sales rank record.",
"items": [
{
"description": "The timestamp when the sales rank was recorded, in ISO 8601 format.",
"format": "date-time",
"type": "string"
},
{
"description": "The sales rank of the item at the given timestamp.",
"minimum": 1,
"type": "integer"
}
],
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"type": "array"
},
"trackingSince": {
"description": "The date when tracking of the item began, in YYYY-MM-DD format.",
"format": "date",
"type": "string"
}
},
"required": [
"asin",
"amazonPrice",
"bestSellerRank",
"buyBoxPrice",
"buyBoxFulfillment",
"buyBoxSellerIdHistory",
"salesRankHistory",
"trackingSince"
],
"type": "object"
},
"errors": {
"description": "Optional list of error messages if the request was not fully successful. Not present in the provided document but included for robustness.",
"items": {
"properties": {
"code": {
"description": "A unique error code.",
"type": "string"
},
"message": {
"description": "A human-readable error message.",
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object"
},
"type": [
"array",
"null"
]
},
"success": {
"description": "Indicates whether the request to retrieve the item tracking data was successful.",
"type": "boolean"
}
},
"required": [
"success",
"data"
],
"title": "Amazon Item Tracking Response Schema",
"type": "object"
}
Response Example
{
"data": {
"asin": "B0CLTBHXWQ",
"buyBoxFulfillment": "FBM",
"buyBoxPrice": 41800,
"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,
"productTitle": "Playstation 5 Console Edizione Digital Slim",
"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
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_amazon_product_statistics(api_key, asin, marketplaceId, graphs, max_retries=3, timeout=10):
"""
Fetch data from Amazon Product Statistics endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
asin (text): Product ASIN (e.g., "B08N5WRWNW")
marketplaceId (text): Marketplace ID (e.g., "A1PA6795UKMFR9")
graphs (text): Generate visually graphs for history data
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-product-statistics"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"asin": asin,
"marketplaceId": marketplaceId,
"graphs": graphs,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Amazon Product Statistics")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Amazon Product Statistics after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_amazon_product_statistics(
api_key="YOUR_API_KEY",
asin="Product ASIN "B08N5WRWNW"",
marketplaceId="Marketplace ID "A1PA6795UKMFR9"",
graphs="graphs",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_amazon_product_statistics(api_key, asin, marketplaceId, graphs, max_retries: 3, timeout: 10)
# Fetch data from Amazon Product Statistics endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param asin [Text] Product ASIN (e.g., "B08N5WRWNW")
#
# @param marketplaceId [Text] Marketplace ID (e.g., "A1PA6795UKMFR9")
#
# @param graphs [Text] Generate visually graphs for history data
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-product-statistics"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"asin" => asin,
"marketplaceId" => marketplaceId,
"graphs" => graphs,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Amazon Product Statistics")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Amazon Product Statistics after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_amazon_product_statistics(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
"graphs",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchAmazonProductStatistics(apiKey, asin, marketplaceId, graphs, retries = 3, timeout = 10000) {
/**
* Fetch data from Amazon Product Statistics endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} asin - Product ASIN (e.g., "B08N5WRWNW")
* @param {string} marketplaceId - Marketplace ID (e.g., "A1PA6795UKMFR9")
* @param {string} graphs - Generate visually graphs for history data
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Amazon Product Statistics endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param asin Product ASIN (e.g., "B08N5WRWNW")
*
* @param marketplaceId Marketplace ID (e.g., "A1PA6795UKMFR9")
*
* @param graphs Generate visually graphs for history data
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchAmazonProductStatistics(String apiKey, String asin, String marketplaceId, String graphs, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-product-statistics";
Map params = new HashMap<>();
params.put("asin", asin);
params.put("marketplaceId", marketplaceId);
params.put("graphs", graphs);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Amazon Product Statistics");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Amazon Product Statistics after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Amazon Product Statistics after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchAmazonProductStatistics(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
"graphs",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchAmazonProductStatistics fetches data from Amazon Product Statistics endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - asin: Product ASIN (e.g., "B08N5WRWNW")
//
// - marketplaceId: Marketplace ID (e.g., "A1PA6795UKMFR9")
//
// - graphs: Generate visually graphs for history data
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchAmazonProductStatistics(apiKey string, asin string, marketplaceId string, graphs string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("asin", asin)
params.Add("marketplaceId", marketplaceId)
params.Add("graphs", graphs)
url := "https://sellermagnet-api.com/amazon-product-statistics?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Amazon Product Statistics", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchAmazonProductStatistics(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
"graphs",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_amazon_product_statistics() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-product-statistics"
local PARAMS="asin=$1&shift;marketplaceId=$1&shift;graphs=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Amazon Product Statistics"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_amazon_product_statistics "YOUR_API_KEY" \
"Product%20ASIN%20%22B08N5WRWNW%22" \
"Marketplace%20ID%20%22A1PA6795UKMFR9%22" \
"graphs" \
Amazon ASIN Converter
Use Case
Convert ASIN to EAN or vice versa to manage cross-marketplace product listings or integrate with external databases.
Endpoint: /amazon-asin-converter
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
asin | text | Yes | ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890") |
marketplaceId | text | Yes | Marketplace ID (e.g., "A1PA6795UKMFR9") |
conversion_direction | text | Yes | Conversion direction: "asin-to-ean" or "ean-to-asin" |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN), a 10-character alphanumeric identifier.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"eanList": {
"description": "List of EAN codes associated with the product.",
"items": {
"description": "European Article Number (EAN), a 12- or 13-digit identifier.",
"pattern": "^[0-9]{12,14}$",
"type": "string"
},
"minItems": 1,
"type": "array"
},
"listedSince": {
"description": "Timestamp indicating when the product was first listed, in ISO 8601 format.",
"format": "date-time",
"type": "string"
},
"productTitle": {
"description": "Title or name of the product.",
"minLength": 1,
"type": "string"
}
},
"required": [
"asin",
"eanList",
"listedSince",
"productTitle"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"asin": "B0CLTBHXWQ",
"eanList": [
"0711719577294"
],
"listedSince": "2023-12-30 01:00:00",
"productTitle": "Playstation 5 Console Edizione Digital Slim"
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_amazon_asin_converter(api_key, asin, marketplaceId, conversion_direction, max_retries=3, timeout=10):
"""
Fetch data from Amazon ASIN Converter endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
asin (text): ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")
marketplaceId (text): Marketplace ID (e.g., "A1PA6795UKMFR9")
conversion_direction (text): Conversion direction: "asin-to-ean" or "ean-to-asin"
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-asin-converter"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"asin": asin,
"marketplaceId": marketplaceId,
"conversion_direction": conversion_direction,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Amazon ASIN Converter")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Amazon ASIN Converter after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_amazon_asin_converter(
api_key="YOUR_API_KEY",
asin="ASIN or EAN to convert "B08N5WRWNW" or "9781234567890"",
marketplaceId="Marketplace ID "A1PA6795UKMFR9"",
conversion_direction="asin-to-ean",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_amazon_asin_converter(api_key, asin, marketplaceId, conversion_direction, max_retries: 3, timeout: 10)
# Fetch data from Amazon ASIN Converter endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param asin [Text] ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")
#
# @param marketplaceId [Text] Marketplace ID (e.g., "A1PA6795UKMFR9")
#
# @param conversion_direction [Text] Conversion direction: "asin-to-ean" or "ean-to-asin"
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-asin-converter"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"asin" => asin,
"marketplaceId" => marketplaceId,
"conversion_direction" => conversion_direction,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Amazon ASIN Converter")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Amazon ASIN Converter after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_amazon_asin_converter(
"YOUR_API_KEY",
"ASIN or EAN to convert "B08N5WRWNW" or "9781234567890"",
"Marketplace ID "A1PA6795UKMFR9"",
"asin-to-ean",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchAmazonASINConverter(apiKey, asin, marketplaceId, conversion_direction, retries = 3, timeout = 10000) {
/**
* Fetch data from Amazon ASIN Converter endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} asin - ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")
* @param {string} marketplaceId - Marketplace ID (e.g., "A1PA6795UKMFR9")
* @param {string} conversion_direction - Conversion direction: "asin-to-ean" or "ean-to-asin"
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Amazon ASIN Converter endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param asin ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")
*
* @param marketplaceId Marketplace ID (e.g., "A1PA6795UKMFR9")
*
* @param conversion_direction Conversion direction: "asin-to-ean" or "ean-to-asin"
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchAmazonASINConverter(String apiKey, String asin, String marketplaceId, String conversion_direction, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-asin-converter";
Map params = new HashMap<>();
params.put("asin", asin);
params.put("marketplaceId", marketplaceId);
params.put("conversion_direction", conversion_direction);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Amazon ASIN Converter");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Amazon ASIN Converter after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Amazon ASIN Converter after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchAmazonASINConverter(
"YOUR_API_KEY",
"ASIN or EAN to convert "B08N5WRWNW" or "9781234567890"",
"Marketplace ID "A1PA6795UKMFR9"",
"asin-to-ean",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchAmazonASINConverter fetches data from Amazon ASIN Converter endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - asin: ASIN or EAN to convert (e.g., "B08N5WRWNW" or "9781234567890")
//
// - marketplaceId: Marketplace ID (e.g., "A1PA6795UKMFR9")
//
// - conversion_direction: Conversion direction: "asin-to-ean" or "ean-to-asin"
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchAmazonASINConverter(apiKey string, asin string, marketplaceId string, conversion_direction string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("asin", asin)
params.Add("marketplaceId", marketplaceId)
params.Add("conversion_direction", conversion_direction)
url := "https://sellermagnet-api.com/amazon-asin-converter?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Amazon ASIN Converter", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchAmazonASINConverter(
"YOUR_API_KEY",
"ASIN or EAN to convert "B08N5WRWNW" or "9781234567890"",
"Marketplace ID "A1PA6795UKMFR9"",
"asin-to-ean",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_amazon_asin_converter() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-asin-converter"
local PARAMS="asin=$1&shift;marketplaceId=$1&shift;conversion_direction=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Amazon ASIN Converter"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_amazon_asin_converter "YOUR_API_KEY" \
"ASIN%20or%20EAN%20to%20convert%20%22B08N5WRWNW%22%20or%20%229781234567890%22" \
"Marketplace%20ID%20%22A1PA6795UKMFR9%22" \
"asin-to-ean" \
Get Amazon Seller Review
Use Case
Retrieve seller feedback to evaluate supplier reliability or monitor competitor performance, useful for dropshipping or sourcing platforms.
Endpoint: /amazon-seller-review
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
sellerId | text | Yes | Seller ID (e.g., "A1B2C3D4E5F6G7") |
marketplaceId | text | Yes | Marketplace ID (e.g., "A1PA6795UKMFR9") |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"marketplace": {
"additionalProperties": {
"additionalProperties": false,
"properties": {
"last5Reviews": {
"description": "List of up to 5 most recent customer reviews.",
"items": {
"additionalProperties": false,
"properties": {
"dateRated": {
"description": "Date and reviewer name of the review, in a human-readable format.",
"type": "string"
},
"reviewText": {
"description": "Text content of the review.",
"minLength": 1,
"type": "string"
},
"starRating": {
"description": "Star rating of the review, formatted as \u0027X out of 5 stars\u0027.",
"pattern": "^[1-5] out of 5 stars$",
"type": "string"
}
},
"required": [
"dateRated",
"reviewText",
"starRating"
],
"type": "object"
},
"maxItems": 5,
"type": "array"
},
"sellerFeedback": {
"additionalProperties": false,
"description": "Seller feedback ratings and review counts over different time periods.",
"properties": {
"30": {
"additionalProperties": false,
"properties": {
"rating": {
"description": "Average rating over the last 30 days.",
"pattern": "^[0-5](\\.\\d)?$",
"type": "string"
},
"reviewsCount": {
"description": "Number of reviews over the last 30 days.",
"pattern": "^[0-9]+$",
"type": "string"
}
},
"required": [
"rating",
"reviewsCount"
],
"type": "object"
},
"365": {
"additionalProperties": false,
"properties": {
"rating": {
"description": "Average rating over the last 365 days.",
"pattern": "^[0-5](\\.\\d)?$",
"type": "string"
},
"reviewsCount": {
"description": "Number of reviews over the last 365 days.",
"pattern": "^[0-9]+$",
"type": "string"
}
},
"required": [
"rating",
"reviewsCount"
],
"type": "object"
},
"90": {
"additionalProperties": false,
"properties": {
"rating": {
"description": "Average rating over the last 90 days.",
"pattern": "^[0-5](\\.\\d)?$",
"type": "string"
},
"reviewsCount": {
"description": "Number of reviews over the last 90 days.",
"pattern": "^[0-9]+$",
"type": "string"
}
},
"required": [
"rating",
"reviewsCount"
],
"type": "object"
},
"lifetime": {
"additionalProperties": false,
"properties": {
"rating": {
"description": "Average rating over the seller\u0027s lifetime.",
"pattern": "^[0-5](\\.\\d)?$",
"type": "string"
},
"reviewsCount": {
"description": "Total number of reviews over the seller\u0027s lifetime, with optional comma for thousands.",
"pattern": "^[0-9]+(,[0-9]+)?$",
"type": "string"
}
},
"required": [
"rating",
"reviewsCount"
],
"type": "object"
}
},
"required": [
"30",
"90",
"365",
"lifetime"
],
"type": "object"
}
},
"required": [
"last5Reviews",
"sellerFeedback"
],
"type": "object"
},
"description": "Marketplace-specific data, keyed by marketplace ID.",
"type": "object"
},
"sellerId": {
"description": "Unique identifier for the seller.",
"pattern": "^[A-Z0-9]+$",
"type": "string"
}
},
"required": [
"marketplace",
"sellerId"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"marketplace": {
"ATVPDKIKX0DER": {
"last5Reviews": [
{
"dateRated": "By gary kraus on June 5, 2025.",
"reviewText": "great",
"starRating": "5 out of 5 stars"
},
{
"dateRated": "By Amazon Customer on June 5, 2025.",
"reviewText": "Ok",
"starRating": "5 out of 5 stars"
},
{
"dateRated": "By Graciela Casta\u00f1eda on May 21, 2025.",
"reviewText": "Excelente",
"starRating": "5 out of 5 stars"
}
],
"sellerFeedback": {
"30": {
"rating": "3.3",
"reviewsCount": "7"
},
"365": {
"rating": "3.9",
"reviewsCount": "114"
},
"90": {
"rating": "3.6",
"reviewsCount": "30"
},
"lifetime": {
"rating": "4.5",
"reviewsCount": "1,535"
}
}
}
},
"sellerId": "A1CWSGXIR635I6"
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_seller_review(api_key, sellerId, marketplaceId, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Seller Review endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
sellerId (text): Seller ID (e.g., "A1B2C3D4E5F6G7")
marketplaceId (text): Marketplace ID (e.g., "A1PA6795UKMFR9")
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-seller-review"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"sellerId": sellerId,
"marketplaceId": marketplaceId,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Seller Review")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Seller Review after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_seller_review(
api_key="YOUR_API_KEY",
sellerId="Seller ID "A1B2C3D4E5F6G7"",
marketplaceId="Marketplace ID "A1PA6795UKMFR9"",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_seller_review(api_key, sellerId, marketplaceId, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Seller Review endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param sellerId [Text] Seller ID (e.g., "A1B2C3D4E5F6G7")
#
# @param marketplaceId [Text] Marketplace ID (e.g., "A1PA6795UKMFR9")
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-seller-review"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"sellerId" => sellerId,
"marketplaceId" => marketplaceId,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Seller Review")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Seller Review after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_seller_review(
"YOUR_API_KEY",
"Seller ID "A1B2C3D4E5F6G7"",
"Marketplace ID "A1PA6795UKMFR9"",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonSellerReview(apiKey, sellerId, marketplaceId, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Seller Review endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} sellerId - Seller ID (e.g., "A1B2C3D4E5F6G7")
* @param {string} marketplaceId - Marketplace ID (e.g., "A1PA6795UKMFR9")
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Seller Review endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param sellerId Seller ID (e.g., "A1B2C3D4E5F6G7")
*
* @param marketplaceId Marketplace ID (e.g., "A1PA6795UKMFR9")
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonSellerReview(String apiKey, String sellerId, String marketplaceId, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-seller-review";
Map params = new HashMap<>();
params.put("sellerId", sellerId);
params.put("marketplaceId", marketplaceId);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Seller Review");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Seller Review after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Seller Review after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonSellerReview(
"YOUR_API_KEY",
"Seller ID "A1B2C3D4E5F6G7"",
"Marketplace ID "A1PA6795UKMFR9"",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonSellerReview fetches data from Get Amazon Seller Review endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - sellerId: Seller ID (e.g., "A1B2C3D4E5F6G7")
//
// - marketplaceId: Marketplace ID (e.g., "A1PA6795UKMFR9")
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonSellerReview(apiKey string, sellerId string, marketplaceId string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("sellerId", sellerId)
params.Add("marketplaceId", marketplaceId)
url := "https://sellermagnet-api.com/amazon-seller-review?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Seller Review", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonSellerReview(
"YOUR_API_KEY",
"Seller ID "A1B2C3D4E5F6G7"",
"Marketplace ID "A1PA6795UKMFR9"",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_seller_review() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-seller-review"
local PARAMS="sellerId=$1&shift;marketplaceId=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Seller Review"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_seller_review "YOUR_API_KEY" \
"Seller%20ID%20%22A1B2C3D4E5F6G7%22" \
"Marketplace%20ID%20%22A1PA6795UKMFR9%22" \
Get Amazon Product
Use Case
Access product details like price, images, and descriptions to build product comparison tools or enrich e-commerce catalogs.
Endpoint: /amazon-product-lookup
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
asin | text | Yes | Product ASIN (e.g., 'B08N5WRWNW') |
marketplaceId | text | Yes | Marketplace ID (e.g., 'A1PA6795UKMFR9') |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"productInfo": {
"additionalProperties": false,
"description": "Detailed product information.",
"properties": {
"additionalDetails": {
"additionalProperties": true,
"description": "Detailed product information.",
"properties": {
"ASIN": {
"description": "Amazon Standard Identification Number (ASIN).",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"Batteries": {
"description": "Battery requirements.",
"type": "string"
},
"Best Sellers Rank": {
"description": "Bestseller rank information.",
"type": "string"
},
"Customer Rating": {
"description": "Customer review summary.",
"type": "string"
},
"Date First Available": {
"description": "Date the product was first available.",
"type": "string"
},
"Item Weight": {
"description": "Weight of the item.",
"type": "string"
},
"Item model number": {
"description": "Model number of the item.",
"type": "string"
},
"Manufacturer": {
"description": "Manufacturer of the product.",
"type": "string"
},
"Number of Reviews": {
"description": "Total number of reviews with \u0027ratings\u0027 suffix.",
"type": "string"
},
"Product Dimensions": {
"description": "Dimensions of the product.",
"type": "string"
},
"Release date": {
"description": "Release date of the product.",
"type": "string"
},
"Type of item": {
"description": "Type of the item.",
"type": "string"
}
},
"required": [
"ASIN"
],
"type": "object"
},
"asin": {
"description": "Amazon Standard Identification Number (ASIN), a 10-character alphanumeric identifier.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"bestsellerRanks": {
"additionalProperties": false,
"description": "Bestseller rank information.",
"properties": {
"main_category": {
"additionalProperties": false,
"properties": {
"name": {
"description": "Name of the main category.",
"minLength": 1,
"type": "string"
},
"rank": {
"description": "Bestseller rank in the main category.",
"minimum": 1,
"type": "integer"
}
},
"required": [
"name",
"rank"
],
"type": "object"
},
"subcategory": {
"additionalProperties": false,
"properties": {
"name": {
"description": "Name of the subcategory (may be empty).",
"type": "string"
},
"rank": {
"description": "Bestseller rank in the subcategory (0 if not applicable).",
"minimum": 0,
"type": "integer"
}
},
"required": [
"name",
"rank"
],
"type": "object"
}
},
"required": [
"main_category",
"subcategory"
],
"type": "object"
},
"bulletPoints": {
"description": "List of product bullet points.",
"items": {
"description": "A product feature or specification.",
"minLength": 1,
"type": "string"
},
"type": "array"
},
"buyBoxInfo": {
"additionalProperties": false,
"description": "Buy box information.",
"properties": {
"currencyCode": {
"description": "Currency code (e.g., USD).",
"type": "string"
},
"currencyName": {
"description": "Full name of the currency.",
"minLength": 1,
"type": "string"
},
"currencySymbol": {
"description": "Symbol of the currency.",
"minLength": 1,
"type": "string"
},
"price": {
"description": "Buy box price.",
"minimum": 0,
"type": "number"
},
"sellerId": {
"description": "Unique identifier of the buy box seller.",
"pattern": "^[A-Z0-9]+$",
"type": "string"
}
},
"required": [
"currencyCode",
"currencyName",
"currencySymbol",
"price",
"sellerId"
],
"type": "object"
},
"categories": {
"additionalProperties": false,
"description": "Bestseller category information.",
"properties": {
"bestsellerCategory": {
"description": "List of bestseller categories.",
"items": {
"additionalProperties": false,
"properties": {
"id": {
"description": "Category identifier.",
"type": "string"
},
"index": {
"description": "Index of the category in the hierarchy.",
"minimum": 1,
"type": "integer"
},
"name": {
"description": "Name of the category.",
"minLength": 1,
"type": "string"
},
"url": {
"description": "URL to the category page on Amazon.",
"format": "uri",
"type": "string"
}
},
"required": [
"id",
"index",
"name",
"url"
],
"type": "object"
},
"type": "array"
},
"rootCategory": {
"additionalProperties": false,
"description": "Root category details.",
"properties": {
"id": {
"description": "Root category identifier.",
"type": "string"
},
"name": {
"description": "Name of the root category.",
"minLength": 1,
"type": "string"
},
"url": {
"description": "URL to the root category page on Amazon.",
"format": "uri",
"type": "string"
}
},
"required": [
"id",
"name",
"url"
],
"type": "object"
}
},
"required": [
"bestsellerCategory",
"rootCategory"
],
"type": "object"
},
"description": {
"description": "Product description (may be empty).",
"items": {
"description": "A description segment.",
"type": "string"
},
"type": "array"
},
"details": {
"additionalProperties": true,
"description": "Additional product details.",
"properties": {
"ASIN": {
"description": "Amazon Standard Identification Number (ASIN).",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"Batteries": {
"description": "Battery requirements.",
"type": "string"
},
"Date First Available": {
"description": "Date the product was first available.",
"type": "string"
},
"Item Weight": {
"description": "Weight of the item.",
"type": "string"
},
"Item model number": {
"description": "Model number of the item.",
"type": "string"
},
"Manufacturer": {
"description": "Manufacturer of the product.",
"type": "string"
},
"Platform": {
"description": "Platform of the product.",
"type": "string"
},
"Product Dimensions": {
"description": "Dimensions of the product.",
"type": "string"
},
"Release date": {
"description": "Release date of the product.",
"type": "string"
},
"Type of item": {
"description": "Type of the item.",
"type": "string"
}
},
"required": [
"ASIN"
],
"type": "object"
},
"hasAPlusContent": {
"description": "Indicates if the product has A+ Content.",
"type": "boolean"
},
"images": {
"description": "List of product image URLs.",
"items": {
"description": "URL to a product image.",
"format": "uri",
"type": "string"
},
"type": "array"
},
"link": {
"description": "URL to the product page on Amazon.",
"format": "uri",
"type": "string"
},
"listedSinceDate": {
"description": "Date when the product was first listed, in YYYY-MM-DD format, or null if unavailable.",
"format": "date",
"type": [
"string",
"null"
]
},
"mainImage": {
"description": "URL to the main product image.",
"format": "uri",
"type": "string"
},
"marketplaceId": {
"description": "Unique identifier for the marketplace.",
"pattern": "^[A-Z0-9]+$",
"type": "string"
},
"reviews": {
"additionalProperties": false,
"description": "Product review summary.",
"properties": {
"averageRating": {
"description": "Average star rating.",
"maximum": 5,
"minimum": 0,
"type": "number"
},
"reviewSummary": {
"description": "Title of the review summary.",
"type": "string"
},
"totalReviews": {
"description": "Total number of reviews.",
"minimum": 0,
"type": "integer"
}
},
"required": [
"averageRating",
"reviewSummary",
"totalReviews"
],
"type": "object"
},
"title": {
"description": "Title of the product.",
"minLength": 1,
"type": "string"
},
"variations": {
"description": "List of product variations.",
"items": {
"additionalProperties": false,
"description": "A product variation.",
"properties": {
"asin": {
"description": "ASIN of the variation.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"attributes": {
"additionalProperties": true,
"description": "Attributes of the variation (e.g., Pattern Name, Style).",
"type": "object"
}
},
"required": [
"asin",
"attributes"
],
"type": "object"
},
"type": "array"
},
"videos": {
"description": "List of product video URLs.",
"items": {
"description": "URL to a product video.",
"format": "uri",
"type": "string"
},
"type": "array"
}
},
"required": [
"additionalDetails",
"asin",
"bestsellerRanks",
"bulletPoints",
"buyBoxInfo",
"categories",
"description",
"details",
"hasAPlusContent",
"images",
"link",
"listedSinceDate",
"mainImage",
"marketplaceId",
"reviews",
"title",
"variations",
"videos"
],
"type": "object"
}
},
"required": [
"productInfo"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"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\u0026node=20972781011"
},
{
"id": "20972796011",
"index": 2,
"name": "Consoles",
"url": "https://www.amazon.com/b/ref=dp_bc_3?ie=UTF8\u0026node=20972796011"
}
],
"rootCategory": {
"id": "468642",
"name": "Video Games",
"url": "https://www.amazon.com/computer-video-games-hardware-accessories/b/ref=dp_bc_1?ie=UTF8\u0026node=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
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_product(api_key, asin, marketplaceId, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Product endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
asin (text): Product ASIN (e.g., 'B08N5WRWNW')
marketplaceId (text): Marketplace ID (e.g., 'A1PA6795UKMFR9')
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-product-lookup"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"asin": asin,
"marketplaceId": marketplaceId,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Product")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Product after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_product(
api_key="YOUR_API_KEY",
asin="Product ASIN 'B08N5WRWNW'",
marketplaceId="Marketplace ID 'A1PA6795UKMFR9'",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_product(api_key, asin, marketplaceId, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Product endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param asin [Text] Product ASIN (e.g., 'B08N5WRWNW')
#
# @param marketplaceId [Text] Marketplace ID (e.g., 'A1PA6795UKMFR9')
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-product-lookup"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"asin" => asin,
"marketplaceId" => marketplaceId,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Product")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Product after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_product(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonProduct(apiKey, asin, marketplaceId, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Product endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} asin - Product ASIN (e.g., 'B08N5WRWNW')
* @param {string} marketplaceId - Marketplace ID (e.g., 'A1PA6795UKMFR9')
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Product endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param asin Product ASIN (e.g., 'B08N5WRWNW')
*
* @param marketplaceId Marketplace ID (e.g., 'A1PA6795UKMFR9')
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonProduct(String apiKey, String asin, String marketplaceId, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-product-lookup";
Map params = new HashMap<>();
params.put("asin", asin);
params.put("marketplaceId", marketplaceId);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Product");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Product after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Product after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonProduct(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonProduct fetches data from Get Amazon Product endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - asin: Product ASIN (e.g., 'B08N5WRWNW')
//
// - marketplaceId: Marketplace ID (e.g., 'A1PA6795UKMFR9')
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonProduct(apiKey string, asin string, marketplaceId string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("asin", asin)
params.Add("marketplaceId", marketplaceId)
url := "https://sellermagnet-api.com/amazon-product-lookup?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Product", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonProduct(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_product() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-product-lookup"
local PARAMS="asin=$1&shift;marketplaceId=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Product"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_product "YOUR_API_KEY" \
"Product%20ASIN%20%27B08N5WRWNW%27" \
"Marketplace%20ID%20%27A1PA6795UKMFR9%27" \
Get Amazon Product Offers
Use Case
Analyze multiple offers for a product to identify the best price or seller, perfect for price tracking or arbitrage applications.
Endpoint: /amazon-product-offers
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
asin | text | Yes | Product ASIN (e.g., 'B08N5WRWNW') |
marketplaceId | text | Yes | Marketplace ID (e.g., 'A1PA6795UKMFR9') |
geo_location | text | No | Detailed Geo Location ZIP CODE |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN), a 10-character alphanumeric identifier.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"buyBox": {
"additionalProperties": false,
"description": "Buy box information.",
"properties": {
"condition": {
"description": "Condition of the buy box product.",
"enum": [
"New",
"Used - Like New",
"Used - Very Good",
"Used - Good",
"Used - Acceptable"
],
"type": "string"
},
"deliveryDate": {
"description": "Expected delivery date in YYYY-MM-DD format.",
"format": "date",
"type": "string"
},
"fulfillmentType": {
"description": "Fulfillment method (FBA or FBM).",
"enum": [
"FBA",
"FBM"
],
"type": "string"
},
"inventory": {
"description": "Number of items available in seller\u0027s inventory.",
"minimum": 0,
"type": "integer"
},
"positivePercentage": {
"description": "Percentage of positive reviews for the seller.",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"priceWithoutShipping": {
"description": "Price excluding shipping.",
"minimum": 0,
"type": "number"
},
"sellerId": {
"description": "Unique identifier of the buy box seller or \u0027Amazon\u0027.",
"pattern": "^[A-Z0-9]+$|^Amazon$",
"type": "string"
},
"sellerName": {
"description": "Name of the buy box seller.",
"minLength": 1,
"type": "string"
},
"shippingPrice": {
"description": "Shipping cost for the buy box offer.",
"minimum": 0,
"type": "number"
},
"totalPrice": {
"description": "Total price including shipping.",
"minimum": 0,
"type": "number"
},
"totalReviews": {
"description": "Total number of reviews for the seller.",
"minimum": 0,
"type": "integer"
}
},
"required": [
"condition",
"deliveryDate",
"fulfillmentType",
"inventory",
"positivePercentage",
"priceWithoutShipping",
"sellerId",
"sellerName",
"shippingPrice",
"totalPrice",
"totalReviews"
],
"type": "object"
},
"currency": {
"additionalProperties": false,
"description": "Currency details.",
"properties": {
"code": {
"description": "Currency code (e.g., USD).",
"type": "string"
},
"name": {
"description": "Full name of the currency.",
"minLength": 1,
"type": "string"
},
"symbol": {
"description": "Symbol of the currency.",
"minLength": 1,
"type": "string"
}
},
"required": [
"code",
"name",
"symbol"
],
"type": "object"
},
"marketplaceId": {
"description": "Unique identifier for the marketplace.",
"pattern": "^[A-Z0-9]+$",
"type": "string"
},
"offers": {
"description": "List of offers for the product.",
"items": {
"additionalProperties": false,
"description": "Details of an offer for the product.",
"properties": {
"condition": {
"description": "Condition of the product.",
"enum": [
"New",
"Used - Like New",
"Used - Very Good",
"Used - Good",
"Used - Acceptable"
],
"type": "string"
},
"deliveryDate": {
"description": "Expected delivery date in YYYY-MM-DD format.",
"format": "date",
"type": "string"
},
"fulfillmentType": {
"description": "Fulfillment method (FBA or FBM).",
"enum": [
"FBA",
"FBM"
],
"type": "string"
},
"inventory": {
"description": "Number of items available in seller\u0027s inventory.",
"minimum": 0,
"type": "integer"
},
"positivePercentage": {
"description": "Percentage of positive reviews for the seller.",
"maximum": 100,
"minimum": 0,
"type": "integer"
},
"priceWithoutShipping": {
"description": "Price excluding shipping.",
"minimum": 0,
"type": "number"
},
"sellerId": {
"description": "Unique identifier of the seller or \u0027Amazon\u0027.",
"pattern": "^[A-Z0-9]+$|^Amazon$",
"type": "string"
},
"sellerName": {
"description": "Name of the seller.",
"minLength": 1,
"type": "string"
},
"shippingPrice": {
"description": "Shipping cost for the offer.",
"minimum": 0,
"type": "number"
},
"totalPrice": {
"description": "Total price including shipping.",
"minimum": 0,
"type": "number"
},
"totalReviews": {
"description": "Total number of reviews for the seller.",
"minimum": 0,
"type": "integer"
}
},
"required": [
"condition",
"deliveryDate",
"fulfillmentType",
"inventory",
"positivePercentage",
"priceWithoutShipping",
"sellerId",
"sellerName",
"shippingPrice",
"totalPrice",
"totalReviews"
],
"type": "object"
},
"type": "array"
},
"productLink": {
"description": "URL to the product page on Amazon.",
"format": "uri",
"type": "string"
},
"productMainImage": {
"description": "URL to the main product image.",
"format": "uri",
"type": "string"
},
"productTitle": {
"description": "Title of the product.",
"minLength": 1,
"type": "string"
}
},
"required": [
"asin",
"buyBox",
"currency",
"marketplaceId",
"offers",
"productLink",
"productMainImage",
"productTitle"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"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
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-07-07",
"fulfillmentType": "FBM",
"inventory": 10,
"positivePercentage": 78,
"priceWithoutShipping": 409.99,
"sellerId": "A17J18A7XABQI9",
"sellerName": "PRICE 2 SAVE",
"shippingPrice": 0,
"totalPrice": 409.99,
"totalReviews": 6892
},
{
"condition": "Used - Good",
"deliveryDate": "2025-06-26",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 87,
"priceWithoutShipping": 409.99,
"sellerId": "A1YU28SVL05CUG",
"sellerName": "premier liquidation",
"shippingPrice": 9.84,
"totalPrice": 419.83,
"totalReviews": 1177
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-06-30",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 40,
"priceWithoutShipping": 418.99,
"sellerId": "A2NBVGK6C0HCUA",
"sellerName": "Fix N Plug",
"shippingPrice": 3.99,
"totalPrice": 422.98,
"totalReviews": 30
},
{
"condition": "Used - Good",
"deliveryDate": "2025-06-30",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 94,
"priceWithoutShipping": 423.99,
"sellerId": "AZZMAGMBAQU46",
"sellerName": "VG1shop (Serial # Recorded)",
"shippingPrice": 3.99,
"totalPrice": 427.98,
"totalReviews": 163
},
{
"condition": "Used - Acceptable",
"deliveryDate": "2025-06-28",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 0,
"priceWithoutShipping": 433.85,
"sellerId": "Amazon",
"sellerName": "Amazon Resale",
"shippingPrice": 0,
"totalPrice": 433.85,
"totalReviews": 0
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-07-01",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 73,
"priceWithoutShipping": 419.99,
"sellerId": "AO9EU0V84CET9",
"sellerName": "StarEdge Electronics",
"shippingPrice": 15.75,
"totalPrice": 435.74,
"totalReviews": 154
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-06-27",
"fulfillmentType": "FBM",
"inventory": 2,
"positivePercentage": 74,
"priceWithoutShipping": 441.49,
"sellerId": "A2E7NH3SLWCOH4",
"sellerName": "Tech for Less",
"shippingPrice": 0,
"totalPrice": 441.49,
"totalReviews": 56746
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-06-27",
"fulfillmentType": "FBM",
"inventory": 1,
"positivePercentage": 84,
"priceWithoutShipping": 443.7,
"sellerId": "A3JEKQLX9Y2C9L",
"sellerName": "SaveCentral",
"shippingPrice": 0,
"totalPrice": 443.7,
"totalReviews": 7483
},
{
"condition": "Used - Like New",
"deliveryDate": "2025-06-27",
"fulfillmentType": "FBM",
"inventory": 2,
"positivePercentage": 80,
"priceWithoutShipping": 439.99,
"sellerId": "A1KOYPV53GXGUI",
"sellerName": "JRS GAMES",
"shippingPrice": 3.99,
"totalPrice": 443.98,
"totalReviews": 81
},
{
"condition": "Used - Very Good",
"deliveryDate": "2025-06-28",
"fulfillmentType": "FBA",
"inventory": 8,
"positivePercentage": 82,
"priceWithoutShipping": 444.99,
"sellerId": "A3853PJW50SJG8",
"sellerName": "Wardyga Management Services LLC",
"shippingPrice": 0,
"totalPrice": 444.99,
"totalReviews": 60
}
],
"productLink": "https://www.amazon.com/dp/B0CL61F39H",
"productMainImage": "https://m.media-amazon.com/images/I/31kTNmpm6vL.jpg",
"productTitle": "PlayStation\u00ae5 console (slim)"
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_product_offers(api_key, asin, marketplaceId, geo_location, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Product Offers endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
asin (text): Product ASIN (e.g., 'B08N5WRWNW')
marketplaceId (text): Marketplace ID (e.g., 'A1PA6795UKMFR9')
geo_location (text): Detailed Geo Location ZIP CODE
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-product-offers"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"asin": asin,
"marketplaceId": marketplaceId,
"geo_location": geo_location,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Product Offers")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Product Offers after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_product_offers(
api_key="YOUR_API_KEY",
asin="Product ASIN 'B08N5WRWNW'",
marketplaceId="Marketplace ID 'A1PA6795UKMFR9'",
geo_location="geo_location",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_product_offers(api_key, asin, marketplaceId, geo_location, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Product Offers endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param asin [Text] Product ASIN (e.g., 'B08N5WRWNW')
#
# @param marketplaceId [Text] Marketplace ID (e.g., 'A1PA6795UKMFR9')
#
# @param geo_location [Text] Detailed Geo Location ZIP CODE
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-product-offers"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"asin" => asin,
"marketplaceId" => marketplaceId,
"geo_location" => geo_location,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Product Offers")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Product Offers after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_product_offers(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
"geo_location",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonProductOffers(apiKey, asin, marketplaceId, geo_location, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Product Offers endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} asin - Product ASIN (e.g., 'B08N5WRWNW')
* @param {string} marketplaceId - Marketplace ID (e.g., 'A1PA6795UKMFR9')
* @param {string} geo_location - Detailed Geo Location ZIP CODE
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Product Offers endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param asin Product ASIN (e.g., 'B08N5WRWNW')
*
* @param marketplaceId Marketplace ID (e.g., 'A1PA6795UKMFR9')
*
* @param geo_location Detailed Geo Location ZIP CODE
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonProductOffers(String apiKey, String asin, String marketplaceId, String geo_location, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-product-offers";
Map params = new HashMap<>();
params.put("asin", asin);
params.put("marketplaceId", marketplaceId);
params.put("geo_location", geo_location);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Product Offers");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Product Offers after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Product Offers after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonProductOffers(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
"geo_location",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonProductOffers fetches data from Get Amazon Product Offers endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - asin: Product ASIN (e.g., 'B08N5WRWNW')
//
// - marketplaceId: Marketplace ID (e.g., 'A1PA6795UKMFR9')
//
// - geo_location: Detailed Geo Location ZIP CODE
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonProductOffers(apiKey string, asin string, marketplaceId string, geo_location string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("asin", asin)
params.Add("marketplaceId", marketplaceId)
params.Add("geo_location", geo_location)
url := "https://sellermagnet-api.com/amazon-product-offers?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Product Offers", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonProductOffers(
"YOUR_API_KEY",
"Product ASIN 'B08N5WRWNW'",
"Marketplace ID 'A1PA6795UKMFR9'",
"geo_location",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_product_offers() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-product-offers"
local PARAMS="asin=$1&shift;marketplaceId=$1&shift;geo_location=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Product Offers"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_product_offers "YOUR_API_KEY" \
"Product%20ASIN%20%27B08N5WRWNW%27" \
"Marketplace%20ID%20%27A1PA6795UKMFR9%27" \
"geo_location" \
Get Amazon Marketplaces
Use Case
Retrieve a list of Amazon marketplaces to configure region-specific API requests or display marketplace options in your app.
Endpoint: /amazon-get-marketplaces
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
api_key | text | Yes | Your API key |
JSON Schema
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"data": {
"type": "object",
"properties": {
"api_key": { "type": "text" },
"timestamp": { "type": "string", "format": "date-time" }
},
"required": ["api_key", "timestamp"]
},
"message": { "type": "string" }
},
"required": ["success", "data", "message"]
}
Response Example
{
"marketplaces": [
{
"country": "Germany",
"id": "A1PA6795UKMFR9",
"name": "Amazon.de"
}
]
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_marketplaces(api_key, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Marketplaces endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-get-marketplaces"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Marketplaces")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Marketplaces after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_marketplaces(
api_key="YOUR_API_KEY",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_marketplaces(api_key, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Marketplaces endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-get-marketplaces"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Marketplaces")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Marketplaces after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_marketplaces(
"YOUR_API_KEY",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonMarketplaces(apiKey, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Marketplaces endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Marketplaces endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonMarketplaces(String apiKey, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-get-marketplaces";
Map params = new HashMap<>();
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Marketplaces");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Marketplaces after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Marketplaces after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonMarketplaces(
"YOUR_API_KEY",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonMarketplaces fetches data from Get Amazon Marketplaces endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonMarketplaces(apiKey string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
url := "https://sellermagnet-api.com/amazon-get-marketplaces?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Marketplaces", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonMarketplaces(
"YOUR_API_KEY",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_marketplaces() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-get-marketplaces"
local PARAMS=""
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Marketplaces"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_marketplaces "YOUR_API_KEY" \
Search Amazon
Use Case
Implement a product search feature to display relevant Amazon products based on user queries, suitable for affiliate marketing or search tools.
Endpoint: /amazon-search
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
q | text | Yes | Search query (e.g., "phone") |
marketplaceId | text | Yes | Marketplace ID (e.g., "A1PA6795UKMFR9") |
count | number | No | Number of results (max 50, default 30) |
geo_location | text | No | Detailed Geo Location ZIP CODE |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"description": "Search results data.",
"properties": {
"searchResults": {
"description": "List of search results for products.",
"items": {
"additionalProperties": false,
"description": "A single search result entry.",
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN), a 10-character alphanumeric identifier.",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"discount_info": {
"description": "Information about stock availability or discounts (e.g., \u0027Nur noch 1 auf Lager\u0027).",
"type": "string"
},
"link": {
"description": "URL to the product page on Amazon.",
"format": "uri",
"type": "string"
},
"listingPrice": {
"additionalProperties": false,
"description": "Listing price information.",
"properties": {
"original_price": {
"additionalProperties": false,
"description": "Original price details for the listing, if available.",
"properties": {
"currency_code": {
"description": "Currency code (e.g., EUR).",
"type": "string"
},
"currency_name": {
"description": "Full name of the currency.",
"minLength": 1,
"type": "string"
},
"currency_symbol": {
"description": "Symbol of the currency.",
"minLength": 1,
"type": "string"
},
"total": {
"description": "Total price as a string, with up to two decimal places.",
"pattern": "^[0-9]+(\\.[0-9]{1,2})?$",
"type": "string"
}
},
"required": [
"currency_code",
"currency_name",
"currency_symbol",
"total"
],
"type": "object"
},
"price": {
"additionalProperties": false,
"description": "Price details for the listing.",
"properties": {
"currency_code": {
"description": "Currency code (e.g., EUR).",
"type": "string"
},
"currency_name": {
"description": "Full name of the currency.",
"minLength": 1,
"type": "string"
},
"currency_symbol": {
"description": "Symbol of the currency.",
"minLength": 1,
"type": "string"
},
"total": {
"description": "Total price as a string, with up to two decimal places.",
"pattern": "^[0-9]+(\\.[0-9]{1,2})?$",
"type": "string"
}
},
"required": [
"currency_code",
"currency_name",
"currency_symbol",
"total"
],
"type": "object"
}
},
"required": [
"price"
],
"type": "object"
},
"mainImage": {
"description": "URL to the main product image.",
"format": "uri",
"type": "string"
},
"on_sale": {
"description": "Indicates if the product is on sale.",
"type": "boolean"
},
"position": {
"description": "Position of the product in the search results.",
"minimum": 1,
"type": "integer"
},
"productTitle": {
"description": "Title of the product.",
"minLength": 1,
"type": "string"
},
"reviewAmount": {
"description": "Total number of customer reviews.",
"minimum": 0,
"type": "integer"
},
"reviewRating": {
"description": "Average review rating, with one decimal place, or null if not available.",
"maximum": 5,
"minimum": 0,
"type": [
"number",
"null"
]
},
"sponsored": {
"description": "Indicates if the product is a sponsored listing.",
"type": "boolean"
}
},
"required": [
"asin",
"discount_info",
"link",
"listingPrice",
"mainImage",
"on_sale",
"position",
"productTitle",
"reviewAmount",
"reviewRating",
"sponsored"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"searchResults"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"searchResults": [
{
"asin": "B0CL5KNB9M",
"discount_info": "",
"link": "https://www.amazon.com/dp/B0CL5KNB9M",
"listingPrice": {
"price": {
"currency_code": "USD",
"currency_name": "United States Dollar",
"currency_symbol": "$",
"total": "449.00"
}
},
"mainImage": "https://m.media-amazon.com/images/I/51fM0CKG+HL._AC_UY218_.jpg",
"on_sale": false,
"position": 1,
"productTitle": "PlayStation\u00ae5 Digital Edition (slim)",
"reviewAmount": 7209,
"reviewRating": 4.7,
"sponsored": false
},
{
"asin": "B0DGY63Z2H",
"discount_info": "",
"link": "https://www.amazon.com/dp/B0DGY63Z2H",
"listingPrice": {
"price": {
"currency_code": "USD",
"currency_name": "United States Dollar",
"currency_symbol": "$",
"total": "699.00"
}
},
"mainImage": "https://m.media-amazon.com/images/I/61vR3ovb2UL._AC_UY218_.jpg",
"on_sale": false,
"position": 2,
"productTitle": "PlayStation 5 Pro Console",
"reviewAmount": 1373,
"reviewRating": 4.4,
"sponsored": false
},
{
"asin": "B0CV4JW8XM",
"discount_info": "",
"link": "https://www.amazon.com/dp/B0CV4JW8XM",
"listingPrice": {
"price": {
"currency_code": "USD",
"currency_name": "United States Dollar",
"currency_symbol": "$",
"total": "77.16"
}
},
"mainImage": "https://m.media-amazon.com/images/I/81BjQjGll8L._AC_UY218_.jpg",
"on_sale": false,
"position": 3,
"productTitle": "PlayStation Stellar Blade",
"reviewAmount": 405,
"reviewRating": 4.7,
"sponsored": false
}
]
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_search_amazon(api_key, q, marketplaceId, count, geo_location, max_retries=3, timeout=10):
"""
Fetch data from Search Amazon endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
q (text): Search query (e.g., "phone")
marketplaceId (text): Marketplace ID (e.g., "A1PA6795UKMFR9")
count (number): Number of results (max 50, default 30)
geo_location (text): Detailed Geo Location ZIP CODE
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-search"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"q": q,
"marketplaceId": marketplaceId,
"count": count,
"geo_location": geo_location,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Search Amazon")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Search Amazon after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_search_amazon(
api_key="YOUR_API_KEY",
q="Search query "phone"",
marketplaceId="Marketplace ID "A1PA6795UKMFR9"",
count="30",
geo_location="geo_location",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_search_amazon(api_key, q, marketplaceId, count, geo_location, max_retries: 3, timeout: 10)
# Fetch data from Search Amazon endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param q [Text] Search query (e.g., "phone")
#
# @param marketplaceId [Text] Marketplace ID (e.g., "A1PA6795UKMFR9")
#
# @param count [Number] Number of results (max 50, default 30)
#
# @param geo_location [Text] Detailed Geo Location ZIP CODE
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-search"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"q" => q,
"marketplaceId" => marketplaceId,
"count" => count,
"geo_location" => geo_location,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Search Amazon")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Search Amazon after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_search_amazon(
"YOUR_API_KEY",
"Search query "phone"",
"Marketplace ID "A1PA6795UKMFR9"",
"30",
"geo_location",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchSearchAmazon(apiKey, q, marketplaceId, count, geo_location, retries = 3, timeout = 10000) {
/**
* Fetch data from Search Amazon endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} q - Search query (e.g., "phone")
* @param {string} marketplaceId - Marketplace ID (e.g., "A1PA6795UKMFR9")
* @param {string} count - Number of results (max 50, default 30)
* @param {string} geo_location - Detailed Geo Location ZIP CODE
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Search Amazon endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param q Search query (e.g., "phone")
*
* @param marketplaceId Marketplace ID (e.g., "A1PA6795UKMFR9")
*
* @param count Number of results (max 50, default 30)
*
* @param geo_location Detailed Geo Location ZIP CODE
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchSearchAmazon(String apiKey, String q, String marketplaceId, String count, String geo_location, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-search";
Map params = new HashMap<>();
params.put("q", q);
params.put("marketplaceId", marketplaceId);
params.put("count", count);
params.put("geo_location", geo_location);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Search Amazon");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Search Amazon after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Search Amazon after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchSearchAmazon(
"YOUR_API_KEY",
"Search query "phone"",
"Marketplace ID "A1PA6795UKMFR9"",
"30",
"geo_location",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchSearchAmazon fetches data from Search Amazon endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - q: Search query (e.g., "phone")
//
// - marketplaceId: Marketplace ID (e.g., "A1PA6795UKMFR9")
//
// - count: Number of results (max 50, default 30)
//
// - geo_location: Detailed Geo Location ZIP CODE
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchSearchAmazon(apiKey string, q string, marketplaceId string, count string, geo_location string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("q", q)
params.Add("marketplaceId", marketplaceId)
params.Add("count", count)
params.Add("geo_location", geo_location)
url := "https://sellermagnet-api.com/amazon-search?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Search Amazon", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchSearchAmazon(
"YOUR_API_KEY",
"Search query "phone"",
"Marketplace ID "A1PA6795UKMFR9"",
"30",
"geo_location",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_search_amazon() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-search"
local PARAMS="q=$1&shift;marketplaceId=$1&shift;count=$1&shift;geo_location=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Search Amazon"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_search_amazon "YOUR_API_KEY" \
"Search%20query%20%22phone%22" \
"Marketplace%20ID%20%22A1PA6795UKMFR9%22" \
"30" \
"geo_location" \
Get Amazon Bestsellers
Use Case
Curate lists of top-selling products in a category to power recommendation engines or trend analysis dashboards.
Endpoint: /amazon-bestsellers
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
category_id | text | Yes | Category ID (e.g., 'electronics') |
marketplaceId | text | Yes | Marketplace ID (e.g., 'A1PA6795UKMFR9') |
count | number | No | Number of results (max 50, default 30) |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"description": "Bestseller data for the specified category.",
"properties": {
"bestsellers": {
"description": "List of bestseller products.",
"items": {
"additionalProperties": false,
"description": "A single bestseller product entry.",
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN).",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"mainImage": {
"description": "URL to the main product image.",
"format": "uri",
"type": "string"
},
"price": {
"additionalProperties": false,
"description": "Price details for the product.",
"properties": {
"currency_code": {
"description": "Currency code (e.g., EUR).",
"type": "string"
},
"currency_name": {
"description": "Full name of the currency.",
"minLength": 1,
"type": "string"
},
"currency_symbol": {
"description": "Symbol of the currency.",
"minLength": 1,
"type": "string"
},
"price": {
"description": "Price of the product.",
"minimum": 0,
"type": "number"
}
},
"required": [
"currency_code",
"currency_name",
"currency_symbol",
"price"
],
"type": "object"
},
"productImages": {
"description": "List of product image URLs.",
"items": {
"description": "URL to a product image.",
"format": "uri",
"type": "string"
},
"type": "array"
},
"productLink": {
"description": "URL to the product page on Amazon.",
"format": "uri",
"type": "string"
},
"productTitle": {
"description": "Title of the product.",
"minLength": 1,
"type": "string"
},
"rank": {
"description": "Bestseller rank in the category.",
"minimum": 1,
"type": "integer"
},
"reviewAmount": {
"description": "Total number of customer reviews.",
"minimum": 0,
"type": "integer"
},
"reviewRating": {
"description": "Average review rating.",
"maximum": 5,
"minimum": 0,
"type": "number"
}
},
"required": [
"asin",
"mainImage",
"productImages",
"productLink",
"productTitle",
"rank",
"reviewAmount",
"reviewRating"
],
"type": "object"
},
"type": "array"
},
"categoryId": {
"description": "Category ID for the bestsellers.",
"type": "string"
},
"link": {
"description": "URL to the bestseller category page on Amazon.",
"format": "uri",
"type": "string"
}
},
"required": [
"bestsellers",
"categoryId",
"link"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"bestsellers": [
{
"asin": "B0B7SFSN99",
"mainImage": "https://images-eu.ssl-images-amazon.com/images/I/81AZ+P-42vL._AC_UL300_SR300,200_.jpg",
"price": {
"currency_code": "EUR",
"currency_name": "Euro",
"currency_symbol": "\u20ac",
"price": 16.68
},
"productImages": [
"https://images-eu.ssl-images-amazon.com/images/I/81AZ+P-42vL._AC_UL300_SR300,200_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/81AZ+P-42vL._AC_UL600_SR600,400_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/81AZ+P-42vL._AC_UL900_SR900,600_.jpg"
],
"productLink": "https://www.amazon.de/Sterntaler-Unisex-Schirmm%C3%BCtze-Nackenschutz-Kinderm%C3%BCtze/dp/B0B7SFSN99/ref=zg_bs_g_12419321031_d_sccl_1/260-5378242-6478342?psc=1",
"productTitle": "Sterntaler Schirmm\u00fctze Nacken - Unisex Baby- und Kinder M\u00fctze mit Nackenschutz und einsteckbaren Ohrenklappen - UV-Schutz 50+ Sommerm\u00fctze zum Binden - Popeline (Bio) Kopfbedeckung",
"rank": 1,
"reviewAmount": 5152,
"reviewRating": 4.6
},
{
"asin": "B0154K62CK",
"mainImage": "https://images-eu.ssl-images-amazon.com/images/I/51r4mejhPuL._AC_UL300_SR300,200_.jpg",
"productImages": [
"https://images-eu.ssl-images-amazon.com/images/I/51r4mejhPuL._AC_UL300_SR300,200_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/51r4mejhPuL._AC_UL600_SR600,400_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/51r4mejhPuL._AC_UL900_SR900,600_.jpg"
],
"productLink": "https://www.amazon.de/Sterntaler-Unisex-Flapper-Bindeb%C3%A4ndern-Nackenschutz/dp/B0154K62CK/ref=zg_bs_g_12419321031_d_sccl_2/260-5378242-6478342?psc=1",
"productTitle": "Sterntaler Sonnenhut - Unisex Sommerhut - UV-Schutz 50+ M\u00fctze mit breiter Krempe und Gr\u00f6\u00dfenregulierung - Nackenschutz - Bindeb\u00e4nder - Baby und Kinder Kopfbedeckung aus Popeline (Bio)",
"rank": 2,
"reviewAmount": 4646,
"reviewRating": 4.7
},
{
"asin": "B08F1W2857",
"mainImage": "https://images-eu.ssl-images-amazon.com/images/I/719-LFYpdJL._AC_UL300_SR300,200_.jpg",
"productImages": [
"https://images-eu.ssl-images-amazon.com/images/I/719-LFYpdJL._AC_UL300_SR300,200_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/719-LFYpdJL._AC_UL600_SR600,400_.jpg",
"https://images-eu.ssl-images-amazon.com/images/I/719-LFYpdJL._AC_UL900_SR900,600_.jpg"
],
"productLink": "https://www.amazon.de/T%C3%B6pfchen-Trainingshose-T%C3%B6pfchentraining-Unterw%C3%A4sche-T%C3%B6pfchen-Trainingshosen/dp/B08F1W2857/ref=zg_bs_g_12419321031_d_sccl_3/260-5378242-6478342?psc=1",
"productTitle": "FLYISH DIRECT T\u00f6pfchen Trainingshose, Kinder T\u00f6pfchentraining Unterw\u00e4sche f\u00fcr Jungen und M\u00e4dchen, Kinder T\u00f6pfchen-Trainingshosen, 3T",
"rank": 3,
"reviewAmount": 4915,
"reviewRating": 4.1
}
],
"categoryId": "12419321031",
"link": "https://www.amazon.de/gp/bestsellers/fashion/12419321031?pg=1"
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_bestsellers(api_key, category_id, marketplaceId, count, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Bestsellers endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
category_id (text): Category ID (e.g., 'electronics')
marketplaceId (text): Marketplace ID (e.g., 'A1PA6795UKMFR9')
count (number): Number of results (max 50, default 30)
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-bestsellers"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"category_id": category_id,
"marketplaceId": marketplaceId,
"count": count,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Bestsellers")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Bestsellers after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_bestsellers(
api_key="YOUR_API_KEY",
category_id="Category ID 'electronics'",
marketplaceId="Marketplace ID 'A1PA6795UKMFR9'",
count="30",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_bestsellers(api_key, category_id, marketplaceId, count, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Bestsellers endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param category_id [Text] Category ID (e.g., 'electronics')
#
# @param marketplaceId [Text] Marketplace ID (e.g., 'A1PA6795UKMFR9')
#
# @param count [Number] Number of results (max 50, default 30)
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-bestsellers"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"category_id" => category_id,
"marketplaceId" => marketplaceId,
"count" => count,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Bestsellers")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Bestsellers after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_bestsellers(
"YOUR_API_KEY",
"Category ID 'electronics'",
"Marketplace ID 'A1PA6795UKMFR9'",
"30",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonBestsellers(apiKey, category_id, marketplaceId, count, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Bestsellers endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} category_id - Category ID (e.g., 'electronics')
* @param {string} marketplaceId - Marketplace ID (e.g., 'A1PA6795UKMFR9')
* @param {string} count - Number of results (max 50, default 30)
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Bestsellers endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param category_id Category ID (e.g., 'electronics')
*
* @param marketplaceId Marketplace ID (e.g., 'A1PA6795UKMFR9')
*
* @param count Number of results (max 50, default 30)
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonBestsellers(String apiKey, String category_id, String marketplaceId, String count, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-bestsellers";
Map params = new HashMap<>();
params.put("category_id", category_id);
params.put("marketplaceId", marketplaceId);
params.put("count", count);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Bestsellers");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Bestsellers after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Bestsellers after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonBestsellers(
"YOUR_API_KEY",
"Category ID 'electronics'",
"Marketplace ID 'A1PA6795UKMFR9'",
"30",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonBestsellers fetches data from Get Amazon Bestsellers endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - category_id: Category ID (e.g., 'electronics')
//
// - marketplaceId: Marketplace ID (e.g., 'A1PA6795UKMFR9')
//
// - count: Number of results (max 50, default 30)
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonBestsellers(apiKey string, category_id string, marketplaceId string, count string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("category_id", category_id)
params.Add("marketplaceId", marketplaceId)
params.Add("count", count)
url := "https://sellermagnet-api.com/amazon-bestsellers?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Bestsellers", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonBestsellers(
"YOUR_API_KEY",
"Category ID 'electronics'",
"Marketplace ID 'A1PA6795UKMFR9'",
"30",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_bestsellers() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-bestsellers"
local PARAMS="category_id=$1&shift;marketplaceId=$1&shift;count=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Bestsellers"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_bestsellers "YOUR_API_KEY" \
"Category%20ID%20%27electronics%27" \
"Marketplace%20ID%20%27A1PA6795UKMFR9%27" \
"30" \
Get Amazon Deals
Use Case
Leverage this endpoint to extract relevant Amazon data for your specific use case.
Endpoint: /amazon-deals
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
marketplaceId | text | Yes | Marketplace ID (e.g., 'A1PA6795UKMFR9') |
api_key | text | Yes | Your API key |
category_id | text | No | Category ID (e.g., 'electronics') |
geo_location | text | No | Detailed Geo Location ZIP CODE |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"description": "Active deals data.",
"properties": {
"deals": {
"description": "List of active deals.",
"items": {
"additionalProperties": false,
"description": "A single deal entry.",
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN).",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"basisPrice": {
"description": "Original price of the product as a string.",
"pattern": "^[0-9]+(\\.[0-9]{1,2})?$",
"type": "string"
},
"coupon_savings": {
"description": "Coupon savings amount as a string, or null if not applicable.",
"pattern": "^[0-9]+(\\.[0-9]{1,2})?$",
"type": [
"string",
"null"
]
},
"dealEndTime": {
"description": "End time of the deal in ISO 8601 format, or \u0027N/A\u0027 if not applicable.",
"format": "date-time",
"type": "string"
},
"dealId": {
"description": "Unique identifier for the deal, or \u0027N/A\u0027 if not applicable.",
"type": "string"
},
"dealLink": {
"description": "URL to the deal page on Amazon.",
"format": "uri",
"type": "string"
},
"dealPrice": {
"additionalProperties": false,
"description": "Price details for the deal.",
"properties": {
"priceCurrency": {
"description": "Currency code (e.g., EUR).",
"type": "string"
},
"priceTotal": {
"description": "Total deal price.",
"minimum": 0,
"type": "number"
}
},
"required": [
"priceCurrency",
"priceTotal"
],
"type": "object"
},
"dealStartTime": {
"description": "Start time of the deal in ISO 8601 format, or \u0027N/A\u0027 if not applicable.",
"format": "date-time",
"type": "string"
},
"image_url": {
"description": "URL to the main product image.",
"format": "uri",
"type": "string"
},
"productTitle": {
"description": "Title of the product.",
"minLength": 1,
"type": "string"
},
"savings_percentage": {
"description": "Percentage of savings for the deal.",
"maximum": 100,
"minimum": 0,
"type": "integer"
}
},
"required": [
"asin",
"basisPrice",
"coupon_savings",
"dealEndTime",
"dealId",
"dealLink",
"dealPrice",
"dealStartTime",
"image_url",
"productTitle",
"savings_percentage"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"deals"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"deals": [
{
"asin": "B094YCTK6P",
"basisPrice": "18.69",
"coupon_savings": null,
"dealEndTime": "2025-07-08T16:15:00.000Z",
"dealId": "5675cf93",
"dealLink": "https://www.amazon.de/dp/B094YCTK6P",
"dealPrice": {
"priceCurrency": "EUR",
"priceTotal": 15.89
},
"dealStartTime": "2025-07-08T04:15:00.000Z",
"image_url": "https://images-eu.ssl-images-amazon.com/images/I/717dw8J-hbL.jpg",
"productTitle": "IceUnicorn Krabbelschuhe Baby Lauflernschuhe Jungen M\u00e4dchen Weicher Leder Babyhausschuhe Kleinkind Rutschfeste Lederschuhe Baby",
"savings_percentage": 15
},
{
"asin": "B07TT3DDCV",
"basisPrice": "25.99",
"coupon_savings": null,
"dealEndTime": "2025-07-11T21:59:59.000Z",
"dealId": "b6dfba81",
"dealLink": "https://www.amazon.de/dp/B07TT3DDCV",
"dealPrice": {
"priceCurrency": "EUR",
"priceTotal": 17.9
},
"dealStartTime": "2025-07-07T22:00:00.000Z",
"image_url": "https://images-eu.ssl-images-amazon.com/images/I/81sqngrRBRL.jpg",
"productTitle": "Playshoes Unisex Kinder Matschhose Regenlatzhose Ungef\u00fcttert Wind-und wasserdichte Regenhose Regenbekleidung",
"savings_percentage": 31
},
{
"asin": "B0B31KTXP6",
"basisPrice": "33.0",
"coupon_savings": null,
"dealEndTime": "2025-07-11T21:59:59.000Z",
"dealId": "783116c9",
"dealLink": "https://www.amazon.de/dp/B0B31KTXP6",
"dealPrice": {
"priceCurrency": "EUR",
"priceTotal": 21.8
},
"dealStartTime": "2025-07-07T22:00:00.000Z",
"image_url": "https://images-eu.ssl-images-amazon.com/images/I/412p-qTjLFL.jpg",
"productTitle": "adidas Unisex Kinder Tensaur Hook and Loop Shoes Laufschuhe",
"savings_percentage": 34
}
]
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_get_amazon_deals(api_key, marketplaceId, category_id, geo_location, max_retries=3, timeout=10):
"""
Fetch data from Get Amazon Deals endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
marketplaceId (text): Marketplace ID (e.g., 'A1PA6795UKMFR9')
category_id (text): Category ID (e.g., 'electronics')
geo_location (text): Detailed Geo Location ZIP CODE
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-deals"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"marketplaceId": marketplaceId,
"category_id": category_id,
"geo_location": geo_location,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Get Amazon Deals")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Get Amazon Deals after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_get_amazon_deals(
api_key="YOUR_API_KEY",
marketplaceId="Marketplace ID 'A1PA6795UKMFR9'",
category_id="Category ID 'electronics'",
geo_location="geo_location",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_get_amazon_deals(api_key, marketplaceId, category_id, geo_location, max_retries: 3, timeout: 10)
# Fetch data from Get Amazon Deals endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param marketplaceId [Text] Marketplace ID (e.g., 'A1PA6795UKMFR9')
#
# @param category_id [Text] Category ID (e.g., 'electronics')
#
# @param geo_location [Text] Detailed Geo Location ZIP CODE
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-deals"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"marketplaceId" => marketplaceId,
"category_id" => category_id,
"geo_location" => geo_location,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Get Amazon Deals")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Get Amazon Deals after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_get_amazon_deals(
"YOUR_API_KEY",
"Marketplace ID 'A1PA6795UKMFR9'",
"Category ID 'electronics'",
"geo_location",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchGetAmazonDeals(apiKey, marketplaceId, category_id, geo_location, retries = 3, timeout = 10000) {
/**
* Fetch data from Get Amazon Deals endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} marketplaceId - Marketplace ID (e.g., 'A1PA6795UKMFR9')
* @param {string} category_id - Category ID (e.g., 'electronics')
* @param {string} geo_location - Detailed Geo Location ZIP CODE
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Get Amazon Deals endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param marketplaceId Marketplace ID (e.g., 'A1PA6795UKMFR9')
*
* @param category_id Category ID (e.g., 'electronics')
*
* @param geo_location Detailed Geo Location ZIP CODE
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchGetAmazonDeals(String apiKey, String marketplaceId, String category_id, String geo_location, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-deals";
Map params = new HashMap<>();
params.put("marketplaceId", marketplaceId);
params.put("category_id", category_id);
params.put("geo_location", geo_location);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Get Amazon Deals");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Get Amazon Deals after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Get Amazon Deals after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchGetAmazonDeals(
"YOUR_API_KEY",
"Marketplace ID 'A1PA6795UKMFR9'",
"Category ID 'electronics'",
"geo_location",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchGetAmazonDeals fetches data from Get Amazon Deals endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - marketplaceId: Marketplace ID (e.g., 'A1PA6795UKMFR9')
//
// - category_id: Category ID (e.g., 'electronics')
//
// - geo_location: Detailed Geo Location ZIP CODE
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchGetAmazonDeals(apiKey string, marketplaceId string, category_id string, geo_location string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("marketplaceId", marketplaceId)
params.Add("category_id", category_id)
params.Add("geo_location", geo_location)
url := "https://sellermagnet-api.com/amazon-deals?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Get Amazon Deals", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchGetAmazonDeals(
"YOUR_API_KEY",
"Marketplace ID 'A1PA6795UKMFR9'",
"Category ID 'electronics'",
"geo_location",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_get_amazon_deals() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-deals"
local PARAMS="marketplaceId=$1&shift;category_id=$1&shift;geo_location=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Get Amazon Deals"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_get_amazon_deals "YOUR_API_KEY" \
"Marketplace%20ID%20%27A1PA6795UKMFR9%27" \
"Category%20ID%20%27electronics%27" \
"geo_location" \
Amazon Product Search Estimated Sells
Use Case
Leverage this endpoint to extract relevant Amazon data for your specific use case.
Endpoint: /amazon-product-search-estimated-sells
Method: GET
Parameters
Name | Type | Required | Description |
---|---|---|---|
asin | text | Yes | Product ASIN (e.g., "B08N5WRWNW") |
marketplaceId | text | Yes | Marketplace ID (e.g., "A1PA6795UKMFR9") |
api_key | text | Yes | Your API key |
JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": false,
"properties": {
"asin": {
"description": "Amazon Standard Identification Number (ASIN).",
"pattern": "^[A-Z0-9]{10}$",
"type": "string"
},
"category": {
"description": "Product category.",
"type": "string"
},
"estimated_monthly_sales": {
"description": "Estimated number of units sold per month.",
"minimum": 0,
"type": "integer"
},
"marketplace_domain": {
"description": "Domain of the marketplace (e.g., \u0027amazon.com\u0027).",
"type": "string"
},
"sales_rank": {
"description": "Current sales rank in the category.",
"minimum": 1,
"type": "integer"
}
},
"required": [
"asin",
"estimated_monthly_sales",
"sales_rank",
"category",
"marketplace_domain"
],
"type": "object"
},
"success": {
"description": "Indicates whether the API request was successful.",
"type": "boolean"
}
},
"required": [
"data",
"success"
],
"type": "object"
}
Response Example
{
"data": {
"asin": "B08N5WRWNW",
"estimated_monthly_sales": 121
},
"success": true
}
Code Examples
import requests
import time
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def fetch_amazon_product_search_estimated_sells(api_key, asin, marketplaceId, max_retries=3, timeout=10):
"""
Fetch data from Amazon Product Search Estimated Sells endpoint with retry logic and error handling.
Args:
api_key (str): API key for authentication
asin (text): Product ASIN (e.g., "B08N5WRWNW")
marketplaceId (text): Marketplace ID (e.g., "A1PA6795UKMFR9")
max_retries (int): Maximum number of retry attempts
timeout (int): Request timeout in seconds
Returns:
dict: API response data
Raises:
Exception: If all retries fail
"""
url = "https://sellermagnet-api.com/amazon-product-search-estimated-sells"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
params = {
"asin": asin,
"marketplaceId": marketplaceId,
}
for attempt in range(max_retries):
try:
logger.info(f"Attempt {attempt + 1} to fetch Amazon Product Search Estimated Sells")
response = requests.get(url, headers=headers, params=params, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt + 1 == max_retries:
raise Exception(f"Failed to fetch Amazon Product Search Estimated Sells after {max_retries} attempts: {e}")
time.sleep(2 ** attempt) # Exponential backoff
return {}
# Example usage
if __name__ == "__main__":
try:
result = fetch_amazon_product_search_estimated_sells(
api_key="YOUR_API_KEY",
asin="Product ASIN "B08N5WRWNW"",
marketplaceId="Marketplace ID "A1PA6795UKMFR9"",
)
logger.info(f"Response: {result}")
except Exception as e:
logger.error(f"Error: {e}")
require 'httparty'
require 'logger'
# Configure logging
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
module SellerMagnetAPI
class << self
def fetch_amazon_product_search_estimated_sells(api_key, asin, marketplaceId, max_retries: 3, timeout: 10)
# Fetch data from Amazon Product Search Estimated Sells endpoint with retry logic and error handling.
#
# @param api_key [String] API key for authentication
#
# @param asin [Text] Product ASIN (e.g., "B08N5WRWNW")
#
# @param marketplaceId [Text] Marketplace ID (e.g., "A1PA6795UKMFR9")
#
# @param max_retries [Integer] Maximum number of retry attempts
# @param timeout [Integer] Request timeout in seconds
# @return [Hash] API response data
# @raise [StandardError] If all retries fail
url = "https://sellermagnet-api.com/amazon-product-search-estimated-sells"
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json"
}
params = {
"asin" => asin,
"marketplaceId" => marketplaceId,
}
max_retries.times do |attempt|
begin
logger.info("Attempt #{attempt + 1} to fetch Amazon Product Search Estimated Sells")
response = HTTParty.get(url, headers: headers, query: params, timeout: timeout)
return response.parsed_response if response.success?
rescue StandardError => e
logger.error("Attempt #{attempt + 1} failed: #{e.message}")
raise("Failed to fetch Amazon Product Search Estimated Sells after #{max_retries} attempts: #{e.message}") if attempt + 1 == max_retries
sleep(2 ** attempt) # Exponential backoff
end
end
end
end
end
# Example usage
begin
result = SellerMagnetAPI.fetch_amazon_product_search_estimated_sells(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
)
logger.info("Response: #{result}")
rescue StandardError => e
logger.error("Error: #{e.message}")
end
const axios = require('axios');
const winston = require('winston');
// Configure logging
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [new winston.transports.Console()]
});
async function fetchAmazonProductSearchEstimatedSells(apiKey, asin, marketplaceId, retries = 3, timeout = 10000) {
/**
* Fetch data from Amazon Product Search Estimated Sells endpoint with retry logic and error handling.
*
* @param {string} apiKey - API key for authentication
* @param {string} asin - Product ASIN (e.g., "B08N5WRWNW")
* @param {string} marketplaceId - Marketplace ID (e.g., "A1PA6795UKMFR9")
* @param {number} retries - Maximum number of retry attempts
* @param {number} timeout - Request timeout in milliseconds
* @returns {Promise
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class SellerMagnetAPIClient {
private static final Logger LOGGER = Logger.getLogger(SellerMagnetAPIClient.class.getName());
private final HttpClient client;
public SellerMagnetAPIClient() {
this.client = HttpClient.newBuilder().build();
}
/**
* Fetch data from Amazon Product Search Estimated Sells endpoint with retry logic and error handling.
*
* @param apiKey API key for authentication
*
* @param asin Product ASIN (e.g., "B08N5WRWNW")
*
* @param marketplaceId Marketplace ID (e.g., "A1PA6795UKMFR9")
*
* @param maxRetries Maximum number of retry attempts
* @param timeoutSeconds Request timeout in seconds
* @return API response data as a String
* @throws Exception If all retries fail
*/
public String fetchAmazonProductSearchEstimatedSells(String apiKey, String asin, String marketplaceId, int maxRetries, int timeoutSeconds) throws Exception {
String url = "https://sellermagnet-api.com/amazon-product-search-estimated-sells";
Map params = new HashMap<>();
params.put("asin", asin);
params.put("marketplaceId", marketplaceId);
String query = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url + "?" + query))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.timeout(java.time.Duration.ofSeconds(timeoutSeconds))
.GET()
.build();
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
LOGGER.info("Attempt " + (attempt + 1) + " to fetch Amazon Product Search Estimated Sells");
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 200 && response.statusCode() < 300) {
return response.body();
}
} catch (Exception e) {
LOGGER.severe("Attempt " + (attempt + 1) + " failed: " + e.getMessage());
if (attempt + 1 == maxRetries) {
throw new Exception("Failed to fetch Amazon Product Search Estimated Sells after " + maxRetries + " attempts: " + e.getMessage());
}
Thread.sleep((long) Math.pow(2, attempt) * 1000); // Exponential backoff
}
}
throw new Exception("Failed to fetch Amazon Product Search Estimated Sells after " + maxRetries + " attempts");
}
// Example usage
public static void main(String[] args) {
SellerMagnetAPIClient apiClient = new SellerMagnetAPIClient();
try {
String response = apiClient.fetchAmazonProductSearchEstimatedSells(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
3,
10
);
LOGGER.info("Response: " + response);
} catch (Exception e) {
LOGGER.severe("Error: " + e.getMessage());
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
"log"
)
// FetchAmazonProductSearchEstimatedSells fetches data from Amazon Product Search Estimated Sells endpoint with retry logic and error handling.
//
// Parameters:
// - apiKey: API key for authentication
//
// - asin: Product ASIN (e.g., "B08N5WRWNW")
//
// - marketplaceId: Marketplace ID (e.g., "A1PA6795UKMFR9")
//
// - maxRetries: Maximum number of retry attempts
// - timeout: Request timeout duration
//
// Returns:
// - []byte: API response data
// - error: Any error encountered
func FetchAmazonProductSearchEstimatedSells(apiKey string, asin string, marketplaceId string, maxRetries int, timeout time.Duration) ([]byte, error) {
client := &http.Client{Timeout: timeout}
params := url.Values{}
params.Add("asin", asin)
params.Add("marketplaceId", marketplaceId)
url := "https://sellermagnet-api.com/amazon-product-search-estimated-sells?" + params.Encode()
for attempt := 0; attempt < maxRetries; attempt++ {
log.Printf("Attempt %d to fetch Amazon Product Search Estimated Sells", attempt+1)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %v", err)
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Printf("Attempt %d failed: %v", attempt+1, err)
if attempt+1 == maxRetries {
return nil, fmt.Errorf("failed after %d attempts: %v", maxRetries, err)
}
time.Sleep(time.Duration(1<= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response: %v", err)
}
return body, nil
}
}
return nil, fmt.Errorf("failed after %d attempts", maxRetries)
}
// Example usage
func main() {
response, err := FetchAmazonProductSearchEstimatedSells(
"YOUR_API_KEY",
"Product ASIN "B08N5WRWNW"",
"Marketplace ID "A1PA6795UKMFR9"",
3,
10*time.Second,
)
if err != nil {
log.Fatalf("Error: %v", err)
}
log.Printf("Response: %s", response)
}
#!/bin/bash
# Configure logging
LOG_FILE="/var/log/sellermagnet_api.log"
log() {
echo "[$(date -Iseconds)] $1" >> "$LOG_FILE"
}
# API request function with retry logic
fetch_amazon_product_search_estimated_sells() {
local API_KEY="$1"
shift
local URL="https://sellermagnet-api.com/amazon-product-search-estimated-sells"
local PARAMS="asin=$1&shift;marketplaceId=$1&"
local MAX_RETRIES=3
local TIMEOUT=10
log "Starting fetch for Amazon Product Search Estimated Sells"
for ((i=1; i<=MAX_RETRIES; i++)); do
RESPONSE=$(curl -s -X GET "${URL}?${PARAMS}" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
--max-time ${TIMEOUT})
if [ $? -eq 0 ]; then
log "Fetch successful on attempt $i"
echo "${RESPONSE}"
return 0
else
log "Attempt $i failed"
sleep $((2 ** i))
fi
done
log "Error: Max retries reached"
echo "Error: Max retries reached"
return 1
}
# Example usage
fetch_amazon_product_search_estimated_sells "YOUR_API_KEY" \
"Product%20ASIN%20%22B08N5WRWNW%22" \
"Marketplace%20ID%20%22A1PA6795UKMFR9%22" \
Need Advanced Integration?
Contact our team for custom solutions, high-volume API access, or dedicated support tailored to your enterprise needs.
Get in TouchGetting Started
Follow these steps to integrate SellerMagnetAPI into your enterprise application.
1. Sign Up
Create an enterprise account to receive your API key and access premium endpoints. Sign Up Now.
2. Authenticate
Use your API key in the Authorization
header (Bearer YOUR_API_KEY
) for secure requests.
3. Test the API
Start with the /amazon-product-lookup
endpoint using a sample ASIN (e.g., B0CX23V2ZK) to validate your integration.
4. Scale Your Integration
Leverage our endpoints for advanced use cases like real-time pricing, competitor analysis, or inventory optimization.