### Install via NuGet Source: https://github.com/thiagolunardi/upcitemdb/blob/master/README.md Install the SDK using the Package Manager Console. ```powershell PM> Install-Package UPCItemDb ``` -------------------------------- ### UPCItemDb SDK .NET - Installation Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Instructions on how to install the UPCItemDb SDK .NET package using the Package Manager Console. ```APIDOC ## Installation ```bash PM> Install-Package UPCItemDb ``` ``` -------------------------------- ### UPCItemDb SDK .NET - LookupByGetAsync Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Shows how to use the `LookupByGetAsync` method to retrieve product information by UPC/EAN codes using an HTTP GET request. Includes examples for single and multiple lookups, and accessing rate limit information. ```APIDOC ## LookupByGetAsync - Look Up Products by UPC Code (GET) Retrieves product information for one or more UPC/EAN codes using an HTTP GET request. This is ideal for looking up specific products when you know their barcode numbers. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); // Look up a single product by UPC code var singleResult = await client.LookupByGetAsync("885909456017"); Console.WriteLine($"Found {singleResult.Total} item(s)"); foreach (var item in singleResult.Items) { Console.WriteLine($"Title: {item.Title}"); Console.WriteLine($"Brand: {item.Brand}"); Console.WriteLine($"EAN: {item.EAN}"); Console.WriteLine($"UPC: {item.UPC}"); Console.WriteLine($"Description: {item.Description}"); Console.WriteLine($"Lowest Price: {item.LowestRecordedPrice} {item.Currency}"); // Access product images if (item.Images != null) { foreach (var imageUrl in item.Images) { Console.WriteLine($"Image: {imageUrl}"); } } // Access merchant offers if (item.Offers != null) { foreach (var offer in item.Offers) { Console.WriteLine($"Merchant: {offer.Merchant} - Price: {offer.Price} - {offer.Condition}"); } } } // Look up multiple products at once var multipleResult = await client.LookupByGetAsync("885909456017", "674785680773"); Console.WriteLine($"Found {multipleResult.Total} items for multiple UPCs"); // Check rate limit information Console.WriteLine($"Rate Limit Remaining: {singleResult.RateLimit.Remaining}/{singleResult.RateLimit.Limit}"); Console.WriteLine($"Rate Limit Resets: {singleResult.RateLimit.Reset}"); ``` ``` -------------------------------- ### Search Products by Keywords (GET) Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Use this method for simple keyword searches or advanced filtering by brand, category, and match mode via HTTP GET. Ensure the UPCItemDB client is initialized. ```csharp using UPCItemDb; using UPCItemDb.Requests; var client = new UPCItemDBClient(); // Simple keyword search var simpleResult = await client.SearchByGetAsync("iphone"); Console.WriteLine($"Found {simpleResult.Total} results for 'iphone'"); foreach (var item in simpleResult.Items) { Console.WriteLine($"- {item.Title} | {item.Brand} | ${item.LowestRecordedPrice}"); } // Advanced search with SearchParameters var advancedSearch = new SearchParameters("tablet") { Brand = "Samsung", // Filter by brand name Category = "Electronics", // Filter by category MatchMode = MatchMode.Phrase, // Strict matching (match all keywords) Type = "product", // "product" (default) or "book" Offset = 0 // Pagination offset }; var advancedResult = await client.SearchByGetAsync(advancedSearch); Console.WriteLine($"Found {advancedResult.Total} Samsung tablets"); Console.WriteLine($"Offset for next page: {advancedResult.OffSet}"); foreach (var item in advancedResult.Items) { Console.WriteLine($"Title: {item.Title}"); Console.WriteLine($"Model: {item.Model}"); Console.WriteLine($"Price Range: ${item.LowestRecordedPrice} - ${item.HighestRecordedPrice}"); } ``` -------------------------------- ### GET /search Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Searches for products using keywords via HTTP GET request. Supports simple keyword searches as well as advanced search with brand, category, and match mode filters. ```APIDOC ## GET /search ### Description Searches for products using keywords via HTTP GET request. Supports simple keyword searches as well as advanced search with brand, category, and match mode filters. ### Method GET ### Parameters #### Query Parameters - **s** (string) - Required - The search keyword string. - **brand** (string) - Optional - Filter by brand name. - **category** (string) - Optional - Filter by category. - **match_mode** (int) - Optional - 0 for Default, 1 for Phrase. - **type** (string) - Optional - "product" or "book". - **offset** (int) - Optional - Pagination offset. ``` -------------------------------- ### Lookup Products by UPC Code (GET) Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Retrieve product information using UPC/EAN codes via an HTTP GET request. This method supports looking up single or multiple products and provides rate limit details. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); // Look up a single product by UPC code var singleResult = await client.LookupByGetAsync("885909456017"); Console.WriteLine($"Found {singleResult.Total} item(s)"); foreach (var item in singleResult.Items) { Console.WriteLine($"Title: {item.Title}"); Console.WriteLine($"Brand: {item.Brand}"); Console.WriteLine($"EAN: {item.EAN}"); Console.WriteLine($"UPC: {item.UPC}"); Console.WriteLine($"Description: {item.Description}"); Console.WriteLine($"Lowest Price: {item.LowestRecordedPrice} {item.Currency}"); // Access product images if (item.Images != null) { foreach (var imageUrl in item.Images) { Console.WriteLine($"Image: {imageUrl}"); } } // Access merchant offers if (item.Offers != null) { foreach (var offer in item.Offers) { Console.WriteLine($"Merchant: {offer.Merchant} - Price: {offer.Price} - {offer.Condition}"); } } } // Look up multiple products at once var multipleResult = await client.LookupByGetAsync("885909456017", "674785680773"); Console.WriteLine($"Found {multipleResult.Total} items for multiple UPCs"); // Check rate limit information Console.WriteLine($"Rate Limit Remaining: {singleResult.RateLimit.Remaining}/{singleResult.RateLimit.Limit}"); Console.WriteLine($"Rate Limit Resets: {singleResult.RateLimit.Reset}"); ``` -------------------------------- ### POST /search Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Searches for products using keywords via HTTP POST request. This is functionally identical to the GET search endpoint. ```APIDOC ## POST /search ### Description Searches for products using keywords via HTTP POST request. This is functionally identical to the GET search endpoint. ### Method POST ### Request Body - **s** (string) - Required - The search keyword string. - **brand** (string) - Optional - Filter by brand name. - **category** (string) - Optional - Filter by category. - **match_mode** (int) - Optional - 0 for Default, 1 for Phrase. - **type** (string) - Optional - "product" or "book". - **offset** (int) - Optional - Pagination offset. ``` -------------------------------- ### Lookup Products by UPC Code (POST) Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Retrieve product information using UPC/EAN codes via an HTTP POST request. This method is an alternative to GET for lookup operations and supports single or multiple product lookups. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); // Look up a single product by UPC code using POST var result = await client.LookupByPostAsync("885909456017"); Console.WriteLine($"Product: {result.Items[0].Title}"); Console.WriteLine($"Brand: {result.Items[0].Brand}"); // Look up multiple products using POST var multiResult = await client.LookupByPostAsync("885909456017", "674785680773"); foreach (var item in multiResult.Items) { Console.WriteLine($"- {item.Title} ({item.UPC})"); } ``` -------------------------------- ### Build the project Source: https://github.com/thiagolunardi/upcitemdb/blob/master/README.md Use the .NET CLI to build the solution. ```bash dotnet build UPCItemDb.sln ``` -------------------------------- ### UPCItemDb SDK .NET - Creating a Client Instance Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Demonstrates how to create instances of the `UPCItemDBClient` for trial or production use with an API key. ```APIDOC ## Creating a Client Instance The `UPCItemDBClient` class is the main entry point for all API operations. It supports both trial mode (limited to 100 requests/day/IP) and production mode with an API key. ```csharp using UPCItemDb; // Create a trial client (100 requests/day limit) var client = new UPCItemDBClient(); // Create a trial client explicitly var trialClient = new UPCItemDBClient(UPCItemDBEnvironment.Trial); // Create a production client with API key var productionClient = new UPCItemDBClient(UPCItemDBEnvironment.Production, "your-api-key-here"); // The client implements IDisposable for proper resource cleanup using (var disposableClient = new UPCItemDBClient()) { // Use the client } ``` ``` -------------------------------- ### Instantiate the client Source: https://github.com/thiagolunardi/upcitemdb/blob/master/README.md Create an instance of the UpcItemDbClient. An empty constructor can be used for testing with limited requests. ```csharp var upcItemDbClient = new UpcItemDbClient(); ``` -------------------------------- ### Search Products by Keywords (POST) Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt This method is functionally identical to SearchByGetAsync but uses the HTTP POST method for searching products. It supports simple keyword searches and advanced filtering. ```csharp using UPCItemDb; using UPCItemDb.Requests; var client = new UPCItemDBClient(); // Simple keyword search via POST var result = await client.SearchByPostAsync("laptop"); Console.WriteLine($"Found {result.Total} laptops"); // Advanced search with brand filter via POST var searchParams = new SearchParameters("iphone") { Brand = "Apple", MatchMode = MatchMode.Default // Find best matches if no exact match }; var appleResult = await client.SearchByPostAsync(searchParams); foreach (var item in appleResult.Items) { Console.WriteLine($"Apple Product: {item.Title}"); Console.WriteLine($" ASIN: {item.ASIN}"); Console.WriteLine($" Color: {item.Color}"); Console.WriteLine($" Size: {item.Size}"); Console.WriteLine($" Weight: {item.Weight}"); Console.WriteLine($" Dimensions: {item.Dimension}"); } ``` -------------------------------- ### Create UPCItemDBClient Instance Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Instantiate the UPCItemDBClient for trial or production use. The client implements IDisposable for proper resource management. ```csharp using UPCItemDb; // Create a trial client (100 requests/day limit) var client = new UPCItemDBClient(); // Create a trial client explicitly var trialClient = new UPCItemDBClient(UPCItemDBEnvironment.Trial); // Create a production client with API key var productionClient = new UPCItemDBClient(UPCItemDBEnvironment.Production, "your-api-key-here"); // The client implements IDisposable for proper resource cleanup using (var disposableClient = new UPCItemDBClient()) { // Use the client } ``` -------------------------------- ### Configure Advanced Product Searches Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Utilize the SearchParameters class to define detailed search criteria, including keywords, brand, category, match mode, product type, and pagination offset. Initialize with keywords. ```csharp using UPCItemDb.Requests; // Basic search parameters (keywords required) var basicParams = new SearchParameters("wireless headphones"); // Full search configuration var fullParams = new SearchParameters("gaming mouse") { // Filter by brand name Brand = "Logitech", // Filter by product category Category = "Electronics", // Match mode: Default (0) = best matches, Phrase (1) = strict matching MatchMode = MatchMode.Phrase, // Product type: "product" (default) or "book" Type = "product", // Pagination offset (0 indicates no more results) Offset = 10 }; // Search for books var bookSearch = new SearchParameters("programming c#") { Type = "book", MatchMode = MatchMode.Default }; ``` -------------------------------- ### UPCItemDb SDK .NET - LookupByPostAsync Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Demonstrates how to use the `LookupByPostAsync` method to retrieve product information by UPC/EAN codes using an HTTP POST request. This method is functionally identical to `LookupByGetAsync` but uses POST. ```APIDOC ## LookupByPostAsync - Look Up Products by UPC Code (POST) Retrieves product information for one or more UPC/EAN codes using an HTTP POST request. This method is functionally identical to LookupByGetAsync but uses POST, which may be preferred for security or caching considerations. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); // Look up a single product by UPC code using POST var result = await client.LookupByPostAsync("885909456017"); Console.WriteLine($"Product: {result.Items[0].Title}"); Console.WriteLine($"Brand: {result.Items[0].Brand}"); // Look up multiple products using POST var multiResult = await client.LookupByPostAsync("885909456017", "674785680773"); foreach (var item in multiResult.Items) { Console.WriteLine($"- {item.Title} ({item.UPC})"); } ``` ``` -------------------------------- ### Handle API Errors with ErrorResponse Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Demonstrates how to check for and display error details from the client's ErrorResponse property when an API call fails. This is useful for diagnosing issues when a lookup or search operation does not return expected results. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); try { var result = await client.LookupByGetAsync("invalid-upc-code"); if (result == null || result.Items == null || result.Items.Length == 0) { // Check for error response if (client.ErrorResponse != null) { Console.WriteLine($"Error Code: {client.ErrorResponse.Code}"); Console.WriteLine($"Error Message: {client.ErrorResponse.Message}"); } else { Console.WriteLine("No items found for the provided UPC code"); } } } catch (Exception ex) { Console.WriteLine($"Request failed: {ex.Message}"); // Access error details if available if (client.ErrorResponse != null) { Console.WriteLine($"API Error: {client.ErrorResponse.Code} - {client.ErrorResponse.Message}"); } } ``` -------------------------------- ### Search for items Source: https://github.com/thiagolunardi/upcitemdb/blob/master/README.md Search for items using specific search parameters. ```csharp var items = await upcItemDbClient.SearchAsync(new SearchParameters("tablet")); ``` -------------------------------- ### Track API Rate Limits Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt Shows how to access and interpret rate limit information from the API response. This is crucial for monitoring usage and preventing API request limits from being exceeded. ```csharp using UPCItemDb; var client = new UPCItemDBClient(); var result = await client.LookupByGetAsync("885909456017"); // Access rate limit information from the response var rateLimit = result.RateLimit; Console.WriteLine($"Requests Remaining: {rateLimit.Remaining}"); Console.WriteLine($"Request Limit: {rateLimit.Limit}"); Console.WriteLine($"Current Request Count: {rateLimit.Current}"); Console.WriteLine($"Limit Resets At: {rateLimit.Reset}"); // Example: Check if approaching rate limit if (rateLimit.Remaining < 10) { Console.WriteLine($"Warning: Only {rateLimit.Remaining} requests remaining!"); Console.WriteLine($"Rate limit will reset at: {rateLimit.Reset}"); } ``` -------------------------------- ### Lookup an item Source: https://github.com/thiagolunardi/upcitemdb/blob/master/README.md Perform a lookup for a specific item using its UPC code. ```csharp var items = await upcItemDbClient.LookupAsync("4002293401102"); ``` -------------------------------- ### Control Keyword Matching with MatchMode Source: https://context7.com/thiagolunardi/upcitemdb/llms.txt The MatchMode enum allows you to specify how search keywords are matched. Use MatchMode.Default for best matches or MatchMode.Phrase for strict, exact phrase matching. ```csharp using UPCItemDb.Requests; // Default mode: Find best matches if no exact match for the whole phrase var defaultSearch = new SearchParameters("wireless bluetooth speaker") { MatchMode = MatchMode.Default // Value: 0 }; // Phrase mode: Strict matching - must match all search keywords var phraseSearch = new SearchParameters("wireless bluetooth speaker") { MatchMode = MatchMode.Phrase // Value: 1 }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.