1

Prerequisites

To get the most out of this guide, you’ll need to:

2

Install the SDK

Get the Livepeer Go SDK.

go get github.com/livepeer/livepeer-go
3

Initialize the SDK

The first step is to initialize the SDK with your Livepeer Studio API key.

package main

import (
	"context"
	livepeer "github.com/livepeer/livepeer-go"
	"github.com/livepeer/livepeer-go/models/components"
	"log"
)

func main() {
	lpClient := livepeer.New(
		livepeer.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
	)
}
4

Use the SDK

Now that you have the SDK installed and initialized, you can use it in your app. Let’s create a stream.

package main

import (
	"context"
	livepeer "github.com/livepeer/livepeer-go"
	"github.com/livepeer/livepeer-go/models/components"
	"log"
)

func main() {
	lpClient := livepeer.New(
		livepeer.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
	)

	ctx := context.Background()
	res, err := lpClient.Stream.Create(ctx, components.NewStreamPayload{
		Name: "test_stream",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res.Stream != nil {
		log.Printf("Stream created successfully")
	}
}

Next steps

Checkout Livepeer API Reference to learn more about the Livepeer API and the Go SDK.