--- title: Go quickstart | Lightfield description: Get started with the Lightfield API using Go. --- The Lightfield API is currently in beta. Methods, parameters, and response schemas may change as we incorporate feedback during this period. This guide walks you through making your first request to the Lightfield API using the official Go SDK. ## Installation Requires Go 1.22+. Terminal window ``` go get -u github.com/Lightfld/lightfield-go ``` The package is imported as `githubcomlightfldlightfieldgo`: ``` import "github.com/Lightfld/lightfield-go" ``` ## Get an API key An [API key](/using-the-api/api-keys/index.md) can be created in [Lightfield settings](https://crm.lightfield.app/crm/settings/api-keys) (admin only). When creating the key, select the [scopes](/using-the-api/scopes/index.md) your integration needs. For the example below, you’ll need `accounts:read`. ## Make your first request Create a client and [list](/api/resources/account/methods/list/index.md) 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: Terminal window ``` go run main.go ``` A 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](/using-the-api/list-endpoints/index.md) for pagination. The full API is in the [Go API Reference](/api/go/index.md). **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](/using-the-api/errors/index.md). ## Next steps - **[Objects in Lightfield](/objects-in-lightfield/object-types/index.md)** — Overview of object types (accounts, contacts, opportunities, and more) and how they relate. - **[Go API Reference](/api/go/index.md)** — Full API reference with Go code examples. - **[Rate limits](/using-the-api/rate-limits/index.md)** — Request limits and how to handle 429 responses. - **[Idempotency](/using-the-api/idempotency/index.md)** — Safe retries for create and update operations.