Unofficial Go SDK for the Listmonk newsletter and mailing list manager.
go get github.com/canpacis/listmonk-go
// Import the package
import listmonkgo "github.com/canpacis/listmonk-go"
// ...
// Create a client
client := listmonkgo.New(
listmonkgo.WithBaseURL(/* Base URL */),
listmonkgo.WithAPIUser(/* API User */),
listmonkgo.WithToken(/* API Token */),
// You can optionally pass a custom http client
listmonkgo.WithHTTPClient(/* Your client */),
)
This example creates a client and retrieves the mailing lists and prints them.
package main
import (
"context"
"log"
listmonkgo "github.com/canpacis/listmonk-go"
)
func main() {
// Load variables from environment
client := listmonkgo.New(
listmonkgo.WithBaseURL(os.Getenv("LISTMONK_URL")),
listmonkgo.WithAPIUser(os.Getenv("API_USER")),
listmonkgo.WithToken(os.Getenv("API_TOKEN")),
)
// Get lists, optionally pass your parameters
lists, err := client.GetLists(context.Background(), &listmonkgo.GetListsParams{})
if err != nil {
log.Fatal(err)
}
for _, list := range lists.Results {
fmt.Println(list)
}
}
You can find the API reference in Listmonk website.