Go quickstart
Get started with the Lightfield API using Go.
This guide walks you through making your first request to the Lightfield API using the official Go SDK.
Installation
Section titled “Installation”Requires Go 1.22+.
go get -u github.com/Lightfld/lightfield-goThe package is imported as githubcomlightfldlightfieldgo:
import "github.com/Lightfld/lightfield-go"Get an API key
Section titled “Get an API key”An API key can be created in Lightfield settings (admin only).
When creating the key, select the scopes your integration needs.
For the example below, you’ll need accounts:read.
Make your first request
Section titled “Make your first request”Create a client and list one account to verify your key and scope.
1. Create a new file (e.g. main.go) and paste in:
package main
import ( "context" "fmt"
"github.com/Lightfld/lightfield-go" "github.com/Lightfld/lightfield-go/option")
func main() { client := githubcomlightfldlightfieldgo.NewClient( option.WithAPIKey("My API Key"), ) accounts, err := client.Account.List(context.TODO(), githubcomlightfldlightfieldgo.AccountListParams{ Limit: githubcomlightfldlightfieldgo.Int(1), }) if err != nil { panic(err) } fmt.Printf("%+v\n", accounts)}2. Replace "My API Key" with your actual API key (sk_lf_...).
3. Run the script from your terminal:
go run main.goA successful response prints the AccountListResponse struct. With Limit: 1 you get at most one account. To fetch more results, use Limit and Offset — see List methods for pagination. The full API is in the Go API Reference.
Error handling: The SDK returns typed errors you can inspect with errors.As:
import "errors"
accounts, err := client.Account.List(context.TODO(), githubcomlightfldlightfieldgo.AccountListParams{ Limit: githubcomlightfldlightfieldgo.Int(1),})if err != nil { var apierr *githubcomlightfldlightfieldgo.Error if errors.As(err, &apierr) { fmt.Println(apierr.StatusCode) // e.g. 401, 403 fmt.Println(apierr.Message) } panic(err)}For more on error responses and how to handle them, see Errors.
Next steps
Section titled “Next steps”- Objects in Lightfield — Overview of object types (accounts, contacts, opportunities, and more) and how they relate.
- Go API Reference — Full API reference with Go code examples.
- Rate limits — Request limits and how to handle 429 responses.
- Idempotency — Safe retries for create and update operations.