Basic client library for ntfy.sh service.
Find a file
onlyati 0b2947664c
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/tag/release Pipeline was successful
ci/woodpecker/cron/vulnerability Pipeline was successful
ci/woodpecker/cron/renovate Pipeline was successful
ci/woodpecker/cron/auto_merge Pipeline was successful
Add token authentication (#3)
Reviewed-on: #3
2026-04-11 16:26:24 +00:00
.markdownlint.json intial commit 2026-04-11 15:38:35 +02:00
.prettierrc intial commit 2026-04-11 15:38:35 +02:00
go.mod intial commit 2026-04-11 15:38:35 +02:00
LICENSE intial commit 2026-04-11 15:38:35 +02:00
ntfy.go Add token authentication (#3) 2026-04-11 16:26:24 +00:00
README.md add install intruction 2026-04-11 15:40:40 +02:00
renovate.json intial commit 2026-04-11 15:38:35 +02:00

Go client for ntfy.sh

This is a basic client for ntfy.sh service.

Install

go get -u code.thinkaboutit.tech/pandora/ntfysh.gopack

Example to use

Send a basic push notification:

package main

import (
	"fmt"
	"log/slog"
	"os"

	ntfy "code.thinkaboutit.tech/pandora/ntfysh.gopack"
)

func main() {
	client := ntfy.NewNtfyClient("https://ntfy.sh", nil)

	// Optional, if no authentication setup then no auth will be used.
	client.SetAuthBasic("myuser", "mypassword")

	msg := ntfy.Message{
		Topic:   ntfy.AsPtr("my-topic"),
		Message: ntfy.AsPtr("my message"),
		Title:   ntfy.AsPtr("my title"),
	}

	response, err := client.Push(msg)
	if err != nil {
		slog.Error("failed push message", "error", err.Error())
		os.Exit(1)
	}
	fmt.Printf("%+v\n", response)
}