Loqate.Core 0.0.1-beta.4

Prefix Reserved
This is a prerelease version of Loqate.Core.
dotnet add package Loqate.Core --version 0.0.1-beta.4
                    
NuGet\Install-Package Loqate.Core -Version 0.0.1-beta.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Loqate.Core" Version="0.0.1-beta.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Loqate.Core" Version="0.0.1-beta.4" />
                    
Directory.Packages.props
<PackageReference Include="Loqate.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Loqate.Core --version 0.0.1-beta.4
                    
#r "nuget: Loqate.Core, 0.0.1-beta.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Loqate.Core@0.0.1-beta.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Loqate.Core&version=0.0.1-beta.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Loqate.Core&version=0.0.1-beta.4&prerelease
                    
Install as a Cake Tool

Loqate.Core

SDK Example Usage

Example

using Loqate.Core;
using Loqate.Core.Models.Components;
using Loqate.Core.Models.Requests;

var sdk = new LoqateCore(
    source: "loqate-core-sdk-typescript",
    apiKey: "<YOUR_API_KEY_HERE>"
);

CaptureInteractiveFindRequest req = new CaptureInteractiveFindRequest() {
    Key = "AA11-AA11-AA11-AA11",
    Text = "wr5 3da",
    Container = "GB|RM|ENG|3DA-WR5",
    Origin = "52.182,-2.222",
    Countries = "GB,US,CA",
    Limit = 10,
    Language = "10",
    Bias = false,
    Filters = "",
    GeoFence = "",
};

var res = await sdk.Capture.FindAsync(req);

// handle response

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
ApiKey apiKey API key

To authenticate with the API the ApiKey parameter must be set when initializing the SDK client instance. For example:

using Loqate.Core;
using Loqate.Core.Models.Components;
using Loqate.Core.Models.Requests;

var sdk = new LoqateCore(
    apiKey: "<YOUR_API_KEY_HERE>",
    source: "loqate-core-sdk-typescript"
);

CaptureInteractiveFindRequest req = new CaptureInteractiveFindRequest() {
    Key = "AA11-AA11-AA11-AA11",
    Text = "wr5 3da",
    Container = "GB|RM|ENG|3DA-WR5",
    Origin = "52.182,-2.222",
    Countries = "GB,US,CA",
    Limit = 10,
    Language = "10",
    Bias = false,
    Filters = "",
    GeoFence = "",
};

var res = await sdk.Capture.FindAsync(req);

// handle response

Global Parameters

A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set SOURCE to "loqate-core-sdk-typescript" at SDK initialization and then you do not have to pass the same value on calls to operations like Find. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.

Available Globals

The following global parameter is available.

Name Type Description
source string The Source parameter.

Example

using Loqate.Core;
using Loqate.Core.Models.Components;
using Loqate.Core.Models.Requests;

var sdk = new LoqateCore(
    source: "loqate-core-sdk-typescript",
    apiKey: "<YOUR_API_KEY_HERE>"
);

CaptureInteractiveFindRequest req = new CaptureInteractiveFindRequest() {
    Key = "AA11-AA11-AA11-AA11",
    Text = "wr5 3da",
    Container = "GB|RM|ENG|3DA-WR5",
    Origin = "52.182,-2.222",
    Countries = "GB,US,CA",
    Limit = 10,
    Language = "10",
    Bias = false,
    Filters = "",
    GeoFence = "",
};

var res = await sdk.Capture.FindAsync(req);

// handle response

Error Handling

LoqateCoreException is the base exception class for all HTTP error responses. It has the following properties:

Property Type Description
Message string Error message
Request HttpRequestMessage HTTP request object
Response HttpResponseMessage HTTP response object

Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.

Example

using Loqate.Core;
using Loqate.Core.Models.Components;
using Loqate.Core.Models.Errors;
using Loqate.Core.Models.Requests;
using System.Collections.Generic;

var sdk = new LoqateCore(
    source: "loqate-core-sdk-typescript",
    apiKey: "<YOUR_API_KEY_HERE>"
);

try
{
    CaptureInteractiveFindRequest req = new CaptureInteractiveFindRequest() {
        Key = "AA11-AA11-AA11-AA11",
        Text = "wr5 3da",
        Container = "GB|RM|ENG|3DA-WR5",
        Origin = "52.182,-2.222",
        Countries = "GB,US,CA",
        Limit = 10,
        Language = "10",
        Bias = false,
        Filters = "",
        GeoFence = "",
    };

    var res = await sdk.Capture.FindAsync(req);

    // handle response
}
catch (LoqateCoreException ex)  // all SDK exceptions inherit from LoqateCoreException
{
    // ex.ToString() provides a detailed error message
    System.Console.WriteLine(ex);

    // Base exception fields
    HttpRequestMessage request = ex.Request;
    HttpResponseMessage response = ex.Response;
    var statusCode = (int)response.StatusCode;
    var responseBody = ex.Body;

    if (ex is CaptureInteractiveFindError) // different exceptions may be thrown depending on the method
    {
        // Check error data fields
        CaptureInteractiveFindErrorPayload payload = ex.Payload;
        List<CaptureInteractiveFindErrorItem> Items = payload.Items;
        HTTPMetadata HttpMeta = payload.HttpMeta;
    }

    // An underlying cause may be provided
    if (ex.InnerException != null)
    {
        Exception cause = ex.InnerException;
    }
}
catch (System.Net.Http.HttpRequestException ex)
{
    // Check ex.InnerException for Network connectivity errors
}

Error Classes

Primary exception:

<details><summary>Less common exceptions (66)</summary>

* Refer to the relevant documentation to determine whether an exception applies to a specific operation.

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using Loqate.Core;
using Loqate.Core.Models.Components;
using Loqate.Core.Models.Requests;

var sdk = new LoqateCore(
    serverUrl: "https://api.addressy.com",
    source: "loqate-core-sdk-typescript",
    apiKey: "<YOUR_API_KEY_HERE>"
);

CaptureInteractiveFindRequest req = new CaptureInteractiveFindRequest() {
    Key = "AA11-AA11-AA11-AA11",
    Text = "wr5 3da",
    Container = "GB|RM|ENG|3DA-WR5",
    Origin = "52.182,-2.222",
    Countries = "GB,US,CA",
    Limit = 10,
    Language = "10",
    Bias = false,
    Filters = "",
    GeoFence = "",
};

var res = await sdk.Capture.FindAsync(req);

// handle response

Custom HTTP Client

The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native HttpClient. This client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle errors and response.

The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK, or provide your own custom implementation with customized configuration such as custom message handlers, timeouts, connection pooling, and other HTTP client settings.

The following example shows how to create a custom HTTP client with request modification and error handling:

using Loqate.Core;
using Loqate.Core.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
    private readonly ISpeakeasyHttpClient _defaultClient;

    public CustomHttpClient()
    {
        _defaultClient = new SpeakeasyHttpClient();
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        // Add custom header and timeout
        request.Headers.Add("x-custom-header", "custom value");
        request.Headers.Add("x-request-timeout", "30");
        
        try
        {
            var response = await _defaultClient.SendAsync(request, cancellationToken);
            // Log successful response
            Console.WriteLine($"Request successful: {response.StatusCode}");
            return response;
        }
        catch (Exception error)
        {
            // Log error
            Console.WriteLine($"Request failed: {error.Message}");
            throw;
        }
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
        _defaultClient?.Dispose();
    }
}

// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new LoqateCore(client: customHttpClient);

<details> <summary>You can also provide a completely custom HTTP client with your own configuration:</summary>

using Loqate.Core.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
    private readonly HttpClient _httpClient;

    public AdvancedHttpClient()
    {
        var handler = new HttpClientHandler()
        {
            MaxConnectionsPerServer = 10,
            // ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
        };

        _httpClient = new HttpClient(handler)
        {
            Timeout = TimeSpan.FromSeconds(30)
        };
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
    }
}

var sdk = LoqateCore.Builder()
    .WithClient(new AdvancedHttpClient())
    .Build();

</details>

<details> <summary>For simple debugging, you can enable request/response logging by implementing a custom client:</summary>

public class LoggingHttpClient : ISpeakeasyHttpClient
{
    private readonly ISpeakeasyHttpClient _innerClient;

    public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
    {
        _innerClient = innerClient ?? new SpeakeasyHttpClient();
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        // Log request
        Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
        
        var response = await _innerClient.SendAsync(request, cancellationToken);
        
        // Log response
        Console.WriteLine($"Received {response.StatusCode} response");
        
        return response;
    }

    public void Dispose() => _innerClient?.Dispose();
}

var sdk = new LoqateCore(client: new LoggingHttpClient());

</details>

The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1-beta.4 363 12/8/2025
0.0.1-beta.3 280 11/17/2025
0.0.1-beta.2 122 10/15/2025
0.0.1-beta.1 131 10/6/2025