ForeverTools.APILayer
1.0.1
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package ForeverTools.APILayer --version 1.0.1
NuGet\Install-Package ForeverTools.APILayer -Version 1.0.1
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="ForeverTools.APILayer" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ForeverTools.APILayer" Version="1.0.1" />
<PackageReference Include="ForeverTools.APILayer" />
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 ForeverTools.APILayer --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ForeverTools.APILayer, 1.0.1"
#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 ForeverTools.APILayer@1.0.1
#: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=ForeverTools.APILayer&version=1.0.1
#tool nuget:?package=ForeverTools.APILayer&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ForeverTools.APILayer
A unified .NET client for the APILayer marketplace APIs. Access IP geolocation, currency exchange rates, phone validation, email verification, and more with a single API key.
Features
- IP Geolocation - Look up geographic location, ISP, and security data for any IP address
- Currency Exchange - Real-time and historical exchange rates for 168+ currencies
- Phone Validation - Validate phone numbers and get carrier/line type information
- Email Validation - Verify email deliverability, detect disposables, and more
- Multi-targeting - Supports .NET 8.0, .NET 6.0, and .NET Standard 2.0
- Async/await - Full async support with cancellation tokens
- Dependency Injection - Built-in support for Microsoft.Extensions.DependencyInjection
Installation
dotnet add package ForeverTools.APILayer
Quick Start
Get your API key at apilayer.com.
using ForeverTools.APILayer;
// Create client
var client = new ApiLayerClient("your-api-key");
// IP Geolocation
var geoResult = await client.GetIpGeolocationAsync("8.8.8.8");
if (geoResult.Success)
{
Console.WriteLine($"Country: {geoResult.Data.CountryName}");
Console.WriteLine($"City: {geoResult.Data.City}");
}
// Currency Exchange
var ratesResult = await client.GetExchangeRatesAsync("USD", new[] { "EUR", "GBP", "JPY" });
if (ratesResult.Success)
{
Console.WriteLine($"EUR: {ratesResult.Data.GetRate("EUR")}");
}
// Currency Conversion
var convertResult = await client.ConvertCurrencyAsync("USD", "EUR", 100);
if (convertResult.Success)
{
Console.WriteLine($"100 USD = {convertResult.Data.Result} EUR");
}
// Phone Validation
var phoneResult = await client.ValidatePhoneAsync("+14155552671");
if (phoneResult.Success && phoneResult.Data.Valid)
{
Console.WriteLine($"Carrier: {phoneResult.Data.Carrier}");
Console.WriteLine($"Type: {phoneResult.Data.LineType}");
}
// Email Validation
var emailResult = await client.ValidateEmailAsync("test@example.com");
if (emailResult.Success)
{
Console.WriteLine($"Valid format: {emailResult.Data.FormatValid}");
Console.WriteLine($"Deliverable: {emailResult.Data.IsDeliverable}");
Console.WriteLine($"Disposable: {emailResult.Data.Disposable}");
}
Dependency Injection
// In Program.cs or Startup.cs
services.AddForeverToolsApiLayer("your-api-key");
// Or from configuration
services.AddForeverToolsApiLayer(configuration);
appsettings.json:
{
"APILayer": {
"ApiKey": "your-api-key",
"TimeoutSeconds": 30
}
}
Inject and use:
public class MyService
{
private readonly ApiLayerClient _client;
public MyService(ApiLayerClient client)
{
_client = client;
}
public async Task<string> GetUserCountry(string ipAddress)
{
var result = await _client.GetIpGeolocationAsync(ipAddress);
return result.Success ? result.Data.CountryName : "Unknown";
}
}
API Reference
IP Geolocation
// Look up any IP address
var result = await client.GetIpGeolocationAsync("8.8.8.8");
// Look up caller's IP
var myIp = await client.GetMyIpGeolocationAsync();
// Access detailed data
result.Data.CountryCode // "US"
result.Data.City // "Mountain View"
result.Data.Latitude // 37.386
result.Data.TimeZone.Id // "America/Los_Angeles"
result.Data.Currency.Code // "USD"
result.Data.Security.IsProxy // false
Currency Exchange
// Latest rates
var rates = await client.GetExchangeRatesAsync("USD");
// Historical rates
var historical = await client.GetHistoricalRatesAsync("2024-01-15", "USD");
// Convert currency
var conversion = await client.ConvertCurrencyAsync("USD", "EUR", 100);
// Time series (365 days max)
var series = await client.GetTimeSeriesAsync("2024-01-01", "2024-01-31", "USD");
// Rate fluctuation
var fluctuation = await client.GetFluctuationAsync("2024-01-01", "2024-01-31", "USD");
// Available symbols
var symbols = await client.GetCurrencySymbolsAsync();
Phone Validation
var result = await client.ValidatePhoneAsync("+14155552671");
result.Data.Valid // true
result.Data.LocalFormat // "4155552671"
result.Data.InternationalFormat // "+14155552671"
result.Data.CountryCode // "US"
result.Data.Carrier // "AT&T Mobility LLC"
result.Data.LineType // "mobile"
Email Validation
var result = await client.ValidateEmailAsync("user@example.com");
result.Data.FormatValid // true
result.Data.MxFound // true
result.Data.SmtpCheck // true
result.Data.Disposable // false
result.Data.Free // false
result.Data.Role // false
result.Data.Score // 0.85
result.Data.IsDeliverable // true (computed)
result.Data.Quality // EmailQuality.High
Error Handling
All methods return ApiLayerResponse<T> which includes error information:
var result = await client.GetIpGeolocationAsync("invalid");
if (!result.Success)
{
Console.WriteLine($"Error: {result.Error.Message}");
Console.WriteLine($"Code: {result.Error.Code}");
}
Environment Variables
// Uses APILAYER_KEY by default
var client = ApiLayerClient.FromEnvironment();
// Or specify a custom variable
var client = ApiLayerClient.FromEnvironment("MY_API_KEY");
Other ForeverTools Packages
License
MIT License - see LICENSE file for details.
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net6.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.