Corellia API
This module provides easy access to Corellia's API to request and manage video rendering.
Installation
npm i --save @kassellabs/corellia-api
Usage
First you should get your Corellia API Client ID and Client Secret, then you can start using this project by instantiating the main class
import CorelliaAPI from '@kassellabs/corellia-api';
const api = new CorelliaAPI({
clientId: '< your corellia client id >',
clientSecret: '< your corellia client secret >',
});
You can also specify a different API endpoint via host
param on the constructor.
After that you can start calling the main methods:
requestNewVideo(customJSON)
Requests a new video to be rendered based on a custom JSON
const videoRequest = await api.requestNewVideo(customJSON);
// Example:
//
// {
// "lastModified":"2020-01-24T18:08:13.654Z",
// "userId":"XXXX",
// "actions":[
// ...,
// ],
// "templateId":"my-template-id",
// "customJSON":{
// "videoURL":"<my-video-url>",
// "timeToBeContinued":9.731636028610229,
// "videoStartAt":0,
// "videoEndAt":14.731636028610229
// },
// "renderJob":{
// "state":"started",
// "downloadURL":null
// },
// "id":"IIIIIIIIIIIIII"
// }
getAllVideoRequests()
Retrieve a list of all requestd videos so far
const videoRequests = await api.getAllVideoRequests(customJSON);
// Example:
//
// [{
// "lastModified":"2020-01-24T18:08:13.654Z",
// "userId":"XXXX",
// "actions":[
// ...,
// ],
// "templateId":"my-template-id",
// "customJSON":{
// "videoURL":"<my-video-url>",
// "timeToBeContinued":9.731636028610229,
// "videoStartAt":0,
// "videoEndAt":14.731636028610229
// },
// "renderJob":{
// "state":"started",
// "downloadURL":null
// },
// "id":"IIIIIIIIIIIIII"
// }, ...]
getVideoRequest(id)
Retrieve the status of a already created videoRequest
const videoRequest = await api.getVideoRequest('<your-video-request-id>');
// Example:
//
// {
// "lastModified":"2020-01-24T18:08:13.654Z",
// "userId":"XXXX",
// "actions":[
// ...,
// ],
// "templateId":"my-template-id",
// "customJSON":{
// "videoURL":"<my-video-url>",
// "timeToBeContinued":9.731636028610229,
// "videoStartAt":0,
// "videoEndAt":14.731636028610229
// },
// "renderJob":{
// "state":"started",
// "downloadURL":null
// },
// "id":"IIIIIIIIIIIIII"
// }
deleteVideoRequest(id)
Remove a specific video request
const { success } = await api.deleteVideoRequest('<your-video-request-id>');
// success === true -> deleted
// success === false -> not deleted