Livepeer API Reference
Welcome to the Livepeer API reference docs. Here you'll find all the endpoints exposed on the standard Livepeer API, learn how to use them and what they return.
The Livepeer API is organized around REST, has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Just Getting Started?
Head over to Livepeer Studio, create an account and start building with Livepeer.
https://livepeer.studio/api
Create a stream
POST /stream creates a stream object. The configuration on this stream
object is inherited by all live sessions using this stream's streamKey.
It is important to note, that the stream object is the core building
block of the Livepeer Studio platform. In Livepeer Studio, the stream
object has unique configuration data and metadata about all livestream
sessions that are associated with the stream.
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"}
Parameters
No parameters available.
[]
Retrieve streams
GET /stream
endpoint is used to retrieve all stream objects with the same userId. The response will include both parent stream objects and the historic stream objects with a parentId, which represent a single live stream session. Please note that the usage of these "child-session" stream objects is deprecated, and it is recommended to use the session endpoints instead.
To filter the API response and exclude the historic stream objects with a parentId, you can add the ?streamsonly=true
query string.
GET /stream?streamsonly=1
This endpoint retrieves all stream objects with the same userId and excludes the historic stream objects with a parentId, which represent a single live stream session.
Quick Filters
Filter | Example | Description |
---|---|---|
All stream objects with the same userId | /api/stream?streamsonly=1 | This filter excludes the historic stream objects with a parentId, which represent a single live stream session. |
All active stream objects | /api/stream?streamsonly=1&filters=[{"id": "isActive", "value": true}] | This filter returns active stream objects. Setting the value to false returns idle stream objects. The default value for new stream objects is false . Note that the example shows a decoded JSON object, but in a URL, it should be URL-encoded. |
All stream objects with recording on | /api/stream?streamsonly=1&filters=[{"id": "record", "value": true}] | This filter returns stream objects with recording turned on. The default value for new stream objects is false . Note that the example shows a decoded JSON object, but in a URL, it should be URL-encoded. |
Parameters
No parameters available.
[]
Retrieve a stream
In order to retrieve a specific stream, you can just pass the stream id to this API
Parameters
No parameters available.
[]
Update a stream
PATCH /stream/{id} can be used to modify a stream object. It is a single endpoint that can update any of the mutable properties of a stream. Specifically:
All fields in the request payload are optional, and any field that is not included will keep the same value as before in the saved object.
A 204 No Content status response indicates the stream was successfully updated
Parameters
No parameters available.
[]
Delete a stream
DELETE /stream/{id} deletes an existing stream object.
This will also suspend any active stream sessions, so make sure to wait
until the stream has finished. To explicitly interrupt an active
session, consider instead updating the suspended field in the stream
using the PATCH stream API.
Parameters
No parameters available.
[]
Retrieve Multistream Targets
Use /multistream/target to a return a list of your existing multistream targets.
Parameters
No parameters available.
[]
Create a multistream target
Parameters
No parameters available.
[]
Retrieve a multistream target
You can retrieve a multistream target from its ID with this API.
Parameters
No parameters available.
[]
Update Multistream Target
PATCH /multistream/target/{id} updates an existing multistream target
object. You can change any user-defined field in the current object,
specifically name, url and disabled.
All fields are optional, and if any field is not included in the request
payload it will be kept unchanged from the saved object.
You cannot access the current url field for updating it since we redact
it from GET responses. If you want to update the URL you have to build
it from scratch. You can also omit it from the PATCH payload to keep it
as is.
A 204 No Content status response indicates the multistream target was
successfully updated.
Parameters
No parameters available.
[]
Delete a multistream target
DELETE /multistream/target/{id} deletes an existing multistream target object. Make sure to remove any references to the target on existing streams before actually deleting it from the API.
Parameters
No parameters available.
[]
Retrieve a Webhook
Parameters
No parameters available.
[]
Create a webhook
To create a new webhook, you need to make an API call with the events you want to listen for and the URL that will be called when those events occur.
Types of Events
Name | Description |
---|---|
stream.started | The parent stream object's isActive value is marked as true and the .m3u8 HLS URL works |
stream.idle | The parent stream object's isActive value should be marked as false and the .m3u8 HLS URL no longer works |
recording.ready | This fires when a recording is ready to be downloaded |
recording.started | This fires when recording has started on an active stream |
recording.waiting | This fires after a stream with recording on has concluded and is not yet ready to be downloaded. Typically it takes 5 minutes for recordings to be ready for download |
multistream.connected | This fires when we've successfully connected to the multistream target |
multistream.error | This fires when we've encountered an error either while attempting to connect to the third-party streaming service or while broadcasting |
multistream.disconnected | This fires when we are no longer sending video to the multistream target |
asset.created | This fires when an On Demand asset is created |
asset.updated | This fires when an On Demand asset is updated |
asset.ready | This fires when an On Demand asset is ready |
asset.failed | This fires when an On Demand asset fails during the upload or during processing |
asset.deleted | This fires when an On Demand asset is deleted |
task.spawned | This fires when a task is spawned (e.g., an On Demand upload) |
task.updated | This fires when a task is updated |
task.completed | This fires when a task completes its execution successfully |
task.failed | This fires when a task has failed |
playback.accessControl | A specialized webhook for playback access control. Unlike other events, this is only used for assets and streams that reference its ID on their playback policy |
Parameters
No parameters available.
[]
Retrieve a webhook
Parameters
No parameters available.
[]
Update a webhook
You can update a webhook by calling the PATCH webhook endpoint with the webhookId. It is a single endpoint that can update any of the mutable properties of a webhook. Specifically:
Parameters
No parameters available.
[]
Delete a webhook
Parameters
No parameters available.
[]
Retrieve assets
Parameters
No parameters available.
[]
Upload an asset
To upload an asset, your first need to request for a direct upload URL
and only then actually upload the contents of the asset.
Once you created a upload link, you have 2 options, resumable or direct
upload. For a more reliable experience, you should use resumable uploads
which will work better for users with unreliable or slow network
connections. If you want a simpler implementation though, you should
just use a direct upload.
Direct Upload
For a direct upload, make a PUT request to the URL received in the url field of the response above, with the raw video file as the request body. response above:
Resumable Upload
Livepeer supports resumable uploads via Tus. This section provides a
simple example of how to use tus-js-client to upload a video file.
From the previous section, we generated a URL to upload a video file to
Livepeer on POST /api/asset/request-upload. You should use the
tusEndpoint field of the response to upload the video file and track the
progress:
# This assumes there is an `input` element of `type="file"` with id
`fileInput` in the HTML
const input = document.getElementById('fileInput');
const file = input.files[0];
const upload = new tus.Upload(file, {
endpoint: tusEndpoint, // URL from `tusEndpoint` field in the
`/request-upload` response
metadata: {
filename,
filetype: 'video/mp4',
},
uploadSize: file.size,
onError(err) {
console.error('Error uploading file:', err);
},
onProgress(bytesUploaded, bytesTotal) {
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
console.log('Uploaded ' + percentage + '%');
},
onSuccess() {
console.log('Upload finished:', upload.url);
},
});
const previousUploads = await upload.findPreviousUploads();
if (previousUploads.length > 0) {
upload.resumeFromPreviousUpload(previousUploads[0]);
}
upload.start();
Note: If you are using tus from node.js, you need to add a custom URL storage to enable resuming from previous uploads. On the browser, this is enabled by default using local storage. In node.js, add urlStorage: new tus.FileUrlStorage("path/to/tmp/file"), to the UploadFile object definition above.
Parameters
No parameters available.
[]
Upload asset via URL
Import a video Asset from an external URL through the POST
/api/asset/upload/url API.
For rapid processing of assets that will also be archived on IPFS or Arweave,
we strongly encourage uploading the raw file to Livepeer via a direct upload rather than passing the IPFS / Arweave gateway URL to this endpoint.
The gateway URL will work, but may incur longer-than-usual processing time.
For IPFS HTTP gateway URLs, the API currently only supports “path style”
URLs and does not support “subdomain style” URLs. The API will support
both styles of URLs in a future update.
Parameters
No parameters available.
[]
Retrieves an asset
Parameters
No parameters available.
[]
Delete an asset
Parameters
No parameters available.
[]
Create a room
Create a multiparticipant livestreaming room.
Parameters
No parameters available.
[]
Retrieve a room
Parameters
No parameters available.
[]
Delete a room
Parameters
No parameters available.
[]
Start room RTMP egress
Create a livestream for your room. This allows you to leverage livestreaming features like recording and HLS output.
Parameters
No parameters available.
[]
Stop room RTMP egress
Parameters
No parameters available.
[]
Create a room user
Call this endpoint to add a user to a room, specifying a display name at a minimum. The response will contain a joining URL for Livepeer's default meeting app. Alternatively the joining token can be used with a custom app.
Parameters
No parameters available.
[]
Get user details
Parameters
No parameters available.
[]
Update a room user
Update properties for a user.
Parameters
No parameters available.
[]
Remove a user from the room
Parameters
No parameters available.
[]
Query viewership metrics
Allows querying any metric in its raw form. Requires a private (non-CORS) API key to be used.
Parameters
No parameters available.
[]
Query creator viewership metrics
Allows querying creator-specific metrics. Requires a proof of ownership to be sent in the request, which for now is just the assetId or streamId parameters (1 of those must be in the query-string). Returns only the higher level metrics like viewCount and platimeMins. Can be used from the frontend with a CORS key.
Parameters
No parameters available.
[]
Query public total views metrics
Allows querying for the public metrics for viewership about a video. This can be called from the frontend with a CORS key, or even unauthenticated.
Parameters
No parameters available.
[]
Query usage metrics
Allows querying any metric in its raw form. This can be called from the frontend with a CORS key.
Parameters
No parameters available.
[]
Retrieve sessions
Parameters
No parameters available.
[]
Retrieve a session
Parameters
No parameters available.
[]
Retrieve Recorded Sessions
Parameters
No parameters available.
[]
Create a signing key
A signing key is used to sign JWTs and are necessary to make a stream
private.
When you create a signing key, the request returns a base64 encoded pem
keypair, where
Up to 10 signing keys can be generated, after that you must delete at least one signing key to create a new one.
Parameters
No parameters available.
[]
Retrieves signing keys
You can list all the signing keys in your account by making a GET request on /api/access-control/signing-key.
Parameters
No parameters available.
[]
Delete Signing Key
Parameters
No parameters available.
[]
Retrieves a signing key
Parameters
No parameters available.
[]
Update a signing key
PATCH /access-control/signing-key/{KEY_ID} updates an existing signing key. It is a single endpoint that can update any of the mutable properties of a stream. Specifically:
All fields are optional, and if any field is not included in the request payload it will be kept unchanged from the saved object.
Parameters
No parameters available.
[]
Retrieve Tasks
Parameters
No parameters available.
[]
Retrieve a Task
Retrieves the details of a Task, including progress updates and status. Supply the unique Task ID that was returned from your previous request or from an Asset export.
Parameters
No parameters available.
[]
Transcode a video
POST /transcode
transcodes a video file and uploads the results to the
specified storage service.
Transcoding is asynchronous so you will need to check the status of the
task in order to determine when transcoding is complete. The id
field
in the response is the unique ID for the transcoding Task
. The task
status can be queried using the GET tasks
endpoint:
When status.phase
is completed
, transcoding will be complete and
the results will be stored in the storage service and the specified
output location.
The results will be available under params.outputs.hls.path
and
params.outputs.mp4.path
in the specified storage service.
Input
This endpoint currently supports the following inputs:
HTTP
A public HTTP URL can be used to read a video file.
{
"url": "https://www.example.com/video.mp4"
}
Name | Type | Description |
---|---|---|
url | string | A public HTTP URL for the video file. |
Note: For IPFS HTTP gateway URLs, the API currently only supports “path
style” URLs and does not support “subdomain style” URLs. The API will
support both styles of URLs in a future update.
S3 API Compatible Service
S3 credentials can be used to authenticate with a S3 API compatible
service to read a video file.
{
"type": "s3",
"endpoint": "https://gateway.storjshare.io",
"credentials": {
"accessKeyId": "$ACCESS_KEY_ID",
"secretAccessKey": "$SECRET_ACCESS_KEY"
},
"bucket": "inbucket",
"path": "/video/source.mp4"
}
Name | Type | Description |
---|---|---|
type | string | The type of storage service. Supported: "s3". |
endpoint | string | The S3 endpoint. |
credentials.accessKeyId | string | The S3 access key ID. |
credentials.secretAccessKey | string | The S3 access key secret. |
bucket | string | The name of the S3 bucket. |
path | string | The path within the S3 bucket of the video file. |
Storage
This endpoint currently supports the following storage services:
S3 API Compatible Service
{
"type": "s3",
"endpoint": "https://gateway.storjshare.io",
"credentials": {
"accessKeyId": "$ACCESS_KEY_ID",
"secretAccessKey": "$SECRET_ACCESS_KEY"
},
"bucket": "mybucket"
}
Name | Type | Description |
---|---|---|
type | string | The type of storage service. |
endpoint | string | The S3 endpoint. |
credentials.accessKeyId | string | The S3 access key ID. |
credentials.secretAccessKey | string | The S3 access key secret. |
bucket | string | The path within the S3 bucket of the video file. |
Web3 Storage
{
"type": "web3.storage",
"credentials": {
"proof": "$UCAN_DELEGATION_PROOF",
}
}
Name | Type | Description |
---|---|---|
type | string | The type of storage service. |
credentials.proof | string | Base64-encoded UCAN delegation proof. |
Outputs
This endpoint currently supports the following output types:
HLS
{
"hls": {
"path": "/samplevideo/hls"
}
}
Name | Type | Description |
---|---|---|
path | string | The path of the directory that HLS playlists and mpegts segments will be stored in. |
MP4
{
"mp4": {
"path": "/samplevideo/mp4"
}
}
Name | Type | Description |
---|---|---|
path | string | The path of the directory that MP4 output videos will be stored in. |
Parameters
No parameters available.
[]
Retrieve Playback Info
You can retrieve the playback information about any playback identifier by calling this endpoint. It accepts playbackIds from any resource in the API as well as dStorage IDs for assets.
Parameters
No parameters available.
[]