Skip to main content

Installation

Installation of each StatusCake API SDK should be performed through the respective package manager, or directly from GitHub where appropriate. This guide will prefer the use of a dependency manager unless otherwise stated.

Use the following steps to install the StatusCake API SDK for the desired language:

info

Some SDK are currently in alpha and will not be given support at this time. We are currently working to deliver stable releases for each of these projects. Read more about alpha releases here.

Install statuscake-go
go get github.com/StatusCakeDev/statuscake-go

Create a Client

Once the desired SDK(s) is installed the next step is to create an authenticated API client. You can view and manage your API tokens from the StatusCake account panel.

note

API tokens must be kept private. In the event that one is exposed a new one should be generated.

Create a Client
package main

import (
"github.com/StatusCakeDev/statuscake-go"
"github.com/StatusCakeDev/statuscake-go/credentials"
)

func main() {
bearer := credentials.NewBearerWithStaticToken("my-api-token")
client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer))
}

List Uptime Checks

With the API client configured you may make requests to the StatusCake API using the available methods. In this document we will list all uptime checks for the given workspace.

List Uptime Checks
package main

import (
"context"
"fmt"

"github.com/StatusCakeDev/statuscake-go"
"github.com/StatusCakeDev/statuscake-go/credentials"
)

func main() {
bearer := credentials.NewBearerWithStaticToken("my-api-token")
client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer))

res, err := client.ListUptimeTests(context.Background()).Execute()
if err != nil {
panic(err)
}

fmt.Printf("%+v\n", res.Data)
}

Next steps

There are many other methods available within each SDK to manage StatusCake monitoring resource that are not covered in this document. See the respective SDK GitHub repositories for example usage.

Next learn about configuration options available in the SDKs.