| name | scalar-go-sdk |
| description | Go SDK for Scalar API. Use when writing Go code that calls Scalar API with the github.com/scalar/scalar-go package: installing it, constructing and authenticating the client, and calling API operations. |
Scalar Go SDK
Generated Go client for Scalar API, published as github.com/scalar/scalar-go. Use the generated client instead of hand-writing HTTP requests.
Install
go get github.com/scalar/scalar-go
Client setup and authentication
import (
"context"
"fmt"
sdk "github.com/scalar/scalar-go"
)
client := sdk.NewClient()
Provide credentials using the options below. Environment variables are read automatically when the target runtime supports them:
option.WithBearerAuth (env: BEARER_AUTH) — Credential for the BearerAuth client option.
Calling operations
package main
import (
"context"
"fmt"
"os"
sdk "github.com/scalar/scalar-go"
"github.com/scalar/scalar-go/option"
)
func main() {
client := sdk.NewClient(
option.WithBearerAuth(os.Getenv("BEARER_AUTH")),
)
registry, err := client.Registry.ListAllAPIDocuments(context.Background())
if err != {
(err)
}
fmt.Println(registry)
}