SDKs
Go SDK
Idiomatic Go client for the Syntext API. Requires Go 1.21+.
Installation
go get github.com/syntext-dev/syntext-sdk-go
Quick Start
package main
import (
"context"
"fmt"
"log"
"os"
syntext "github.com/syntext-dev/syntext-sdk-go"
)
func main() {
client := syntext.NewClient(os.Getenv("SYNTEXT_API_KEY"))
ctx := context.Background()
// Get a project
project, err := client.Projects.Get(ctx, "prj_abc123")
if err != nil {
log.Fatal(err)
}
// Trigger a build
build, err := client.Builds.Trigger(ctx, project.ID, &syntext.TriggerBuildOptions{
Branch: "main",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("build queued:", build.ID)
}
Services
| Service | Methods |
|---|---|
client.Projects |
List, Get, Create, Update, Delete |
client.Builds |
List, Get, Trigger, Cancel |
client.Search |
Query, Reindex |
client.Domains |
Add, Verify, Remove |
client.APIKeys |
List, Create, Rotate, Revoke |
All methods take a context.Context as the first argument.
Error Handling
Errors are typed — use errors.As to branch on error kinds:
build, err := client.Builds.Trigger(ctx, "prj_abc123", nil)
if err != nil {
var apiErr *syntext.APIError
if errors.As(err, &apiErr) {
switch apiErr.Code {
case "not_found":
// project doesn't exist
case "rate_limited":
time.Sleep(time.Duration(apiErr.RetryAfterSeconds) * time.Second)
}
}
return err
}
429 and 5xx responses are retried automatically with exponential backoff before an error is returned.
CI Usage
The Go SDK is a good fit for build automation — e.g. triggering a docs rebuild after a service deploy:
build, err := client.Builds.Trigger(ctx, projectID, &syntext.TriggerBuildOptions{
Branch: "main",
Force: true,
})
For most CI pipelines the CLI (stx deploy) is simpler — use the SDK when you need programmatic control from Go services.
Was this page helpful?