ApifreaksApi 1.1.2
dotnet add package ApifreaksApi --version 1.1.2
NuGet\Install-Package ApifreaksApi -Version 1.1.2
<PackageReference Include="ApifreaksApi" Version="1.1.2" />
<PackageVersion Include="ApifreaksApi" Version="1.1.2" />
<PackageReference Include="ApifreaksApi" />
paket add ApifreaksApi --version 1.1.2
#r "nuget: ApifreaksApi, 1.1.2"
#:package ApifreaksApi@1.1.2
#addin nuget:?package=ApifreaksApi&version=1.1.2
#tool nuget:?package=ApifreaksApi&version=1.1.2
Apifreaks .NET SDK
The Apifreaks .NET library provides convenient access to the Apifreaks APIs from C# and other .NET languages.
Table of Contents
Installation
Install the package from NuGet:
dotnet add package ApifreaksApi
Or add it directly to your .csproj:
<ItemGroup>
<PackageReference Include="ApifreaksApi" Version="0.1.0" />
</ItemGroup>
Reference
A full reference for this library is available here.
Usage
Instantiate and use the client with the following:
using ApifreaksApi;
var client = new ApifreaksApiClient();
var request = new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
};
var response = await client.GeolocationLookupAsync(request);
Console.WriteLine(response);
Environments
This SDK allows you to configure the API base URL through ClientOptions.
using ApifreaksApi;
var client = new ApifreaksApiClient(
new ClientOptions
{
BaseUrl = ApifreaksApiEnvironment.Default,
}
);
Errors
When the API returns a non-success status code, the SDK throws an exception.
using ApifreaksApi;
try
{
var response = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
}
);
Console.WriteLine(response);
}
catch (ApifreaksApiApiException e)
{
Console.WriteLine($"API error {e.StatusCode}: {e.Body}");
}
catch (ApifreaksApiException e)
{
Console.WriteLine($"SDK error: {e.Message}");
}
Request Types
The SDK exports request and response types in the ApifreaksApi namespace.
using ApifreaksApi;
var request = new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
};
Advanced
Retries
The SDK is instrumented with automatic retries with exponential backoff. By default, the client retries retryable requests up to 2 times.
Configure retries globally:
using ApifreaksApi;
var client = new ApifreaksApiClient(
new ClientOptions
{
MaxRetries = 3,
}
);
Configure retries for a single request:
var response = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
},
new RequestOptions
{
MaxRetries = 3,
}
);
Timeouts
The SDK defaults to a 30 second timeout. Configure timeouts globally:
var client = new ApifreaksApiClient(
new ClientOptions
{
Timeout = TimeSpan.FromSeconds(30),
}
);
Configure a timeout for a single request:
var response = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
},
new RequestOptions
{
Timeout = TimeSpan.FromSeconds(30),
}
);
Additional Headers
Add custom headers globally:
var client = new ApifreaksApiClient(
new ClientOptions
{
AdditionalHeaders = new[]
{
new KeyValuePair<string, string?>("X-Custom-Header", "custom-value"),
},
}
);
Add custom headers for a single request:
var response = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
},
new RequestOptions
{
AdditionalHeaders = new[]
{
new KeyValuePair<string, string?>("X-Custom-Header", "custom-value"),
},
}
);
Additional Query String Parameters
Add custom query parameters for a single request:
var response = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
},
new RequestOptions
{
AdditionalQueryParameters = new[]
{
new KeyValuePair<string, string>("filter", "active"),
new KeyValuePair<string, string>("sort", "desc"),
},
}
);
Raw Response Metadata
Directly awaiting a method returns the parsed response data. Use .WithRawResponse() when you need status code, headers, or URL metadata.
var rawResponse = await client.GeolocationLookupAsync(
new GeolocationLookupRequest
{
ApiKey = "your_api_key",
Ip = "8.8.8.8",
}
).WithRawResponse();
Console.WriteLine(rawResponse.RawResponse.StatusCode);
Console.WriteLine(rawResponse.Data);
Contributing
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 is compatible. 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 is compatible. 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. |
-
.NETFramework 4.6.2
- OneOf (>= 3.0.271)
- OneOf.Extended (>= 3.0.271)
- Portable.System.DateTimeOnly (>= 9.0.1)
- System.Net.Http (>= 4.3.4)
- System.Text.Json (>= 9.0.9)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETStandard 2.0
- OneOf (>= 3.0.271)
- OneOf.Extended (>= 3.0.271)
- Portable.System.DateTimeOnly (>= 9.0.1)
- System.Net.Http (>= 4.3.4)
- System.Text.Json (>= 9.0.9)
- System.Text.RegularExpressions (>= 4.3.1)
-
net8.0
- OneOf (>= 3.0.271)
- OneOf.Extended (>= 3.0.271)
- System.Net.Http (>= 4.3.4)
- System.Text.RegularExpressions (>= 4.3.1)
-
net9.0
- OneOf (>= 3.0.271)
- OneOf.Extended (>= 3.0.271)
- System.Net.Http (>= 4.3.4)
- System.Text.RegularExpressions (>= 4.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.