TypeScript
import { Livepeer } from "livepeer";
import { Profile, TranscodeProfileEncoder, TranscodeProfileProfile, Type } from "livepeer/models/components";
const livepeer = new Livepeer({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await livepeer.stream.create({
name: "test_stream",
pull: {
source: "https://myservice.com/live/stream.flv",
headers: {
"Authorization": "Bearer 123",
},
location: {
lat: 39.739,
lon: -104.988,
},
},
playbackPolicy: {
type: Type.Webhook,
webhookId: "1bde4o2i6xycudoy",
webhookContext: {
"streamerId": "my-custom-id",
},
refreshInterval: 600,
},
profiles: [
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
fps: 30,
fpsDen: 1,
quality: 23,
gop: "2",
profile: Profile.H264Baseline,
},
],
record: false,
recordingSpec: {
profiles: [
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
quality: 23,
fps: 30,
fpsDen: 1,
gop: "2",
profile: TranscodeProfileProfile.H264Baseline,
encoder: TranscodeProfileEncoder.H264,
},
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
quality: 23,
fps: 30,
fpsDen: 1,
gop: "2",
profile: TranscodeProfileProfile.H264Baseline,
encoder: TranscodeProfileEncoder.H264,
},
],
},
multistream: {
targets: [
{
profile: "720p0",
videoOnly: false,
id: "PUSH123",
spec: {
name: "My target",
url: "rtmps://live.my-service.tv/channel/secretKey",
},
},
],
},
});
// Handle the result
console.log(result);
}
run();package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Stream.Create(ctx, components.NewStreamPayload{
Name: "test_stream",
Pull: &components.Pull{
Source: "https://myservice.com/live/stream.flv",
Headers: map[string]string{
"Authorization": "Bearer 123",
},
Location: &components.Location{
Lat: 39.739,
Lon: -104.988,
},
},
PlaybackPolicy: &components.PlaybackPolicy{
Type: components.TypeWebhook,
WebhookID: livepeergo.String("1bde4o2i6xycudoy"),
WebhookContext: map[string]any{
"streamerId": "my-custom-id",
},
RefreshInterval: livepeergo.Float64(600),
},
Profiles: []components.FfmpegProfile{
components.FfmpegProfile{
Width: 1280,
Name: "720p",
Height: 720,
Bitrate: 3000000,
Fps: 30,
FpsDen: livepeergo.Int64(1),
Quality: livepeergo.Int64(23),
Gop: livepeergo.String("2"),
Profile: components.ProfileH264Baseline.ToPointer(),
},
},
Record: livepeergo.Bool(false),
RecordingSpec: &components.NewStreamPayloadRecordingSpec{
Profiles: []components.TranscodeProfile{
components.TranscodeProfile{
Width: livepeergo.Int64(1280),
Name: livepeergo.String("720p"),
Height: livepeergo.Int64(720),
Bitrate: 3000000,
Quality: livepeergo.Int64(23),
Fps: livepeergo.Int64(30),
FpsDen: livepeergo.Int64(1),
Gop: livepeergo.String("2"),
Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),
Encoder: components.TranscodeProfileEncoderH264.ToPointer(),
},
},
},
Multistream: &components.Multistream{
Targets: []components.Target{
components.Target{
Profile: "720p",
VideoOnly: livepeergo.Bool(false),
ID: livepeergo.String("PUSH123"),
Spec: &components.TargetSpec{
Name: livepeergo.String("My target"),
URL: "rtmps://live.my-service.tv/channel/secretKey",
},
},
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Stream != nil {
// handle response
}
}from livepeer import Livepeer
from livepeer.models import components
s = Livepeer(
api_key="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.stream.create(request={
"name": "test_stream",
"pull": {
"source": "https://myservice.com/live/stream.flv",
"headers": {
"Authorization": "Bearer 123",
},
"location": {
"lat": 39.739,
"lon": -104.988,
},
},
"playback_policy": {
"type": components.Type.WEBHOOK,
"webhook_id": "1bde4o2i6xycudoy",
"webhook_context": {
"streamerId": "my-custom-id",
},
"refresh_interval": 600,
},
"profiles": [
{
"width": 1280,
"name": "720p",
"height": 720,
"bitrate": 3000000,
"fps": 30,
"fps_den": 1,
"quality": 23,
"gop": "2",
"profile": components.Profile.H264_BASELINE,
},
],
"record": False,
"recording_spec": {
"profiles": [
{
"width": 1280,
"name": "720p",
"height": 720,
"bitrate": 3000000,
"quality": 23,
"fps": 30,
"fps_den": 1,
"gop": "2",
"profile": components.TranscodeProfileProfile.H264_BASELINE,
"encoder": components.TranscodeProfileEncoder.H_264,
},
],
},
"multistream": {
"targets": [
{
"profile": "720p",
"video_only": False,
"id": "PUSH123",
"spec": {
"name": "My target",
"url": "rtmps://live.my-service.tv/channel/secretKey",
},
},
],
},
})
if res.stream is not None:
# handle response
passcurl --request POST \
--url https://livepeer.studio/api/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<unknown>",
"pull": "<unknown>",
"creatorId": {
"type": "unverified",
"value": "<string>"
},
"playbackPolicy": {
"type": "webhook",
"webhookId": "1bde4o2i6xycudoy",
"webhookContext": {
"streamerId": "my-custom-id"
},
"refreshInterval": 600,
"allowedOrigins": [
"<string>"
]
},
"profiles": {
"$ref": "#/components/schemas/stream/properties/profiles/default"
},
"record": "<unknown>",
"recordingSpec": {
"profiles": [
{
"bitrate": 3000000,
"width": 1280,
"name": "720p",
"height": 720,
"quality": 23,
"fps": 30,
"fpsDen": 1,
"gop": 2,
"profile": "H264Baseline",
"encoder": "H.264"
}
]
},
"multistream": "<unknown>",
"userTags": "<unknown>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<unknown>',
pull: '<unknown>',
creatorId: {type: 'unverified', value: '<string>'},
playbackPolicy: {
type: 'webhook',
webhookId: '1bde4o2i6xycudoy',
webhookContext: {streamerId: 'my-custom-id'},
refreshInterval: 600,
allowedOrigins: ['<string>']
},
profiles: {$ref: '#/components/schemas/stream/properties/profiles/default'},
record: '<unknown>',
recordingSpec: {
profiles: [
{
bitrate: 3000000,
width: 1280,
name: '720p',
height: 720,
quality: 23,
fps: 30,
fpsDen: 1,
gop: 2,
profile: 'H264Baseline',
encoder: 'H.264'
}
]
},
multistream: '<unknown>',
userTags: '<unknown>'
})
};
fetch('https://livepeer.studio/api/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://livepeer.studio/api/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<unknown>',
'pull' => '<unknown>',
'creatorId' => [
'type' => 'unverified',
'value' => '<string>'
],
'playbackPolicy' => [
'type' => 'webhook',
'webhookId' => '1bde4o2i6xycudoy',
'webhookContext' => [
'streamerId' => 'my-custom-id'
],
'refreshInterval' => 600,
'allowedOrigins' => [
'<string>'
]
],
'profiles' => [
'$ref' => '#/components/schemas/stream/properties/profiles/default'
],
'record' => '<unknown>',
'recordingSpec' => [
'profiles' => [
[
'bitrate' => 3000000,
'width' => 1280,
'name' => '720p',
'height' => 720,
'quality' => 23,
'fps' => 30,
'fpsDen' => 1,
'gop' => 2,
'profile' => 'H264Baseline',
'encoder' => 'H.264'
]
]
],
'multistream' => '<unknown>',
'userTags' => '<unknown>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://livepeer.studio/api/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<unknown>\",\n \"pull\": \"<unknown>\",\n \"creatorId\": {\n \"type\": \"unverified\",\n \"value\": \"<string>\"\n },\n \"playbackPolicy\": {\n \"type\": \"webhook\",\n \"webhookId\": \"1bde4o2i6xycudoy\",\n \"webhookContext\": {\n \"streamerId\": \"my-custom-id\"\n },\n \"refreshInterval\": 600,\n \"allowedOrigins\": [\n \"<string>\"\n ]\n },\n \"profiles\": {\n \"$ref\": \"#/components/schemas/stream/properties/profiles/default\"\n },\n \"record\": \"<unknown>\",\n \"recordingSpec\": {\n \"profiles\": [\n {\n \"bitrate\": 3000000,\n \"width\": 1280,\n \"name\": \"720p\",\n \"height\": 720,\n \"quality\": 23,\n \"fps\": 30,\n \"fpsDen\": 1,\n \"gop\": 2,\n \"profile\": \"H264Baseline\",\n \"encoder\": \"H.264\"\n }\n ]\n },\n \"multistream\": \"<unknown>\",\n \"userTags\": \"<unknown>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://livepeer.studio/api/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<unknown>\",\n \"pull\": \"<unknown>\",\n \"creatorId\": {\n \"type\": \"unverified\",\n \"value\": \"<string>\"\n },\n \"playbackPolicy\": {\n \"type\": \"webhook\",\n \"webhookId\": \"1bde4o2i6xycudoy\",\n \"webhookContext\": {\n \"streamerId\": \"my-custom-id\"\n },\n \"refreshInterval\": 600,\n \"allowedOrigins\": [\n \"<string>\"\n ]\n },\n \"profiles\": {\n \"$ref\": \"#/components/schemas/stream/properties/profiles/default\"\n },\n \"record\": \"<unknown>\",\n \"recordingSpec\": {\n \"profiles\": [\n {\n \"bitrate\": 3000000,\n \"width\": 1280,\n \"name\": \"720p\",\n \"height\": 720,\n \"quality\": 23,\n \"fps\": 30,\n \"fpsDen\": 1,\n \"gop\": 2,\n \"profile\": \"H264Baseline\",\n \"encoder\": \"H.264\"\n }\n ]\n },\n \"multistream\": \"<unknown>\",\n \"userTags\": \"<unknown>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "test_stream",
"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
"kind": "stream",
"creatorId": {
"type": "unverified",
"value": "user123"
},
"userTags": {},
"lastSeen": 1587667174725,
"sourceSegments": 1,
"transcodedSegments": 2,
"sourceSegmentsDuration": 1,
"transcodedSegmentsDuration": 2,
"sourceBytes": 1,
"transcodedBytes": 2,
"ingestRate": 1,
"outgoingRate": 2,
"isActive": true,
"isHealthy": "<unknown>",
"issues": "<unknown>",
"createdByTokenName": "abc-123-xyz-456",
"createdAt": 1587667174725,
"parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
"streamKey": "hgebdhhigq",
"pull": {
"source": "https://myservice.com/live/stream.flv",
"headers": {
"Authorization": "Bearer 123"
},
"isMobile": 0,
"location": {
"lat": 39.739,
"lon": -104.988
}
},
"playbackId": "eaw4nk06ts2d0mzb",
"playbackPolicy": {
"type": "webhook",
"webhookId": "1bde4o2i6xycudoy",
"webhookContext": {
"streamerId": "my-custom-id"
},
"refreshInterval": 600,
"allowedOrigins": [
"<string>"
]
},
"profiles": [
{
"name": "240p0",
"fps": 0,
"bitrate": 250000,
"width": 426,
"height": 240
},
{
"name": "360p0",
"fps": 0,
"bitrate": 800000,
"width": 640,
"height": 360
},
{
"name": "480p0",
"fps": 0,
"bitrate": 1600000,
"width": 854,
"height": 480
},
{
"name": "720p0",
"fps": 0,
"bitrate": 3000000,
"width": 1280,
"height": 720
}
],
"projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9",
"record": false,
"recordingSpec": {
"profiles": [
{
"bitrate": 3000000,
"width": 1280,
"name": "720p",
"height": 720,
"quality": 23,
"fps": 30,
"fpsDen": 1,
"gop": 2,
"profile": "H264Baseline",
"encoder": "H.264"
}
]
},
"multistream": {
"targets": [
{
"id": "PUSH123",
"profile": "720p"
}
]
},
"suspended": true,
"lastTerminatedAt": 1713281212993,
"userId": "we7818e7-610a-4057-8f6f-b785dc1e6f88",
"renditions": {}
}{
"errors": [
[
"id not provided",
"Account not found"
]
]
}Livestream
Create a livestream
The only parameter you are required to set is the name of your stream,
but we also highly recommend that you define transcoding profiles
parameter that suits your specific broadcasting configuration.
If you do not define transcoding rendition profiles when creating the
stream, a default set of profiles will be used. These profiles include
240p, 360p, 480p and 720p.
The playback policy is set to public by default for new streams. It can
also be added upon the creation of a new stream by adding
"playbackPolicy": {"type": "jwt"}
POST
/
stream
TypeScript
import { Livepeer } from "livepeer";
import { Profile, TranscodeProfileEncoder, TranscodeProfileProfile, Type } from "livepeer/models/components";
const livepeer = new Livepeer({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await livepeer.stream.create({
name: "test_stream",
pull: {
source: "https://myservice.com/live/stream.flv",
headers: {
"Authorization": "Bearer 123",
},
location: {
lat: 39.739,
lon: -104.988,
},
},
playbackPolicy: {
type: Type.Webhook,
webhookId: "1bde4o2i6xycudoy",
webhookContext: {
"streamerId": "my-custom-id",
},
refreshInterval: 600,
},
profiles: [
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
fps: 30,
fpsDen: 1,
quality: 23,
gop: "2",
profile: Profile.H264Baseline,
},
],
record: false,
recordingSpec: {
profiles: [
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
quality: 23,
fps: 30,
fpsDen: 1,
gop: "2",
profile: TranscodeProfileProfile.H264Baseline,
encoder: TranscodeProfileEncoder.H264,
},
{
width: 1280,
name: "720p",
height: 720,
bitrate: 3000000,
quality: 23,
fps: 30,
fpsDen: 1,
gop: "2",
profile: TranscodeProfileProfile.H264Baseline,
encoder: TranscodeProfileEncoder.H264,
},
],
},
multistream: {
targets: [
{
profile: "720p0",
videoOnly: false,
id: "PUSH123",
spec: {
name: "My target",
url: "rtmps://live.my-service.tv/channel/secretKey",
},
},
],
},
});
// Handle the result
console.log(result);
}
run();package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/components"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Stream.Create(ctx, components.NewStreamPayload{
Name: "test_stream",
Pull: &components.Pull{
Source: "https://myservice.com/live/stream.flv",
Headers: map[string]string{
"Authorization": "Bearer 123",
},
Location: &components.Location{
Lat: 39.739,
Lon: -104.988,
},
},
PlaybackPolicy: &components.PlaybackPolicy{
Type: components.TypeWebhook,
WebhookID: livepeergo.String("1bde4o2i6xycudoy"),
WebhookContext: map[string]any{
"streamerId": "my-custom-id",
},
RefreshInterval: livepeergo.Float64(600),
},
Profiles: []components.FfmpegProfile{
components.FfmpegProfile{
Width: 1280,
Name: "720p",
Height: 720,
Bitrate: 3000000,
Fps: 30,
FpsDen: livepeergo.Int64(1),
Quality: livepeergo.Int64(23),
Gop: livepeergo.String("2"),
Profile: components.ProfileH264Baseline.ToPointer(),
},
},
Record: livepeergo.Bool(false),
RecordingSpec: &components.NewStreamPayloadRecordingSpec{
Profiles: []components.TranscodeProfile{
components.TranscodeProfile{
Width: livepeergo.Int64(1280),
Name: livepeergo.String("720p"),
Height: livepeergo.Int64(720),
Bitrate: 3000000,
Quality: livepeergo.Int64(23),
Fps: livepeergo.Int64(30),
FpsDen: livepeergo.Int64(1),
Gop: livepeergo.String("2"),
Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),
Encoder: components.TranscodeProfileEncoderH264.ToPointer(),
},
},
},
Multistream: &components.Multistream{
Targets: []components.Target{
components.Target{
Profile: "720p",
VideoOnly: livepeergo.Bool(false),
ID: livepeergo.String("PUSH123"),
Spec: &components.TargetSpec{
Name: livepeergo.String("My target"),
URL: "rtmps://live.my-service.tv/channel/secretKey",
},
},
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Stream != nil {
// handle response
}
}from livepeer import Livepeer
from livepeer.models import components
s = Livepeer(
api_key="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.stream.create(request={
"name": "test_stream",
"pull": {
"source": "https://myservice.com/live/stream.flv",
"headers": {
"Authorization": "Bearer 123",
},
"location": {
"lat": 39.739,
"lon": -104.988,
},
},
"playback_policy": {
"type": components.Type.WEBHOOK,
"webhook_id": "1bde4o2i6xycudoy",
"webhook_context": {
"streamerId": "my-custom-id",
},
"refresh_interval": 600,
},
"profiles": [
{
"width": 1280,
"name": "720p",
"height": 720,
"bitrate": 3000000,
"fps": 30,
"fps_den": 1,
"quality": 23,
"gop": "2",
"profile": components.Profile.H264_BASELINE,
},
],
"record": False,
"recording_spec": {
"profiles": [
{
"width": 1280,
"name": "720p",
"height": 720,
"bitrate": 3000000,
"quality": 23,
"fps": 30,
"fps_den": 1,
"gop": "2",
"profile": components.TranscodeProfileProfile.H264_BASELINE,
"encoder": components.TranscodeProfileEncoder.H_264,
},
],
},
"multistream": {
"targets": [
{
"profile": "720p",
"video_only": False,
"id": "PUSH123",
"spec": {
"name": "My target",
"url": "rtmps://live.my-service.tv/channel/secretKey",
},
},
],
},
})
if res.stream is not None:
# handle response
passcurl --request POST \
--url https://livepeer.studio/api/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<unknown>",
"pull": "<unknown>",
"creatorId": {
"type": "unverified",
"value": "<string>"
},
"playbackPolicy": {
"type": "webhook",
"webhookId": "1bde4o2i6xycudoy",
"webhookContext": {
"streamerId": "my-custom-id"
},
"refreshInterval": 600,
"allowedOrigins": [
"<string>"
]
},
"profiles": {
"$ref": "#/components/schemas/stream/properties/profiles/default"
},
"record": "<unknown>",
"recordingSpec": {
"profiles": [
{
"bitrate": 3000000,
"width": 1280,
"name": "720p",
"height": 720,
"quality": 23,
"fps": 30,
"fpsDen": 1,
"gop": 2,
"profile": "H264Baseline",
"encoder": "H.264"
}
]
},
"multistream": "<unknown>",
"userTags": "<unknown>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<unknown>',
pull: '<unknown>',
creatorId: {type: 'unverified', value: '<string>'},
playbackPolicy: {
type: 'webhook',
webhookId: '1bde4o2i6xycudoy',
webhookContext: {streamerId: 'my-custom-id'},
refreshInterval: 600,
allowedOrigins: ['<string>']
},
profiles: {$ref: '#/components/schemas/stream/properties/profiles/default'},
record: '<unknown>',
recordingSpec: {
profiles: [
{
bitrate: 3000000,
width: 1280,
name: '720p',
height: 720,
quality: 23,
fps: 30,
fpsDen: 1,
gop: 2,
profile: 'H264Baseline',
encoder: 'H.264'
}
]
},
multistream: '<unknown>',
userTags: '<unknown>'
})
};
fetch('https://livepeer.studio/api/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://livepeer.studio/api/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<unknown>',
'pull' => '<unknown>',
'creatorId' => [
'type' => 'unverified',
'value' => '<string>'
],
'playbackPolicy' => [
'type' => 'webhook',
'webhookId' => '1bde4o2i6xycudoy',
'webhookContext' => [
'streamerId' => 'my-custom-id'
],
'refreshInterval' => 600,
'allowedOrigins' => [
'<string>'
]
],
'profiles' => [
'$ref' => '#/components/schemas/stream/properties/profiles/default'
],
'record' => '<unknown>',
'recordingSpec' => [
'profiles' => [
[
'bitrate' => 3000000,
'width' => 1280,
'name' => '720p',
'height' => 720,
'quality' => 23,
'fps' => 30,
'fpsDen' => 1,
'gop' => 2,
'profile' => 'H264Baseline',
'encoder' => 'H.264'
]
]
],
'multistream' => '<unknown>',
'userTags' => '<unknown>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://livepeer.studio/api/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<unknown>\",\n \"pull\": \"<unknown>\",\n \"creatorId\": {\n \"type\": \"unverified\",\n \"value\": \"<string>\"\n },\n \"playbackPolicy\": {\n \"type\": \"webhook\",\n \"webhookId\": \"1bde4o2i6xycudoy\",\n \"webhookContext\": {\n \"streamerId\": \"my-custom-id\"\n },\n \"refreshInterval\": 600,\n \"allowedOrigins\": [\n \"<string>\"\n ]\n },\n \"profiles\": {\n \"$ref\": \"#/components/schemas/stream/properties/profiles/default\"\n },\n \"record\": \"<unknown>\",\n \"recordingSpec\": {\n \"profiles\": [\n {\n \"bitrate\": 3000000,\n \"width\": 1280,\n \"name\": \"720p\",\n \"height\": 720,\n \"quality\": 23,\n \"fps\": 30,\n \"fpsDen\": 1,\n \"gop\": 2,\n \"profile\": \"H264Baseline\",\n \"encoder\": \"H.264\"\n }\n ]\n },\n \"multistream\": \"<unknown>\",\n \"userTags\": \"<unknown>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://livepeer.studio/api/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<unknown>\",\n \"pull\": \"<unknown>\",\n \"creatorId\": {\n \"type\": \"unverified\",\n \"value\": \"<string>\"\n },\n \"playbackPolicy\": {\n \"type\": \"webhook\",\n \"webhookId\": \"1bde4o2i6xycudoy\",\n \"webhookContext\": {\n \"streamerId\": \"my-custom-id\"\n },\n \"refreshInterval\": 600,\n \"allowedOrigins\": [\n \"<string>\"\n ]\n },\n \"profiles\": {\n \"$ref\": \"#/components/schemas/stream/properties/profiles/default\"\n },\n \"record\": \"<unknown>\",\n \"recordingSpec\": {\n \"profiles\": [\n {\n \"bitrate\": 3000000,\n \"width\": 1280,\n \"name\": \"720p\",\n \"height\": 720,\n \"quality\": 23,\n \"fps\": 30,\n \"fpsDen\": 1,\n \"gop\": 2,\n \"profile\": \"H264Baseline\",\n \"encoder\": \"H.264\"\n }\n ]\n },\n \"multistream\": \"<unknown>\",\n \"userTags\": \"<unknown>\"\n}"
response = http.request(request)
puts response.read_body{
"name": "test_stream",
"id": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
"kind": "stream",
"creatorId": {
"type": "unverified",
"value": "user123"
},
"userTags": {},
"lastSeen": 1587667174725,
"sourceSegments": 1,
"transcodedSegments": 2,
"sourceSegmentsDuration": 1,
"transcodedSegmentsDuration": 2,
"sourceBytes": 1,
"transcodedBytes": 2,
"ingestRate": 1,
"outgoingRate": 2,
"isActive": true,
"isHealthy": "<unknown>",
"issues": "<unknown>",
"createdByTokenName": "abc-123-xyz-456",
"createdAt": 1587667174725,
"parentId": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
"streamKey": "hgebdhhigq",
"pull": {
"source": "https://myservice.com/live/stream.flv",
"headers": {
"Authorization": "Bearer 123"
},
"isMobile": 0,
"location": {
"lat": 39.739,
"lon": -104.988
}
},
"playbackId": "eaw4nk06ts2d0mzb",
"playbackPolicy": {
"type": "webhook",
"webhookId": "1bde4o2i6xycudoy",
"webhookContext": {
"streamerId": "my-custom-id"
},
"refreshInterval": 600,
"allowedOrigins": [
"<string>"
]
},
"profiles": [
{
"name": "240p0",
"fps": 0,
"bitrate": 250000,
"width": 426,
"height": 240
},
{
"name": "360p0",
"fps": 0,
"bitrate": 800000,
"width": 640,
"height": 360
},
{
"name": "480p0",
"fps": 0,
"bitrate": 1600000,
"width": 854,
"height": 480
},
{
"name": "720p0",
"fps": 0,
"bitrate": 3000000,
"width": 1280,
"height": 720
}
],
"projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9",
"record": false,
"recordingSpec": {
"profiles": [
{
"bitrate": 3000000,
"width": 1280,
"name": "720p",
"height": 720,
"quality": 23,
"fps": 30,
"fpsDen": 1,
"gop": 2,
"profile": "H264Baseline",
"encoder": "H.264"
}
]
},
"multistream": {
"targets": [
{
"id": "PUSH123",
"profile": "720p"
}
]
},
"suspended": true,
"lastTerminatedAt": 1713281212993,
"userId": "we7818e7-610a-4057-8f6f-b785dc1e6f88",
"renditions": {}
}{
"errors": [
[
"id not provided",
"Account not found"
]
]
}Authorizations
Body
application/json
Response
Success
Last modified on April 7, 2026
Was this page helpful?