GitHunt
CH

chA0s-Chris/NtfyCator

A minimalistic .NET library for publishing messages to ntfy.sh.

NtfyCator

A minimalistic .NET library for publishing messages to ntfy.sh and self-hosted instances.

GitHub License
NuGet Version
NuGet Downloads
GitHub last commit
GitHub Actions Workflow Status

Features

โœ… Simple and lightweight

โœ… Async-friendly API

โœ… Easy integration

Installation

You can install NtfyCator via NuGet:

dotnet add package NtfyCator --version 0.3.0

Or using the NuGet Package Manager in Visual Studio:

Install-Package NtfyCator -Version 0.3.0

Getting Started

Register NtfyCator in Program.cs

In an ASP.NET Core or .NET Generic Host application:

using NtfyCator;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddNtfyCator();

var app = builder.Build();

And now you are good to go to publish to ntfy.sh. If you need to target a self-hosted instance, you can simply configure the server URI:

builder.Services.AddNtfyCator(options =>
{
    options.Uri = "https://my.ntfy.server";
});

Inject & Use the Client

public class NotificationService
{
    private readonly INotificator _notificator;
    
    public NotificationService(INotificator notificator)
    {
        _notificator = notificator;
    }
    
    public async Task SendNotification()
    {
        var message = new NtfyMessageBuilder("my-topic")
                      .WithTitle("Test Message")
                      .WithMarkdownBody("This is _just_ a **Test**!")
                      .WithPriority(NtfyPriority.High)
                      .WithTags("tag1", "tag2")
                      .Build();
        
        await notificator.NotifyAsync(message);
    }
}

INotificator also provides an alternative fluent interface that combines message building and sending:

await notificator.NotifyTopic("my-topic")
                 .WithBody("Just another Test!")
                 .WithPriority(NtfyPriority.Low)
                 .SendAsync();

Authorization / Authentication

NtfyCator currently supports access token authorization. To enable it simply call before first usage:

notificator.WithAccessToken("tk_xxxxxxxxxxxxxxxxx");

Every subsequent notification will use the access token as Bearer Token.

As an alternative, NtfyCator also supports user/password authentication:

notificator.WithCredentials("username", "my*password");

If possible you should always prefer token authorization over providing username and password.

Emoji Support

ntfy.sh uses a wide range of custom tags that will be transformed into emojis. NtfyCator supports adding emojis as tags and provides an Emoji enum type so you don't need to use magic strings.

var message = new NtfyMessageBuilder("my-topic")
              .WithTags(Emoji.Wink, Emoji.Rocket) // ๐Ÿ˜‰, ๐Ÿš€
              .Build();

Configuration Options

NtfyCator allows configuring these options:

Option Type Default Value Description
Uri String https://ntfy.sh Server URI

License

MIT License - see LICENSE for more information.

Languages

C#97.9%PowerShell1.1%Shell0.9%Batchfile0.1%

Contributors

MIT License
Created March 16, 2025
Updated January 9, 2026
chA0s-Chris/NtfyCator | GitHunt