The Livepeer JavaScript library provides convenient access to the Livepeer Studio API from applications written in both browser and server-side JavaScript
For full documentation and examples, please visit docs.livepeer.org.
Install the package with:
npm install livepeer
# or
yarn add livepeer
The package needs to be configured with your Livepeer Studio account's API key, which is available in the Studio Dashboard
import Livepeer from "livepeer";
const livepeer = new Livepeer({
apiKey: "",
});
const streams = await livepeer.stream.getAll;
console.log(stream.length);
The default server can also be overridden globally by passing a URL to the serverURL: str
optional parameter when initializing the SDK client instance. For example:
import { Livepeer } from "livepeer";
const livepeer = new Livepeer({
serverURL: "https://livepeer.studio/api",
apiKey: "",
});
const res = await sdk.stream.getAll();
if (res.statusCode == 200) {
// handle response
}
The Typescript SDK makes API calls using the (axios)[https://axios-http.com/docs/intro] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance
object.
For example, you could specify a header for every request that your sdk makes as follows:
import { Livepeer } from "livepeer";
import axios from "axios";
const httpClient = axios.create({
headers: { "x-custom-header": "someValue" },
});
const livepeer = new Livepeer({ defaultClient: httpClient });
- getAll - Retrieve streams
- create - Create a stream
- delete - Delete a stream
- get - Retrieve a stream
- update - Update a stream
- createClip - Create a clip
- getAllClips - Retrieve clips of a livestream
- getAll - Retrieve Multistream Targets
- create - Create a multistream target
- delete - Delete a multistream target
- get - Retrieve a multistream target
- update - Update Multistream Target
- getAll - Retrieve a Webhook
- create - Create a webhook
- delete - Delete a webhook
- get - Retrieve a webhook
- update - Update a webhook
- getAll - Retrieve assets
- create - Upload an asset
- createViaURL - Upload asset via URL
- delete - Delete an asset
- get - Retrieves an asset
- update - Update an asset
- getViewership - Query viewership metrics
- getCreatorViewership - Query creator viewership metrics
- getPublicTotalViews - Query public total views metrics
- getUsage - Query usage metrics
- getAll - Retrieve sessions
- get - Retrieve a session
- getRecorded - Retrieve Recorded Sessions
- getAllClips - Retrieve clips of a session
- getSigningKeys - Retrieves signing keys
- createSigningKey - Create a signing key
- deleteSigningKey - Delete Signing Key
- getSigningKey - Retrieves a signing key
- updateSigningKey - Update a signing key
- create - Transcode a video
- get - Retrieve Playback Info