| name | scalar-galaxy-go-sdk |
| description | Go SDK for Scalar Galaxy API. Use when writing Go code that calls Scalar Galaxy API with the github.com/scalar/galaxy-go package: installing it, constructing and authenticating the client, and calling API operations. |
Scalar Galaxy Go SDK
Generated Go client for Scalar Galaxy API, published as github.com/scalar/galaxy-go. Use the generated client instead of hand-writing HTTP requests.
Install
go get github.com/scalar/galaxy-go
Client setup and authentication
import (
"context"
"fmt"
sdk "github.com/scalar/galaxy-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) โ JWT Bearer token authentication
option.WithBasicAuthUsername (env: BASIC_AUTH_USERNAME) โ Credential for the basicAuth_username client option.
option.WithBasicAuthPassword (env: BASIC_AUTH_PASSWORD) โ Credential for the basicAuth_password client option.
option.WithAPIKeyHeader (env: API_KEY_HEADER) โ API key request header
option.WithAPIKeyQuery (env: API_KEY_QUERY) โ API key query parameter
option.WithAPIKeyCookie (env: API_KEY_COOKIE) โ API key browser cookie
Calling operations
package main
import (
"context"
"fmt"
"os"
sdk "github.com/scalar/galaxy-go"
"github.com/scalar/galaxy-go/option"
)
func main() {
client := sdk.NewClient(
option.WithBearerAuth(os.Getenv("BEARER_AUTH")),
)
planet, err := client.Planets.ListAllData(context.Background(), sdk.PlanetListAllDataParams{
Limit: sdk.F[int64](10),
Offset: sdk.F[int64](0),
})
if err != nil {
panic(err)
}
fmt.Println(planet)
}
Method names, parameter shapes, and response types are generated from the API description โ do not guess them. Look up the exact call signature in api.md before writing a call.
Error handling
Non-success responses return generated API errors. Error objects expose status, headers, response body, and request metadata where the target runtime supports it.
planet, err := client.Planets.ListAllData(context.Background(), sdk.PlanetListAllDataParams{
Limit: sdk.F[int64](10),
Offset: sdk.F[int64](0),
})
if err != nil {
var apiErr *sdk.Error
if errors.As(err, &apiErr) {
fmt.Println(apiErr.StatusCode, apiErr.RawJSON())
}
panic(err)
}
Requirements
Reference files
- README.md โ full feature tour: client options, request options, retries and timeouts, logging.
- api.md โ complete catalogue of every operation with request and response types.