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"
	"log"
	"livepeer"
	"livepeer/models/components"
)

func main() {
    lpClient := livepeer.New(
        livepeer.WithSecurity("") // Your API key
    )
}
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"
	"log"
	"livepeer"
	"livepeer/models/components"
)

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

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

    if res.Data != nil {
        // handle response
    }
}

Next steps

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