Creating and watching a livestream is easy! The example below uses Create Stream API to create and watch a livestream.

Stream Creation

We can use the Livepeer SDK to create a stream. The example below uses the Create Stream API.

  • Node.js

  • Python

  • Ruby

  • PHP

  • Go

import { Livepeer } from "livepeer";

const apiKey = 'YOUR_API_KEY'; // Replace with your API key

const livepeer = new Livepeer(apiKey);

const streamData = {
  name: "test_stream"
};

livepeer
  .createStream(streamData)
  .then((response) => {
    console.log("Stream created:", response);
  })
  .catch((error) => {
    console.error("Error creating stream:", error);
  });

You can find all the information required to broadcast to the stream in the response object.

The RTMP ingest URL of Livepeer Studio is rtmp://rtmp.livepeer.com/live, and the streamKey is present in the response object. You can use these two values to broadcast to the stream.

To learn more about other stream functions such as stopping a stream, recording a stream, and more, see the Stream API.

Play a Stream

To learn how to play a stream, see the Play a Livestream guide.