C# and .NET SDK
Last updated · Changelog · OpenAPI spec · Markdown
Our official C# SDK provides seamless integration for .NET applications, with full async/await support and strong typing.
Installation
dotnet add package ShopSavvy.SdkQuick Start
using ShopSavvy;
// Create a new client
var client = new ShopSavvyClient("ss_live_your_api_key_here");
// Get product details
var product = await client.GetProductDetailsAsync("012345678901");
Console.WriteLine($"Product: {product.Data.Name}");
// Get current offers
var offers = await client.GetCurrentOffersAsync("012345678901");
foreach (var offer in offers.Data)
{
Console.WriteLine($"{offer.Retailer}: ${offer.Price:F2}");
}
// Get price history
var history = await client.GetPriceHistoryAsync(
"012345678901",
new DateTime(2024, 1, 1),
new DateTime(2024, 1, 31)
);Dependency Injection
// Program.cs or Startup.cs
services.AddShopSavvy(options =>
{
options.ApiKey = Configuration["ShopSavvy:ApiKey"];
options.BaseUrl = "https://api.shopsavvy.com/v1";
});
// In your controller
[ApiController]
public class ProductsController : ControllerBase
{
private readonly IShopSavvyClient _client;
public ProductsController(IShopSavvyClient client)
{
_client = client;
}
[HttpGet("{barcode}")]
public async Task<IActionResult> GetProduct(string barcode)
{
var product = await _client.GetProductDetailsAsync(barcode);
return Ok(product);
}
}Features
- Full async/await support
- Strong typing with C# models
- Dependency injection support
- ConfigureAwait(false) for library code
- Custom exception types
- Support for .NET 6+
Was this page helpful?