Loqate.Core
0.0.1-beta.4
Prefix Reserved
dotnet add package Loqate.Core --version 0.0.1-beta.4
NuGet\Install-Package Loqate.Core -Version 0.0.1-beta.4
<PackageReference Include="Loqate.Core" Version="0.0.1-beta.4" />
<PackageVersion Include="Loqate.Core" Version="0.0.1-beta.4" />
<PackageReference Include="Loqate.Core" />
paket add Loqate.Core --version 0.0.1-beta.4
#r "nuget: Loqate.Core, 0.0.1-beta.4"
#:package Loqate.Core@0.0.1-beta.4
#addin nuget:?package=Loqate.Core&version=0.0.1-beta.4&prerelease
#tool nuget:?package=Loqate.Core&version=0.0.1-beta.4&prerelease
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:
LoqateCoreException: The base class for HTTP error responses.
<details><summary>Less common exceptions (66)</summary>
System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect theex.InnerException.Inheriting from
LoqateCoreException:CleansingInternationalBatchBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalTypeAheadBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesDistanceFinderNearbyBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesMappingGetUrlBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesLocationManagementCreateListBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesLocationManagementDeleteListOrPointBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesLocationManagementUpdateListOrPointBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*LocationServicesLocationManagementGetListsBadRequestErrorResponseSelfContained: BadRequest. Status code400. Applicable to 1 of 36 methods.*CaptureInteractiveFindError: BadRequest. Applicable to 1 of 36 methods.*CaptureInteractiveRetrieveError: BadRequest. Applicable to 1 of 36 methods.*CaptureInteractiveGeoLocationError: BadRequest. Applicable to 1 of 36 methods.*StoreFinderInteractiveFindPlaceNamesError: BadRequest. Applicable to 1 of 36 methods.*StoreFinderInteractiveRetrieveCoordinatesError: BadRequest. Applicable to 1 of 36 methods.*EmailValidationBatchValidateError: BadRequest. Applicable to 1 of 36 methods.*EmailValidationInteractiveValidateError: BadRequest. Applicable to 1 of 36 methods.*PhoneNumberValidationInteractiveValidateError: BadRequest. Applicable to 1 of 36 methods.*BankAccountValidationBatchValidateError: BadRequest. Applicable to 1 of 36 methods.*BankAccountValidationInteractiveValidateError: BadRequest. Applicable to 1 of 36 methods.*BankAccountValidationInteractiveRetrieveBySortcoError: BadRequest. Applicable to 1 of 36 methods.*InternationalBankValidationInteractiveValidateError: BadRequest. Applicable to 1 of 36 methods.*DistancesAndDirectionsInteractiveDirectionsError: BadRequest. Applicable to 1 of 36 methods.*DistancesAndDirectionsInteractiveDistanceError: BadRequest. Applicable to 1 of 36 methods.*GeocodingInternationalGeocodeError: BadRequest. Applicable to 1 of 36 methods.*GeocodingInternationalPositionToCountryError: BadRequest. Applicable to 1 of 36 methods.*GeocodingInternationalRetrieveNearestPlacesError: BadRequest. Applicable to 1 of 36 methods.*GeocodingInternationalReverseGeocodeError: BadRequest. Applicable to 1 of 36 methods.*ExtrasWebIp2CountryError: BadRequest. Applicable to 1 of 36 methods.*GeocodingUKFindError: BadRequest. Applicable to 1 of 36 methods.*GeocodingUKGeocodeError: BadRequest. Applicable to 1 of 36 methods.*GeocodingUKRetrieveError: BadRequest. Applicable to 1 of 36 methods.*GeocodingUKRetrieveNearestPlacesError: BadRequest. Applicable to 1 of 36 methods.*GeocodingUKReverseGeocodeError: BadRequest. Applicable to 1 of 36 methods.*GovernmentDataPostzonRetrieveByCoordinatesError: BadRequest. Applicable to 1 of 36 methods.*GovernmentDataPostzonRetrieveByPostcodeError: BadRequest. Applicable to 1 of 36 methods.*GovernmentDataPostzonRetrieveByPostcodeOrPlaceError: BadRequest. Applicable to 1 of 36 methods.*CleansingInternationalBatchUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalTypeAheadUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesDistanceFinderNearbyUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesMappingGetUrlUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesLocationManagementCreateListUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesLocationManagementDeleteListOrPointUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesLocationManagementUpdateListOrPointUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*LocationServicesLocationManagementGetListsUnauthorizedErrorResponseSelfContained: Unauthorized. Status code401. Applicable to 1 of 36 methods.*CleansingInternationalBatchForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalTypeAheadForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesDistanceFinderNearbyForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesMappingGetUrlForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesLocationManagementCreateListForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesLocationManagementDeleteListOrPointForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesLocationManagementUpdateListOrPointForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*LocationServicesLocationManagementGetListsForbiddenErrorResponseSelfContained: Forbidden. Status code403. Applicable to 1 of 36 methods.*NotFoundErrorResponseSelfContained: NotFound. Status code404. Applicable to 1 of 36 methods.*CleansingInternationalBatchInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalTypeAheadInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesGeocodingGlobalInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesDistanceFinderNearbyInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesMappingGetUrlInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesLocationManagementCreateListInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesLocationManagementDeleteListOrPointInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesLocationManagementUpdateListOrPointInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*LocationServicesLocationManagementGetListsInternalServerErrorErrorResponseSelfContained: InternalServerError. Status code500. Applicable to 1 of 36 methods.*ResponseValidationError: Thrown when the response data could not be deserialized into the expected type. </details>
* 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 | Versions 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. |
-
net8.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
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 |