---
title: "Use the .NET library"
description: "How to install and configure the Amplia Reg .NET client library (Lacuna.AmpliaRegNg.Client) in ASP.NET Core or other .NET applications, set the culture and handle exceptions."
canonical: "https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/dotnet-client"
locale: "en"
product: "Amplia Reg"
last_updated: "2026-11-17"
---

# Use the .NET library

The .NET client library calls the [Amplia Reg](https://docs.lacunasoftware.com/en-us/articles/amplia-reg) API for you. The .NET examples in this guide use the `IAmpliaRegService`
interface it provides. In other languages, call the REST API directly: see [API authentication and errors](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/authentication).

## Before you start

* The endpoint and the API key. See [Get started](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/get-started#api-key).
* A project on .NET Framework 4.6.1 or later, or .NET Core 2.0 or later. The library targets .NET Standard 2.0.

## Install the package

Add the NuGet package [Lacuna.AmpliaRegNg.Client](https://www.nuget.org/packages/Lacuna.AmpliaRegNg.Client/):

```bash
dotnet add package Lacuna.AmpliaRegNg.Client
```

## Configure in ASP.NET Core

1. Add the code below to the `ConfigureServices()` method of the *Startup.cs* class:

   ```cs
   public void ConfigureServices(IServiceCollection services) {
   	...
   	services.AddAmpliaReg().Configure(Configuration.GetSection("AmpliaReg"));
   }
   ```

2. In *appsettings.json*, add the `AmpliaReg` section:

   ```json
   {
   	...
   	"AmpliaReg": {
   		"Endpoint": "YOUR_INSTANCE_ENDPOINT_HERE",
   		"ApiKey": "YOUR_API_KEY_HERE"
   	},
   	...
   }
   ```

3. Where your application calls the API, request an `IAmpliaRegService` instance through *dependency injection*:

   ```cs
   using Lacuna.AmpliaRegNg.Client;

   public class MyController : ApiController {

   	private readonly IAmpliaRegService ampliaRegService;

   	public MyController(IAmpliaRegService ampliaRegService) {
   		this.ampliaRegService = ampliaRegService;
   	}

   	...
   }
   ```

## Configure in other .NET applications

Use the endpoint and the API key to get an `IAmpliaRegService` implementation from the static `AmpliaRegServiceFactory` class:

```cs
using Lacuna.AmpliaRegNg.Client;

public class MyController : ApiController {

	private readonly IAmpliaRegService ampliaRegService;

	public MyController() {
		this.ampliaRegService = AmpliaRegServiceFactory.GetService(new AmpliaRegOptions() {
			Endpoint = ConfigurationManager.AppSettings["AmpliaRegEndpoint"],
			ApiKey = ConfigurationManager.AppSettings["AmpliaRegApiKey"],
		});
	}

	...
}
```

In the example, the endpoint and the key are in the `appSettings` section of *web.config*. You can keep them in a different
location. In production, keep the API key in a secrets vault or in an environment variable.

## Set the culture

The library tells the API the culture of the current thread (`Thread.CurrentThread.CurrentUICulture`). To use a fixed culture, set
`CultureName`.

In ASP.NET Core, in the `AmpliaReg` section of *appsettings.json*:

```json
{
	...
	"AmpliaReg": {
		...,
		"CultureName": "en-US"
	},
	...
}
```

In other .NET applications, in the `AmpliaRegOptions` object:

```cs
this.ampliaRegService = AmpliaRegServiceFactory.GetService(new AmpliaRegOptions() {
	...,
	CultureName = "en-US",
});
```

## Handle exceptions

The `IAmpliaRegService` methods can throw:

* `AmpliaRegException`: an API error, usually a request that can be fixed. The `Code` property has the [error code](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/error-codes).
* `RestErrorException`: an HTTP call error. The `StatusCode` property has the [HTTP status code](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/authentication#http-status-codes).

## Features the library does not have

The library has no method for these routes:

* The [`v2` order creation route](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/create-order#v2).
* The holder type list, `GET /api/holder-types`.

For these routes, call the REST API directly, with the same endpoint and API key.

## See also

* [API authentication and errors](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/authentication)
* [Error codes](https://docs.lacunasoftware.com/en-us/articles/amplia-reg/integration/error-codes)
