CDPGuidesSupport
SDKsPlatform

Go SDK (platform)

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

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

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

Usage

Create a Platform API key and set it as OURS_PRIVACY_API_KEY, or pass it with option.WithAPIKey. Import the SDK with an alias; we recommend oursprivacy:

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:

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

How is this guide?

On this page