Go
A typed, context-aware client for the Firmreader API
The Go SDK requires Go 1.21+. Every method takes a context.Context so you can apply timeouts and cancellation.
Install
go get github.com/firmreader/firmreader-go
Initialize the client
package main
import (
"os"
"github.com/firmreader/firmreader-go"
)
func main() {
client := firmreader.NewClient(os.Getenv("FIRMREADER_API_KEY")) // fr_live_...
_ = client
}
Create a post
post, err := client.Posts.Create(ctx, &firmreader.PostParams{
ChannelID: "ch_company_news",
Title: "Welcome to Firmreader",
Body: "We're excited to announce our new internal communications platform.",
Priority: "normal",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Published post %s\n", post.ID)
List posts
posts, err := client.Posts.List(ctx, &firmreader.ListParams{
ChannelID: "ch_company_news",
Limit: 20,
})
if err != nil {
log.Fatal(err)
}
for _, post := range posts.Data {
fmt.Println(post.Title)
}
Handle errors
The client returns a *firmreader.Error for non-2xx responses. Use errors.As to read the status and code.
var apiErr *firmreader.Error
if errors.As(err, &apiErr) {
fmt.Printf("%d: %s\n", apiErr.Status, apiErr.Code)
}
Set firmreader.WithIdempotencyKey("...") on any write call so retries don't create duplicate posts.
