Note: The
openapi.jsonfile for this project is currently under construction and has not been validated yet. Please use it with caution and report any issues.
C# Client for AbusalPDB.
This project provides a client library for interacting with the AbusalPDB API in C#. It is designed to be easily integrated into your .NET applications, supporting dependency injection for seamless configuration.
To use this client, add the package to your project via NuGet:
dotnet add package AbusalPDB.ClientThe API client can be registered in your application's dependency injection container using the AddAbusalPDBApiV2 method from ServiceConfiguration:
// In your Startup.cs or Program.cs (for .NET 6+)
services.AddAbusalPDBApiV2(configuration);This method configures the IAbusalPdbApi client and sets up the necessary HTTP client with the API key.
The API key for AbusalPDB should be configured securely. It is recommended to store the API key in an environment variable and bind it to the configuration. For example:
-
Add the API key to your environment variables:
-
On Windows:
set AbusalPDB__ApiKey=YOUR_API_KEY -
On Linux/macOS:
export AbusalPDB__ApiKey=YOUR_API_KEY
-
-
In your
appsettings.json, reference the environment variable:{ "AbusalPDB": { "ApiKey": "${AbusalPDB_ApiKey}" } } -
Ensure your application reads the configuration and passes it to the
AddAbusalPDBApiV2method.
Once registered, you can inject the Func<IAbusalPdbApi> into your services or controllers:
public class ExampleService
{
private readonly Func<IAbusalPdbApi> _apiFactory;
public ExampleService(Func<IAbusalPdbApi> apiFactory)
{
_apiFactory = apiFactory;
}
public async Task DoSomethingAsync()
{
var apiClient = _apiFactory();
var result = await apiClient.CheckAsync("127.0.0.1");
// Process the result...
}
}For more information, refer to the official AbusalPDB API V2 Documentation.
This project is licensed under the MIT License. See the LICENSE file for details.