Skip to content

apialerts/apialerts-csharp

Repository files navigation

API Alerts • C# Client

GitHub RepoNuget

Overview

The APIAlerts NuGet package simplifies the process of setting up and managing alerts within your API projects. It provides functionalities to activate the package with an API key and offers methods for publishing alerts asynchronously and synchronously.

Installation

APIAlerts is available as a NuGet package. You can install it using the following command:

PM> Install-Package APIAlerts

Initialize the client

The client is implemented as a singleton, ensuring that only one instance is created and used throughout the application.

// Initialise the ApiAlerts client with your API key
APIAlerts.Client.Configure(yourApiKey);

// You can enable debug mode to see logs messages using the additional debug parameter
APIAlerts.Client.Configure(yourApiKey, true);

Send Events

You can send alerts by constructing the AlertEvent class and passing it to the Send() function.

var alert = new APIAlerts.Alert
{
    Message = "My alert message",       // required message
    Channel = "my-channel-identifier",  // optional, uses the default channel if not provided
    Tags = new[] { "tag1", "tag2" },    // optional
    Link = "https://example.com"        // optional
};

APIAlerts.Client.Send(alert);

The APIAlerts.Client.SendAsync() methods are also available if you need to wait for a successful execution. However, the Send() functions are generally always preferred.

Send with API Key functions

You may have the need to talk to different API Alerts workspaces in your application. You can use the SendWithApiKey() functions to send alerts to override the default API key for that single send call.

APIAlerts.Client.SendWithApiKey("other_api_key", alert);

About

C# SDK for the API Alerts notification platform

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages