# C# and .NET SDK

> dotnet add package ShopSavvy.Sdk to call the ShopSavvy Data API from .NET: product lookups, retailer offers, price history and dependency injection setup.

*Source: https://shopsavvy.com/data/documentation/sdk-csharp* · Part of the [ShopSavvy Data API documentation](https://shopsavvy.com/data/documentation.md)

---

Our official C# SDK provides seamless integration for .NET applications, with full async/await support and strong typing.

- [View on GitHub](https://github.com/shopsavvy/sdk-csharp)
- [NuGet](https://www.nuget.org/packages/ShopSavvy.Sdk/)

## Installation

```bash
dotnet add package ShopSavvy.Sdk
```

## Quick Start

```csharp
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

```csharp
// 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+
