go-confluence
go-confluence copied to clipboard
Go package for working with Atlassian Confluence Server REST API
Installation • Usage example • Build Status • License
go-confluence
is a Go package for working with Confluence REST API.
▲ Please take note that this package support only getting data from Confluence API (i.e. you cannot create or modify data using this package).
Installation
Make sure you have a working Go 1.18+ workspace (instructions), then:
go get -u github.com/essentialkaos/go-confluence/v5
Usage example
Authentication with username and password.
package main
import (
"fmt"
cf "github.com/essentialkaos/go-confluence/v6"
)
func main() {
api, err := cf.NewAPI("https://confluence.domain.com", cf.AuthBasic{"john", "MySuppaPAssWOrd"})
api.SetUserAgent("MyApp", "1.2.3")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
content, err := api.GetContentByID(
"18173522", cf.ContentIDParameters{
Version: 4,
Expand: []string{"space", "body.view", "version"},
},
)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("ID: %s\n", content.ID)
}
Authentication with personal token. Please make sure your confluence 7.9 version and later. See Using Personal Access Tokens guide
package main
import (
"fmt"
cf "github.com/essentialkaos/go-confluence/v6"
)
func main() {
api, err := cf.NewAPI("https://confluence.domain.com", cf.AuthToken{"avaMTxxxqKaxpFHpmwHPXhjmUFfAJMaU3VXUji73EFhf"})
api.SetUserAgent("MyApp", "1.2.3")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
content, err := api.GetContentByID(
"18173522", cf.ContentIDParameters{
Version: 4,
Expand: []string{"space", "body.view", "version"},
},
)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("ID: %s\n", content.ID)
}
Build Status
Branch | Status |
---|---|
master (Stable) |
|
develop (Unstable) |