### Complete Amazon SP-API C# Configuration Example Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/configuration.md A comprehensive example demonstrating the setup of AmazonCredential with LWA credentials, marketplace, environment, rate limiting, proxy, debugging, shipping business, and connection parameters including reference number, culture, and logger factory. ```csharp var credential = new AmazonCredential() { // LWA Credentials (required) ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", // Marketplace (required) MarketPlace = MarketPlace.UnitedStates, SellerID = "AXXXXXXXXXXXXX", // Environment Environment = Environments.Production, // Rate Limiting IsActiveLimitRate = true, MaxThrottledRetryCount = 3, // Proxy Proxy = new WebProxy("http://proxy.corp:8080") { Credentials = new NetworkCredential("user", "pass") }, // Debugging IsDebugMode = false, // Shipping (if using Shipping API) ShippingBusiness = ShippingBusiness.SellerCentral }; var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); var cultureInfo = CultureInfo.CreateSpecificCulture("en-US"); var connection = new AmazonConnection( credential, RefNumber: "MyApp-Batch-001", cultureInfo: cultureInfo, loggerFactory: loggerFactory); ``` -------------------------------- ### Get Specific Product Type Definition Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md This example demonstrates how to retrieve a specific product type definition by its name, requirements, and locale. Ensure the 'productType' and 'requirements' are valid. ```CSharp var def = amazonConnection.ProductType.GetDefinitionsProductType( new Parameter.ProductTypes.GetDefinitionsProductTypeParameter() { productType = "PRODUCT", requirements = Requirements.LISTING, locale = AmazonSpApiSDK.Models.ProductTypes.LocaleEnum.en_US }); ``` -------------------------------- ### Basic Configuration Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Example of setting up basic Amazon credentials. ```APIDOC ## Basic Configuration ### Description Example of setting up basic Amazon credentials. ### Code Example ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedStates }; ``` ``` -------------------------------- ### CreateReport Specification Example Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/report-service.md An example demonstrating how to instantiate ParameterCreateReportSpecification with specific report type, date range, marketplace ID, and report options. ```csharp var spec = new ParameterCreateReportSpecification { reportType = ReportTypes.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL, dataStartTime = DateTime.UtcNow.AddDays(-30), marketplaceIds = new MarketplaceIds { MarketPlace.UnitedStates.ID }, reportOptions = new ReportOptions { /* format, encoding */ } }; ``` -------------------------------- ### Manual RDT Creation Example Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/token-service.md Example demonstrating how to manually create an RDT for accessing buyer information on specific orders. This involves defining the restricted resources, including the HTTP method, path, and specific data elements required. ```csharp // Create an RDT for buyer info on specific orders var rdtRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders/{orderId}/buyerInfo", dataElements = new List { "buyerInfo" // Specific data element } }, new RestrictedResource { method = "GET", path = "/orders/v0/orders/{orderId}/address", dataElements = new List { "shippingAddress" // Another specific element } } } }; string rdt = await connection.Tokens.CreateRestrictedDataTokenAsync(rdtRequest); Console.WriteLine($"RDT created, expires in 1 hour: {rdt}"); ``` -------------------------------- ### Get Orders with Filters (C#) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/README.md Example of retrieving orders using the Orders API. Demonstrates filtering by creation date, order status, and requesting restricted data. ```csharp // From order-service.md var orders = await connection.Orders.GetOrdersAsync(new ParameterOrderList { CreatedAfter = DateTime.UtcNow.AddDays(-7), OrderStatuses = new List { OrderStatuses.Unshipped }, IsNeedRestrictedDataToken = true }); ``` -------------------------------- ### Configuration with Proxy Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Example of configuring Amazon credentials with a proxy server, including authenticated proxies. ```APIDOC ## Configuration with Proxy ### Description Example of configuring Amazon credentials with a proxy server, including authenticated proxies. ### Code Example ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedArabEmirates, Proxy = new System.Net.WebProxy("http://proxy.corp:8080") }; // Or with authenticated proxy credential.Proxy = new System.Net.WebProxy("http://proxy.corp:8080") { Credentials = new System.Net.NetworkCredential("user", "password") }; ``` ``` -------------------------------- ### Fetch Orders with PII Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/token-service.md An example demonstrating how to fetch orders along with buyer information by first obtaining an RDT and then calling the Orders API. ```APIDOC ## Fetch Orders with Buyer Info ### Description Fetches a list of orders, including sensitive buyer information, by first requesting a Restricted Data Token (RDT) with the necessary data elements and then calling the Orders API. ### Method `connection.Tokens.CreateRestrictedDataTokenAsync` and `connection.Orders.GetOrdersAsync` ### Usage ```csharp async Task> GetOrdersWithBuyerInfo(List orderIds) { // Request RDT for buyerInfo and shippingAddress var rdt = await connection.Tokens.CreateRestrictedDataTokenAsync( new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders", dataElements = new List { "buyerInfo", "shippingAddress" } } } }); // Call Orders API with the obtained RDT var orders = await connection.Orders.GetOrdersAsync(new ParameterOrderList { IsNeedRestrictedDataToken = false, // RDT is already obtained RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders", dataElements = new List { "buyerInfo", "shippingAddress" } } } } }); return orders.ToList(); } ``` ``` -------------------------------- ### Fetch Orders with PII Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/token-service.md Example of fetching orders including buyer information and shipping addresses. This involves creating an RDT and then calling the Orders API. ```csharp async Task> GetOrdersWithBuyerInfo(List orderIds) { var rdt = await connection.Tokens.CreateRestrictedDataTokenAsync( new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders", dataElements = new List { "buyerInfo", "shippingAddress" } } } }); // Now call Orders API with the RDT var orders = await connection.Orders.GetOrdersAsync(new ParameterOrderList { IsNeedRestrictedDataToken = false, // We already have RDT RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders", dataElements = new List { "buyerInfo", "shippingAddress" } } } } }); return orders.ToList(); } ``` -------------------------------- ### Get Featured Offer Expected Price Batch Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Demonstrates how to get the featured offer expected price for a batch of products. This method is part of the `ProductPricingSample` class. ```CSharp var priceDemo = new ProductPricingSample(amazonConnection); await priceDemo.GetFeaturedOfferExpectedPriceBatch(); ``` -------------------------------- ### Configuration with Debug Logging Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Example of configuring Amazon credentials with debug logging enabled and specifying the environment. ```APIDOC ## Configuration with Debug Logging ### Description Example of configuring Amazon credentials with debug logging enabled and specifying the environment. ### Code Example ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedStates, IsDebugMode = true, Environment = Environments.Sandbox }; ``` ``` -------------------------------- ### Instantiate AmazonConnection with Credentials Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-connection.md Demonstrates how to create an instance of AmazonConnection using AmazonCredential. This is the primary way to start interacting with the SDK's services. ```csharp var credentials = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxxx", MarketPlace = MarketPlace.UnitedStates }; var connection = new AmazonConnection(credentials); ``` -------------------------------- ### Get Product Pricing Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieves pricing information for a given ASIN in a specific marketplace. Requires `MarketPlaceId` and an array of `Asins`. ```CSharp var data = amazonConnection.ProductPricing.GetPricing( new Parameter.ProductPricing.ParameterGetPricing() { MarketplaceId = MarketPlace.UnitedArabEmirates.ID, Asins = new string[] { "B00CZC5F0G" } }); ``` -------------------------------- ### ConstructFeedService Example Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/feed-service.md Demonstrates how to use the ConstructFeedService helper to build feed XML for pricing, inventory, product images, and order fulfillment. This helper simplifies the process of creating compliant feed payloads. ```csharp var feedService = new ConstructFeedService(sellerId, schemaVersion: "1.02"); // Add pricing feedService.AddPriceMessage(new List { new PriceMessage { SKU = "SKU-1", StandardPrice = new StandardPrice { currency = "USD", Value = "99.99" } } }); // Add inventory/quantity feedService.AddInventoryMessage(new List { new InventoryMessage { SKU = "SKU-1", Quantity = 100, FulfillmentLatency = "1" } }); // Add images feedService.AddProductImageMessage(new List { new ProductImageMessage { SKU = "SKU-1", ImageLocation = "http://example.com/image.jpg", ImageType = ImageType.Main } }); // Add order fulfillment (tracking) feedService.AddOrderFulfillmentMessage(new List { new OrderFulfillmentMessage { AmazonOrderID = "123-1234567-1234567", FulfillmentDate = DateTime.Now.ToString("O"), FulfillmentData = new FulfillmentData { CarrierName = "UPS", ShippingMethod = "Ground", ShipperTrackingNumber = "12345678" } } }); string xml = feedService.GetXML(); ``` -------------------------------- ### Get Pricing for ASINs Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/product-pricing-service.md Retrieves current pricing for one or more ASINs on a specific marketplace. Use this method to get the product price and lowest offer for a given ASIN. ```csharp public GetPricingResponse GetPricing(ParameterGetPricing parameter) public async Task GetPricingAsync(ParameterGetPricing parameter, CancellationToken cancellationToken = default) ``` ```csharp var pricingData = await connection.ProductPricing.GetPricingAsync( new ParameterGetPricing { MarketplaceId = MarketPlace.UnitedStates.ID, Asins = new[] { "B00JK2YANC", "B008SYY2Y0" } }); foreach (var item in pricingData.Payload) { Console.WriteLine($"ASIN: {item.Asin}"); Console.WriteLine($"Product Price: {item.Product?.Pricing?.ListingPrice.CurrencyCode} {item.Product?.Pricing?.ListingPrice.Amount}"); if (item.CompetitivePricing?.CompetitivePrices?.Any() == true) { var lowestFbaPrice = item.CompetitivePricing.CompetitivePrices.FirstOrDefault(); Console.WriteLine($"Lowest FBA: {lowestFbaPrice.Price?.CurrencyCode} {lowestFbaPrice.Price?.Amount}"); } } ``` -------------------------------- ### Get Service Job by ID Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md This example shows how to retrieve a specific service job using its ID. Note that as of April 2026, the response includes a 'payments' array. The total paid amount can be calculated from this array. ```CSharp var serviceJob = amazonConnection.Services.GetServiceJobByServiceJobId("SJ-1234567890"); // As of Amazon's April 2026 release, the response contains a payments[] array. var totalPaid = serviceJob.Payments? .Where(p => p.Amount?.Value != null) .Sum(p => p.Amount.Value); ``` -------------------------------- ### Using MarketPlace Enum for Credentials Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/marketplace-regions.md Configure Amazon credentials using the MarketPlace enum for direct integration. This example shows setting up credentials and fetching orders for a specific marketplace. ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedKingdom // Direct enum }; var connection = new AmazonConnection(credential); var orders = connection.Orders.GetOrders(new ParameterOrderList { MarketplaceIds = new List { MarketPlace.UnitedKingdom.ID } }); ``` -------------------------------- ### Using Sandbox Environment for API Calls Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/marketplace-regions.md Configure credentials to use the sandbox environment for testing API calls. This example demonstrates setting the environment to Sandbox and a specific marketplace, then establishing a connection and retrieving mock orders. ```csharp credential.Environment = Environments.Sandbox; credential.MarketPlace = MarketPlace.UnitedStates; // Uses https://sandbox.sellingpartnerapi-na.amazon.com/ var connection = new AmazonConnection(credential); // Get mock orders using TestCase var orders = connection.Orders.GetOrders(new ParameterOrderList { TestCase = Constants.TestCase200 // Returns 200 mock orders }); ``` -------------------------------- ### StartReceivingNotificationMessages / StartReceivingNotificationMessagesAsync Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/notification-service.md Starts a listener to poll an SQS queue for incoming notification messages, processing them via a callback interface. ```APIDOC ## StartReceivingNotificationMessages / StartReceivingNotificationMessagesAsync ### Description Static method to poll an SQS queue for notifications. Blocks and processes messages with a callback interface. ### Method Asynchronous operation (implied by `async Task` signature). ### Endpoint N/A (This is a client-side method for polling an SQS queue, not a direct API endpoint call). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (Method Arguments) - **parameterMessageReceiver** (`ParameterMessageReceiver`) - Required - Contains AWS credentials, SQS URL, region, and poll settings. - **accessKey** (string) - Required - **secretKey** (string) - Required - **sqsUrl** (string) - Required - **regionEndpoint** (`Amazon.RegionEndpoint`) - Required - **WaitTimeSeconds** (int) - Optional - Configures long polling. - **messageReceiver** (`IMessageReceiver`) - Required - Callback handler implementing the `IMessageReceiver` interface. - **cancellationToken** (`CancellationToken`) - Optional - Allows for graceful shutdown of the listener. ### Request Example ```csharp var param = new ParameterMessageReceiver( accessKey: Environment.GetEnvironmentVariable("AWS_ACCESS_KEY"), secretKey: Environment.GetEnvironmentVariable("AWS_SECRET_KEY"), sqsUrl: Environment.GetEnvironmentVariable("SQS_URL"), regionEndpoint: Amazon.RegionEndpoint.USEast2, WaitTimeSeconds: 20); // Long polling var receiver = new MyMessageReceiver(); using var cts = new CancellationTokenSource(); try { await NotificationService.StartReceivingNotificationMessagesAsync(param, receiver, cts.Token); } catch (OperationCanceledException) { Console.WriteLine("Listener stopped"); } ``` ### Response This method runs asynchronously and processes messages via a callback. No direct return value is specified other than exceptions. #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### Get Order Items Async Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/order-service.md Retrieves items (SKU, quantity, price, etc.) for a single order. Use this method to get a list of all items within a specific order. ```csharp var items = await connection.Orders.GetOrderItemsAsync("123-1234567-1234567"); foreach (var item in items) { Console.WriteLine($"SKU: {item.SellerSKU}, Qty: {item.QuantityOrdered}, Price: {item.ItemPrice.CurrencyCode} {item.ItemPrice.Amount}"); } ``` -------------------------------- ### Submit Feed with JSON Listings Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/types.md Example of submitting a feed using the JSON_LISTINGS_FEED type and JSON content type. Ensure the feedDocument is a valid JSON string. ```csharp await connection.Feed.SubmitFeedAsync( feedDocument: jsonString, feedType: FeedType.JSON_LISTINGS_FEED, contentType: ContentType.JSON); ``` -------------------------------- ### Accessing Orders API v0 and v2026-01-01 Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-connection.md Shows how to use the AmazonConnection instance to access different versions of the Orders API. Includes examples for both synchronous (v0) and asynchronous (v2026-01-01) calls. ```csharp // Access Orders API v0 var orders = connection.Orders.GetOrders(new ParameterOrderList { /* ... */ }); // Access Orders API v2026-01-01 var order = await connection.OrdersV20260101.GetOrderAsync("123-4567890-1234567"); ``` -------------------------------- ### Get Order List from Sandbox Environment Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieve orders from the Amazon sandbox environment using a specific test case. Requires an initialized AmazonConnection configured for the sandbox. ```csharp AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential() { ClientId = "amzn1.application-XXX-client.XXXXXXXXXXXXXXXXXXXXXXXXXXXX", ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", RefreshToken= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", Environment=Environments.Sandbox }); var orders = amazonConnection.Orders.GetOrders ( new FikaAmazonAPI.Parameter.Order.ParameterOrderList { TestCase = Constants.TestCase200 } ); ``` -------------------------------- ### Get Competitive Summary (2022-05-01) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieves competitive summary data, including similar items, for up to 20 ASIN/marketplace pairs. Note the strict rate limit of 0.033 req/s. ```CSharp var response = await amazonConnection.ProductPricing.GetCompetitiveSummaryAsync(new CompetitiveSummaryBatchRequest { Requests = new List { new CompetitiveSummaryRequest { Asin = "B00CZC5F0G", MarketplaceId = MarketPlace.UnitedArabEmirates.ID, IncludedData = new List { CompetitiveSummaryIncludedData.similarItems }, } } }); // Read the new similarItems array. foreach (var r in response.Responses) foreach (var group in r.Body?.SimilarItems ?? new List()) foreach (var item in group.Items) Console.WriteLine($"Similar ASIN: {item.Asin}"); ``` -------------------------------- ### Get Competitive Pricing for ASINs Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/product-pricing-service.md Retrieves competitive pricing, including the lowest offers from all sellers, for one or more ASINs. This is useful for understanding the competitive landscape for your products. ```csharp public GetCompetitivePricingResponse GetCompetitivePricing(ParameterGetCompetitivePricing parameter) public async Task GetCompetitivePricingAsync(ParameterGetCompetitivePricing parameter, CancellationToken cancellationToken = default) ``` ```csharp var competitive = await connection.ProductPricing.GetCompetitivePricingAsync( new ParameterGetCompetitivePricing { MarketplaceId = MarketPlace.UnitedStates.ID, Asins = new[] { "B00JK2YANC" } }); foreach (var item in competitive.Payload) { var fbaPrices = item.CompetitivePricing?.FulfillmentChannelPrices? .Where(f => f.Channel == "AFN") .ToList(); if (fbaPrices?.Any() == true) foreach (var price in fbaPrices) Console.WriteLine($"FBA: ${price.CompetitivePriceThreshold?.ListingPrice?.Amount}"); } ``` -------------------------------- ### Get Competitive Summary Batch Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/product-pricing-service.md Retrieve competitive data for up to 20 ASIN/marketplace pairs in a single batch request. Supports fetching featured buying options, reference prices, lowest offers, and similar items. Be mindful of strict rate limits. ```csharp public async Task GetCompetitiveSummaryAsync(CompetitiveSummaryBatchRequest request) ``` ```csharp var response = await connection.ProductPricing.GetCompetitiveSummaryAsync(new CompetitiveSummaryBatchRequest { Requests = new List { new CompetitiveSummaryRequest { Asin = "B00CZC5F0G", MarketplaceId = MarketPlace.UnitedStates.ID, IncludedData = new List { CompetitiveSummaryIncludedData.similarItems, CompetitiveSummaryIncludedData.lowestPrices } } } }); foreach (var r in response.Responses) { // New: Access similar items if (r.Body?.SimilarItems != null) foreach (var group in r.Body.SimilarItems) foreach (var item in group.Items) Console.WriteLine($"Similar ASIN: {item.Asin} - {item.Title}"); // Lowest prices if (r.Body?.LowestPrices != null) foreach (var lp in r.Body.LowestPrices) Console.WriteLine($"FBA: ${lp.ListingPrice?.Amount}"); } ``` -------------------------------- ### Replenishment API - Get Selling Partner Metrics Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieve seller-level metrics, including REVENUE_PENETRATION. This operation is rate-limited to 1 req/s, burst 1. ```CSharp // 3. Seller-level metrics including the new REVENUE_PENETRATION metric. var spMetrics = await amazonConnection.Replenishment.GetSellingPartnerMetricsAsync(new GetSellingPartnerMetricsRequest { AggregationFrequency = AggregationFrequency.MONTH, TimeInterval = new TimeInterval { StartDate = monthStart, EndDate = monthEnd }, TimePeriodType = TimePeriodType.PERFORMANCE, MarketplaceId = MarketPlace.US.ID, ProgramTypes = new List { ProgramType.SUBSCRIBE_AND_SAVE }, Metrics = new List { Metric.REVENUE_PENETRATION, Metric.TOTAL_SUBSCRIPTIONS_REVENUE }, }); ``` -------------------------------- ### Get Catalog Item (2022-04-01) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieves detailed catalog item information for a given ASIN, including attributes, sales ranks, summaries, and more. Requires specifying the desired included data. ```CSharp var data = await amazonConnection.CatalogItem.GetCatalogItem202204Async( new Parameter.CatalogItems.ParameterGetCatalogItem { ASIN = "B00JK2YANC", includedData = new[] { IncludedData.attributes, IncludedData.salesRanks, IncludedData.summaries, IncludedData.productTypes, IncludedData.relationships, IncludedData.dimensions, IncludedData.identifiers, IncludedData.images } }); ``` -------------------------------- ### ParameterGetFeaturedOfferExpectedPrice C# Class Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/product-pricing-service.md Specifies parameters for estimating the expected price of a featured offer, including ASIN, SellerSKU, price, fulfillment channel, item condition, and optional starting price. ```csharp public class ParameterGetFeaturedOfferExpectedPrice : ParameterBased { public string MarketplaceId { get; set; } public string Asin { get; set; } public string SellerSKU { get; set; } public decimal PriceToEstimate { get; set; } public string FulfillmentChannel { get; set; } // "AFN" or "MFN" public string ItemCondition { get; set; } // "New", "Refurbished", "Used" public decimal? StartingPrice { get; set; } } ``` -------------------------------- ### Create Restricted Data Token Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/token-service.md This example demonstrates how to create a Restricted Data Token (RDT) for accessing specific PII data elements. It includes error handling for cases where the application is not authorized for the requested data. ```APIDOC ## CreateRestrictedDataTokenAsync ### Description Creates a Restricted Data Token (RDT) to access specific PII data elements for a given resource. ### Method `connection.Tokens.CreateRestrictedDataTokenAsync` ### Parameters #### Request Body - **restrictedResources** (List) - Required - A list of restricted resources for which the RDT is being requested. - **method** (string) - Required - The HTTP method for the resource. - **path** (string) - Required - The path to the resource. - **dataElements** (List) - Required - A list of data elements to be accessed. ### Request Example ```csharp var rdt = await connection.Tokens.CreateRestrictedDataTokenAsync( new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders/{orderId}/buyerInfo", dataElements = new List { "buyerInfo" } } } }); ``` ### Error Handling - **AmazonUnauthorizedException**: Thrown when the application is not authorized to access the requested PII data. - **AmazonAccessDeniedException**: Thrown when the seller has not granted authorization for the application to access PII data. This typically requires the user to re-authorize via an OAuth flow. ``` -------------------------------- ### Get Order List with PII Data (Simple) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieve a list of unshipped orders within the last 24 hours for the United Arab Emirates, requesting PII data. Requires an initialized AmazonConnection. ```csharp var parameterOrderList = new ParameterOrderList { CreatedAfter = DateTime.UtcNow.AddHours(-24), OrderStatuses = new List { OrderStatuses.Unshipped }, MarketplaceIds = new List { MarketPlace.UnitedArabEmirates.ID }, IsNeedRestrictedDataToken = true }; var orders = _amazonConnection.Orders.GetOrders(parameterOrderList); ``` -------------------------------- ### Convenience Method to Get and Save Report File Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/report-service.md A helper method that combines downloading a report document and saving it directly to the local file system. It returns the path to the saved file. ```csharp public string GetReportFile(string reportDocumentId) ``` -------------------------------- ### Implement IMessageReceiver for Notifications Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/notification-service.md Implement the IMessageReceiver interface to handle incoming notification messages. This example includes logic for deduplicating messages by NotificationId and processing different notification types like OrderChangeNotification and AnyOfferChangedNotification. ```csharp public class MyMessageReceiver : IMessageReceiver { private readonly ConcurrentDictionary _processedIds = new(); public void NewMessageRevicedTriger(NotificationMessageResponce message) { // Deduplicate by NotificationId (SQS may deliver duplicates) var notifId = message?.NotificationMetadata?.NotificationId; if (notifId != null && !_processedIds.TryAdd(notifId, 0)) return; // Process message var payload = message?.Payload; if (payload?.OrderChangeNotification != null) { Console.WriteLine($"Order changed: {payload.OrderChangeNotification.Orders}"); } else if (payload?.AnyOfferChangedNotification != null) { Console.WriteLine($"Offer changed: {payload.AnyOfferChangedNotification.AffectedOffers}"); } } public void ErrorCatch(Exception ex) { Console.WriteLine($"Error processing notification: {ex.Message}"); } } ``` -------------------------------- ### Basic Amazon Credential Configuration Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Configure basic Amazon API credentials including Client ID, Client Secret, Refresh Token, and Marketplace. This is the fundamental setup for interacting with Amazon APIs. ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedStates }; ``` -------------------------------- ### Handling Date/Time Parameters in UTC Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/marketplace-regions.md Ensure all date and time parameters are provided in UTC format. The SDK automatically converts these to ISO 8601 format for API requests. This example shows setting 'CreatedAfter' and 'CreatedBefore' using `DateTime.UtcNow`. ```csharp var parameters = new ParameterOrderList { CreatedAfter = DateTime.UtcNow.AddDays(-7), // Use UTC CreatedBefore = DateTime.UtcNow }; ``` -------------------------------- ### Get Catalog Item with Specific Data Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/types.md Example of how to retrieve a catalog item using the Catalog Items API, specifying which data fields to include in the response. This demonstrates the usage of the IncludedData enum. ```csharp var item = await connection.CatalogItem.GetCatalogItem202204Async( new ParameterGetCatalogItem { ASIN = "B00JK2YANC", includedData = new[] { IncludedData.attributes, IncludedData.summaries, IncludedData.salesRanks } }); ``` -------------------------------- ### Create and Download Report (GET_MERCHANT_LISTINGS_ALL_DATA) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Creates a report for merchant listings and then retrieves its file content. It polls for the report status until the document ID is available. ```CSharp var parameters = new ParameterCreateReportSpecification(); parameters.reportType = ReportTypes.GET_MERCHANT_LISTINGS_ALL_DATA; parameters.marketplaceIds = new MarketplaceIds(); parameters.marketplaceIds.Add(MarketPlace.UnitedArabEmirates.ID); parameters.reportOptions = new FikaAmazonAPI.AmazonSpApiSDK.Models.Reports.ReportOptions(); var reportId = amazonConnection.Reports.CreateReport(parameters); var filePath = string.Empty; string ReportDocumentId = string.Empty; while (string.IsNullOrEmpty(ReportDocumentId)) { Thread.Sleep(1000 * 60); var reportData = amazonConnection.Reports.GetReport(reportId); if (!string.IsNullOrEmpty(reportData.ReportDocumentId)) { filePath = amazonConnection.Reports.GetReportFile(reportData.ReportDocumentId); break; } } //filePath for report ``` -------------------------------- ### Get Feed Document Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/feed-service.md Retrieves the processing report for a completed feed. Use this method to get the pre-signed S3 URL and content type of the feed document. ```csharp public FeedDocumentResponse GetFeedDocument(string feedDocumentId) public async Task GetFeedDocumentAsync(string feedDocumentId, CancellationToken cancellationToken = default) ``` -------------------------------- ### Build and Test Commands for Amazon SP-API C# SDK Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/CLAUDE.md Common dotnet CLI commands for restoring dependencies, building projects, running tests, and packing the NuGet package. ```bash dotnet restore dotnet build # builds all three projects dotnet build ./Source/FikaAmazonAPI/FikaAmazonAPI.csproj --configuration Release dotnet test ./Source/Tests/Tests.csproj # NUnit suite (rate-limit tests only) dotnet test ./Source/Tests/Tests.csproj --filter "FullyQualifiedName~WaitForPermittedRequest" # single test dotnet pack ./Source/FikaAmazonAPI/FikaAmazonAPI.csproj --configuration Release # produces .nupkg ``` -------------------------------- ### Get Report Document with PII Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Demonstrates two ways to get a report document: automatically detecting restricted data or explicitly setting `isRestrictedReport` to true for PII data. ```CSharp //use this method automatically know if the report are RDT or not var data2 = amazonConnection.Reports.CreateReportAndDownloadFile(ReportTypes.GET_EASYSHIP_DOCUMENTS, startDate, null, null); // OR USE this method to get the document and pass parameter isRestrictedReport = true in case the report will return PII data var data = amazonConnection.Reports.GetReportDocument("50039018869997",true); ``` -------------------------------- ### Set Environment to Production or Sandbox Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/configuration.md Configure the SDK to target either the production environment for live data or the sandbox environment for testing with mock data. For sandbox, you can optionally specify a test case to simulate specific responses. ```csharp // Production (default) credential.Environment = Environments.Production; // Sandbox (test environment with mock data) credential.Environment = Environments.Sandbox; // For sandbox, optionally use a test case var orders = connection.Orders.GetOrders(new ParameterOrderList { TestCase = Constants.TestCase200 // Returns 200 mock orders }); ``` -------------------------------- ### Report Manager - Get Seller Performance Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Uses the ReportManager to retrieve seller performance data. ```CSharp var sellerPerformance = reportManager.GetSellerPerformance(); //GET_V2_SELLER_PERFORMANCE_REPORT ``` -------------------------------- ### Marketplace ID Resolution Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Example of configuring Amazon credentials using a Marketplace ID directly, which will be auto-resolved. ```APIDOC ## Marketplace ID Resolution ### Description Example of configuring Amazon credentials using a Marketplace ID directly, which will be auto-resolved. ### Code Example ```csharp // Supply ID directly instead of MarketPlace enum var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlaceID = "A2VIGQ35RCS4UG" // UAE marketplace }; // AmazonConnection will auto-resolve this to MarketPlace.UnitedArabEmirates var connection = new AmazonConnection(credential); ``` ``` -------------------------------- ### Full Constructor Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Initializes an AmazonCredential object with provided LWA authentication details and optional proxy settings. ```APIDOC ## Full Constructor ### Description Initializes an AmazonCredential object with provided LWA authentication details and optional proxy settings. AWS-related parameters are deprecated and ignored. ### Signature ```csharp public AmazonCredential( string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret, string RefreshToken, string ProxyAddress = null) ``` ### Parameters #### Constructor Parameters - **AccessKey** (`string`) - Optional - Deprecated; AWS IAM access key (not used) - **SecretKey** (`string`) - Optional - Deprecated; AWS IAM secret key (not used) - **RoleArn** (`string`) - Optional - Deprecated; AWS IAM role ARN (not used) - **ClientId** (`string`) - Required - LWA application ID (`amzn1.application-...`) - **ClientSecret** (`string`) - Required - LWA application secret - **RefreshToken** (`string`) - Required - LWA refresh token for token exchange - **ProxyAddress** (`string`) - Optional - Optional proxy URL (e.g., `http://proxy.corp:8080`) ### Example ```csharp var credential = new AmazonCredential( ClientId: "amzn1.application-oa2-client.xxxxxxxxxxxxx", ClientSecret: "amzn1.ask.bundle.xxxxxxxxxxxxx", RefreshToken: "Atzr|IwEBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ProxyAddress: null); ``` ``` -------------------------------- ### Disable Rate Limiting (Not Recommended) Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Example of configuring Amazon credentials to disable rate limiting. This is not recommended. ```APIDOC ## Disable Rate Limiting (Not Recommended) ### Description Example of configuring Amazon credentials to disable rate limiting. This is not recommended. ### Code Example ```csharp var credential = new AmazonCredential() { ClientId = "amzn1.application-oa2-client.xxxxx", ClientSecret = "xxxxxxxxxx", RefreshToken = "Atzr|xxxxx", MarketPlace = MarketPlace.UnitedStates, IsActiveLimitRate = false }; ``` ``` -------------------------------- ### Configure AmazonConnection with MarketPlaceID String Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Instantiate AmazonConnection using a MarketPlaceID string for configuration. Ensure all required credentials are provided. ```CSharp AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential() { ClientId = "amzn1.application-XXX-client.XXXXXXXXXXXXXXXXXXXXXXXXXXXX", ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", RefreshToken= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", MarketPlaceID = "A2VIGQ35RCS4UG" }); ``` -------------------------------- ### Get Listing Restrictions Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieve listing restrictions by providing the ASIN and Seller ID in the `ParameterGetListingsRestrictions` object. ```CSharp var result = amazonConnection.Restrictions.GetListingsRestrictions( new Parameter.Restrictions.ParameterGetListingsRestrictions { asin = "AAAAAAAAAA", sellerId = "AXXXXXXXXXXXX" }); ``` -------------------------------- ### Manual RDT Management and Usage Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/token-service.md Demonstrates the process of manually creating an RDT, caching it within the credentials, and then using the cached token to make API calls. ```csharp // 1. Create RDT var rdt = await connection.Tokens.CreateRestrictedDataTokenAsync( new CreateRestrictedDataTokenRequest { restrictedResources = new List { new RestrictedResource { method = "GET", path = "/orders/v0/orders", dataElements = new List { "buyerInfo", "shippingAddress" } } } }); // 2. Cache it manually in credential var credential = connection.Credentials; var tokenResponse = new TokenResponse { access_token = rdt, expires_in = 3600 }; credential.SetToken(TokenDataType.PII, tokenResponse); // 3. Use the cached token var orders = await connection.Orders.GetOrdersAsync(new ParameterOrderList { IsNeedRestrictedDataToken = false // Skip auto-creation; use cached token }); ``` -------------------------------- ### Handle AmazonUnauthorizedException Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/errors.md Example of how to catch and handle an AmazonUnauthorizedException, typically used for refreshing or re-authorizing credentials when authentication fails. ```csharp try { var connection = new AmazonConnection(credential); var orders = connection.Orders.GetOrders(parameters); } catch (AmazonUnauthorizedException ex) { Console.WriteLine($"Auth failed: {ex.Detail}"); // Refresh or re-authorize credentials } ``` -------------------------------- ### Get Subscription by ID Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/notification-service.md Retrieves a single subscription by its unique identifier. Use this to check the status or details of an existing subscription. ```csharp public Subscription GetSubscriptionById(string subscriptionId) public async Task GetSubscriptionByIdAsync(string subscriptionId, CancellationToken cancellationToken = default) ``` ```csharp var sub = await connection.Notification.GetSubscriptionByIdAsync("sub-12345"); Console.WriteLine($"Type: {sub.NotificationType}"); ``` -------------------------------- ### GetCompetitiveSummary / GetCompetitiveSummaryAsync Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/product-pricing-service.md Batch operation (v2022-05-01) returning featured buying options, reference prices, lowest priced offers, and similar items (added April 2026) for up to 20 ASIN/marketplace pairs. ```APIDOC ## GetCompetitiveSummary / GetCompetitiveSummaryAsync ### Description Batch operation (v2022-05-01) returning featured buying options, reference prices, lowest priced offers, and similar items (added April 2026) for up to 20 ASIN/marketplace pairs. ### Method Signature ```csharp public async Task GetCompetitiveSummaryAsync(CompetitiveSummaryBatchRequest request) ``` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **request** (`CompetitiveSummaryBatchRequest`) - Required - List of up to 20 requests, each with ASIN, marketplace, and optional includedData - **cancellationToken** (`CancellationToken`) - Optional - Cancellation token ### Included Data Options - `buyingOptions` — featured buying options - `referencePrice` — Amazon's reference price - `offerCounts` — number of sellers at each price tier - `lowestPrices` — lowest FBA and MFN prices - `similarItems` — **new in April 2026** — related products with ASIN, title, price ### Rate Limit `RateLimitType.ProductPricing_GetCompetitiveSummary` (0.033 req/s, burst 1) ### Throws `AmazonQuotaExceededException` (rate limit is strict) ### Request Example ```csharp var response = await connection.ProductPricing.GetCompetitiveSummaryAsync(new CompetitiveSummaryBatchRequest { Requests = new List { new CompetitiveSummaryRequest { Asin = "B00CZC5F0G", MarketplaceId = MarketPlace.UnitedStates.ID, IncludedData = new List { CompetitiveSummaryIncludedData.similarItems, CompetitiveSummaryIncludedData.lowestPrices } } } }); foreach (var r in response.Responses) { // New: Access similar items if (r.Body?.SimilarItems != null) foreach (var group in r.Body.SimilarItems) foreach (var item in group.Items) Console.WriteLine($"Similar ASIN: {item.Asin} - {item.Title}"); // Lowest prices if (r.Body?.LowestPrices != null) foreach (var lp in r.Body.LowestPrices) Console.WriteLine($"FBA: ${lp.ListingPrice?.Amount}"); } ``` ### Response #### Success Response (200) - **CompetitiveSummaryBatchResponse** - Contains a list of responses, one for each input request. #### Response Example (See Request Example for response handling) ``` -------------------------------- ### Create Subscription with Aggregation Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/notification-service.md Creates a subscription with event filtering and aggregation settings. Specify marketplace IDs and the desired aggregation time period. ```csharp var subscription = await connection.Notification.CreateSubscriptionAsync( new ParameterCreateSubscription { destinationId = destinationId, notificationType = NotificationType.ANY_OFFER_CHANGED, payloadVersion = "1.0", processingDirective = new ProcessingDirective { EventFilter = new EventFilter { EventFilterType = "ANY_OFFER_CHANGED", MarketplaceIds = new List { "ATVPDKIKX0DER" }, AggregationSettings = new AggregationSettings { AggregationTimePeriod = AggregationTimePeriod.FiveMinutes } } } }); ``` -------------------------------- ### Report Manager - Get Products Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Uses the ReportManager to retrieve product data. This is a convenience method for the GET_MERCHANT_LISTINGS_ALL_DATA report type. ```CSharp ReportManager reportManager = new ReportManager(amazonConnection); var products = reportManager.GetProducts(); //GET_MERCHANT_LISTINGS_ALL_DATA ``` -------------------------------- ### Configure Logging with Microsoft.Extensions.Logging Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/configuration.md Integrate with Microsoft.Extensions.Logging for structured logs. Services will use the provided ILoggerFactory to emit structured logs. ```csharp var loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); builder.AddDebug(); }); var connection = new AmazonConnection(credential, loggerFactory: loggerFactory); ``` -------------------------------- ### Core Facade - AmazonConnection Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/README.md The main entry point for interacting with various Amazon SP-API services. It lazily initializes over 30 service clients. ```APIDOC ## AmazonConnection ### Description Main entry point for the SDK, providing access to various service clients. ### Usage `connection.ServiceName` ``` -------------------------------- ### Get Competitive Pricing Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Retrieves competitive pricing details for a given ASIN in a specific marketplace. Requires `MarketPlaceId` and an array of `Asins`. ```CSharp var data = amazonConnection.ProductPricing.GetCompetitivePricing( new Parameter.ProductPricing.ParameterGetCompetitivePricing() { MarketplaceId = MarketPlace.UnitedArabEmirates.ID, Asins = new string[] { "B00CZC5F0G" }, }); ``` -------------------------------- ### Create AmazonCredential with Full Constructor Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/_autodocs/api-reference/amazon-credential.md Instantiate AmazonCredential with LWA authentication details and optional proxy configuration. AWS-related parameters are ignored. ```csharp public AmazonCredential( string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret, string RefreshToken, string ProxyAddress = null) ``` ```csharp var credential = new AmazonCredential( ClientId: "amzn1.application-oa2-client.xxxxxxxxxxxxx", ClientSecret: "amzn1.ask.bundle.xxxxxxxxxxxxx", RefreshToken: "Atzr|IwEBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ProxyAddress: null); ``` -------------------------------- ### Report Manager - Get Inventory Aging Source: https://github.com/abuzuhri/amazon-sp-api-csharp/blob/main/README.md Uses the ReportManager to retrieve inventory aging data. This corresponds to the GET_FBA_INVENTORY_AGED_DATA report type. ```CSharp var inventoryAging = reportManager.GetInventoryAging(); //GET_FBA_INVENTORY_AGED_DATA ```