The Confluence Cloud V2 API includes a set of page endpoints that allow developers to manage and interact with pages in Confluence Cloud. These endpoints provide a range of features that make it easier to create, read, update, and delete pages, as well as retrieve information about them.
The page endpoints in the Confluence Cloud V2 API provide a range of features that are designed to make it easier to work with pages in Confluence Cloud. Some of the key features include:
Create Pages: Developers can use the page endpoints to create new pages in Confluence Cloud. This includes specifying the page title, content, and other relevant information.
Retrieve Page Information: The page endpoints also allow developers to retrieve information about a page, such as the page title, content, and other relevant metadata. This information can be used to populate user interfaces or other integrations.
Update Pages: The Confluence Cloud V2 API also allows developers to update existing pages. This includes changing the page title, content, and other relevant information.
Delete Pages: The page endpoints also provide the ability to delete pages in Confluence Cloud. This can be useful when managing pages that are no longer needed or when cleaning up after testing.
List Pages: Developers can use the page endpoints to retrieve a list of all pages in a space or for a particular user. This can be useful for building integrations that need to work with multiple pages.
Manage Comments: The page endpoints also provide the ability to manage comments on pages. This includes adding, retrieving, updating, and deleting comments.
Get pages for label
GET /wiki/api/v2/labels/{id}/pages
GetsByLabel returns the pages of specified label. The number of results is limited by the limit parameter and additional results (if available) will be available through the next URL present in the Link response header.
package main
import (
"context"
"fmt"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"log"
"net/url"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
var cursor string
for {
pages, response, err := instance.Page.GetsByLabel(context.Background(), 22, "", cursor, 20)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
}
}
for _, page := range pages.Results {
fmt.Println(page.Title, page.ID, page.Version.Number)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
if pages.Links.Next == "" {
break
}
values, err := url.ParseQuery(pages.Links.Next)
if err != nil {
log.Fatal(err)
}
_, containsCursor := values["cursor"]
if containsCursor {
cursor = values["cursor"][0]
}
}
}
Get pages
GET /wiki/api/v2/pages
Bulk returns all pages. The number of results is limited by the limit parameter and additional results (if available) will be available through the next URL present in the Link response header.
Create creates a page in the space. Pages are created as published by default unless specified as a draft in the status field. If creating a published page, the title must be specified.
GetsBySpage returns all pages in a space. The number of results is limited by the limit parameter and additional results (if available) will be available through the next URL present in the Link response header.
package main
import (
"context"
"fmt"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"log"
"net/url"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
var cursor string
for {
pages, response, err := instance.Page.GetsBySpace(context.Background(), 203718658, cursor, 20)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
}
}
for _, page := range pages.Results {
fmt.Println(page.Title, page.ID, page.Version.Number)
}
log.Println("Endpoint:", response.Endpoint)
log.Println("Status Code:", response.Code)
if pages.Links.Next == "" {
break
}
values, err := url.ParseQuery(pages.Links.Next)
if err != nil {
log.Fatal(err)
}
_, containsCursor := values["cursor"]
if containsCursor {
cursor = values["cursor"][0]
}
}
}
Get space permissions
GET /wiki/api/v2/spaces/{id}/permissions
Returns space permissions for a specific space.
package main
import (
"context"
"fmt"
confluence "github.com/ctreminiom/go-atlassian/confluence/v2"
"log"
"net/url"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := confluence.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
var cursor string
for {
permissions, _, err := instance.Space.Permissions(context.Background(), 196613, cursor, 20)
if err != nil {
log.Fatal(err)
}
for _, permission := range permissions.Results {
fmt.Println(permission.ID)
fmt.Println(permission.Principal)
fmt.Println(permission.Operation)
}
if permissions.Links.Next == "" {
break
}
values, err := url.ParseQuery(permissions.Links.Next)
if err != nil {
log.Fatal(err)
}
_, containsCursor := values["cursor"]
if containsCursor {
cursor = values["cursor"][0]
}
}
}