Thanks to visit codestin.com
Credit goes to github.com

Skip to content

garcipat/abusalpdb-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abusalpdb-client

Note: The openapi.json file 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.

Installation

To use this client, add the package to your project via NuGet:

dotnet add package AbusalPDB.Client

Usage

Registering the API Client with Dependency Injection

The 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.

Configuring the AbusalPDB 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:

  1. 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
  2. In your appsettings.json, reference the environment variable:

    {
      "AbusalPDB": {
        "ApiKey": "${AbusalPDB_ApiKey}"
      }
    }
  3. Ensure your application reads the configuration and passes it to the AddAbusalPDBApiV2 method.

Example Usage

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...
    }
}

Resources

For more information, refer to the official AbusalPDB API V2 Documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

C# Client for AbusalPDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages