# Go SDK (platform)

> Install and use the Ours Privacy Go platform SDK to manage sources, destinations, consent settings, and more from your Go applications.

Source: https://docs.oursprivacy.com/docs/platform-go

Use this page to install the Ours Privacy Go platform SDK and make your first call. The SDK requires Go 1.26 or later.

***

## Installation

```sh
go get -u 'github.com/with-ours/platform-sdk-go/v2@latest'
```

## Usage

Create a [Platform API key](https://docs.oursprivacy.com/docs/platform-api/authentication) and set it as `OURS_PRIVACY_API_KEY`, or pass it with `option.WithAPIKey`. Import the SDK with an alias; we recommend `oursprivacy`:

```go
package main

import (
	"context"
	"fmt"

	oursprivacy "github.com/with-ours/platform-sdk-go/v2"
	"github.com/with-ours/platform-sdk-go/v2/option"
)

func main() {
	client := oursprivacy.NewClient(
		option.WithAPIKey("YOUR_API_KEY"), // defaults to os.LookupEnv("OURS_PRIVACY_API_KEY")
	)
	page, err := client.Sources.List(context.TODO(), oursprivacy.SourceListParams{})
	if err != nil {
		panic(err.Error())
	}
	for _, source := range page.Entities {
		fmt.Println(source.ID, source.Name)
	}
}
```

## Pagination

`List` returns one page, with the results in `Entities`. To walk every page, use the matching `ListAutoPaging` method:

```go
iter := client.Sources.ListAutoPaging(context.TODO(), oursprivacy.SourceListParams{})
for iter.Next() {
	source := iter.Current()
	fmt.Println(source.ID, source.Name)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}
```

***

## Next Steps

* **[Platform API Quickstart](https://docs.oursprivacy.com/docs/platform-api/quickstart)**: the same operations against the raw REST API.
* **[Platform OpenAPI Schema](https://docs.oursprivacy.com/docs/platform-api/openapi)**: every resource and method the SDK exposes.
* **[pkg.go.dev](https://pkg.go.dev/github.com/with-ours/platform-sdk-go/v2)** and **[GitHub repository](https://github.com/with-ours/platform-sdk-go)**: releases, changelog, and the full README.
