Skip to content

.NET SDK ​

This page starts with setup prerequisites and then provides an overview of available .NET SDK examples.

Before You Start ​

Before implementing the examples, make sure you have the following in place:

  • A Dataset ID, Server URL, and an API Credential from My Relewise. Choose API Key or OAuth 2.0 (Client Credentials) for your backend integration.
  • A .NET project with NuGet access.
  • Implementation context from Implementation Steps.

Install the SDK from NuGet:

powershell
dotnet add package Relewise.Client

If you want to configure the client through app settings and dependency injection, use the extensions package:

powershell
dotnet add package Relewise.Client.Extensions

To learn more about the extensions package, view it on GitHub.

Authentication ​

The .NET SDK supports API Key and OAuth 2.0 (Client Credentials) authentication for backend integrations. Create an API Credential in My Relewise using your chosen method and grant only the permissions your integration requires.

Select a method below to see how to configure an SDK client. Replace the placeholders with your connection details, and keep API Keys and Client Secrets in secure server-side configuration.

The examples use Product view tracking to demonstrate an authenticated API call. Choose the client and operation that match your integration; the credential must have permission to perform that operation.

Configure the client with the Dataset ID, API Key, and Server URL. The SDK sends the API Key with each request as Authorization: APIKey <api-key>:

csharp
using Relewise.Client;
using Relewise.Client.DataTypes;

Guid datasetId = Guid.Parse("<Dataset ID>");
string apiKey = "<API Key>";
string serverUrl = "<Server URL>";

Tracker tracker = new Tracker(datasetId, apiKey, serverUrl);

// Example API call; requires permission to track Product views.
await tracker.TrackAsync(new ProductView(
    User.ByTemporaryId("<User ID>"),
    new Product("p-1")));

For both methods, each API request is subject to the credential's current permissions, enabled state, and IP restrictions. Configure permissions for the operations your integration calls.

Examples ​

Don't know us? Don't worry - you can find more information about us, by visiting our main page www.relewise.com