Create a livestream
This guide provides you the instructions to create a livestream from the Livepeer Studio Dashboard or the Livepeer API.
The Livepeer API allows you to create a stream object by simply making a POST request. The stream object has unique configuration data and metadata about all livestream sessions that are associated with the stream.
Step 1: Create a stream object
To create a livestream, simply make a POST request.
The only parameter you are required to set is the name of your stream. You can also set the transcoding rendition profiles when you make your request.
Check out the API reference for information on the response object and profiles.
- Livepeer.js
- Fetch
import { useCreateStream } from '@livepeer/react';
function App() {
const { mutate: createStream } = useCreateStream({
name: 'test stream',
profiles: [
{
"name": "720p",
"bitrate": 2000000,
"fps": 0,
"width": 1280,
"height": 720
},
{
"name": "480p",
"bitrate": 1000000,
"fps": 0,
"width": 854,
"height": 480
},
{
"name": "360p",
"bitrate": 500000,
"fps": 0,
"width": 640,
"height": 360
}
]
});
}
const uploadAssetURL = await fetch("https://livepeer.studio/api/stream", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
body: {
"name": "test stream",
"profiles": [
{
"name": "720p",
"bitrate": 2000000,
"fps": 0,
"width": 1280,
"height": 720
},
{
"name": "480p",
"bitrate": 1000000,
"fps": 0,
"width": 854,
"height": 480
},
{
"name": "360p",
"bitrate": 500000,
"fps": 0,
"width": 640,
"height": 360
}
]
},
});