Docs

Log inSign up
GuidesAPI Reference

CONTENT

Overview

Start live streaming

Getting started tutorial

Configure broadcast software

Get an API key

Verify a live stream is active

Create a stream

Playback a live stream

Record a live stream session

Stream delivery via CDN

Using webhooks

Check webhook signatures

Redundant back-up transcoding

Tips for reducing latency

Handling disconnects

Debug live stream issues

Create paywall

Supported codecs and workflows

API Requests

Using livepeer.com in your app

Usage and Billing

#Using Webhooks

Livepeer uses webhooks to communicate with your application asynchronously when events for your stream occur. For example, you may want to know when a stream has become active or idle, so that you can surface this information to viewers. When these events happen, we’ll make a POST request to a URL that you specify.

#How to configure endpoints

Webhook endpoints are specific for each event. Once the event is registered, all streams for this account will be triggering the specific event. Here is an example of registering for the stream.started and stream.idle events:

curl \
-X POST \
-H "authorization: Bearer {api_key}" \
-H "content-type: application/json" \
--data-raw '{
"events": ["stream.started", "stream.idle"],
"url": "{webhook_url}",
"name": "test webhooks"
}' \
https://livepeer.com/api/webhook

This request should return:

{
"createdAt" : 1624939859628,
"events": ["stream.started", "stream.idle"],
"id" : "e7b8a281-8952-4791-b837-183cb95bbf32",
"kind" : "webhook",
"name" : "test webhooks",
"url" : "{webhook_endpoint}",
"userId" : "ffcd3b74-9908-4d23-be05-58e1480e752a"
}

Now all streams will trigger the stream.started and stream.idle events for this account.

#Other webhooks endpoints

GET /api/webhook: Get a list of webhooks

GET /api/webhook/:webhookID: Get a single webhook Object details

PUT /api/webhook/:webhookID: Edit a webhook, using the same parameters as POST /webhook

DEL /api/webhook/:webhookID: Delete a webhook

#Webhook events

Livepeer currently have two webhooks events: stream.started and stream.idle.

After you receive the stream.started event, the “parent” stream object’s isActive value should be marked as true and the .m3u8 HLS URL constructed from the playbackId now works.

{
"id": "e7b8a281-8952-4791-b837-183cb95bbf32",
"event": "stream.started",
"stream": {
"lastSeen": 1624835029795,
"isActive": false,
"record": false,
"suspended": false,
"sourceSegments": 348005,
"transcodedSegments": 1392788,
"sourceSegmentsDuration": 781762.2160000018,
"transcodedSegmentsDuration": 3127919.1879999815,
"sourceBytes": 264901715475844,
"transcodedBytes": 65773596716,
"id": "e0f1ed4f-1359-420c-838f-ebce7633ec3c",
"kind": "stream",
"name": "test",
"region": "mdw",
"userId": "4ef34b74-9908-4d23-be05-58e2480e752a",
"profiles": [
{
"fps": 0,
"name": "240p0",
"width": 426,
"height": 240,
"bitrate": 250000
},
{
"fps": 0,
"name": "360p0",
"width": 640,
"height": 360,
"bitrate": 800000
},
{
"fps": 0,
"name": "480p0",
"width": 854,
"height": 480,
"bitrate": 1600000
},
{
"fps": 0,
"name": "720p0",
"width": 1280,
"height": 720,
"bitrate": 3000000
}
],
"createdAt": 1604415705270,
"ingestRate": 0,
"playbackId": "e0ebw4qldvlofow5",
"renditions": {},
"outgoingRate": 0
}
}

After you receive the stream.idle event, the “parent” stream object’s isActive value should be marked as 'false` and the .m3u8 HLS URL constructed from the playbackId no longer works.

{
"id": "e7b8a281-8952-4791-b837-183cb95bbf32",
"event": "stream.idle",
"stream": {
"lastSeen": 1624835029795,
"isActive": false,
"record": false,
"suspended": false,
"sourceSegments": 348005,
"transcodedSegments": 1392788,
"sourceSegmentsDuration": 781762.2160000018,
"transcodedSegmentsDuration": 3127919.1879999815,
"sourceBytes": 264901715475844,
"transcodedBytes": 65773596716,
"id": "e0f1ed4f-1359-420c-838f-ebce7633ec3c",
"kind": "stream",
"name": "test",
"region": "mdw",
"userId": "4ef34b74-9908-4d23-be05-58e2480e752a",
"profiles": [
{
"fps": 0,
"name": "240p0",
"width": 426,
"height": 240,
"bitrate": 250000
},
{
"fps": 0,
"name": "360p0",
"width": 640,
"height": 360,
"bitrate": 800000
},
{
"fps": 0,
"name": "480p0",
"width": 854,
"height": 480,
"bitrate": 1600000
},
{
"fps": 0,
"name": "720p0",
"width": 1280,
"height": 720,
"bitrate": 3000000
}
],
"createdAt": 1604415705270,
"ingestRate": 0,
"playbackId": "e0ebw4qldvlofow5",
"renditions": {},
"outgoingRate": 0
}
}