Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

@renderforest/sdk-node

0.3.0 • Public • Published

renderforest-sdk-node

Renderforest SDK for Node.js.

Build Status

API Reference

Introduction

Welcome to the Renderforest API! You can use our API to:

API

Projects API

Get All Projects

Retrieves the projects.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  limit: 2,
  offset: 10
}
renderforest.getProjects(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The renderedQualities property is optional and present if the project is in renders queue (ongoing rend).

See example

Add Project

Creates a project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  templateId: 701
}
renderforest.addProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • Also, project-data is created with the following list of initial properties: templateId, title, duration, equalizer, isLego, extendableScreens, fps, projectVersion, screens, muteMusic, currentScreenId, projectColors (optional), themeVariableName (optional), themeVariableValue (optional).

  • The "muteMusic" is false initially.

  • If template is lego ("isLego": true), then no initial screen is added and "screens" defaults to []. Otherwise, at least one screen is present.

  • The "currentScreenId" is the id of the first screen for non-lego templates & null for lego templates.

  • The "projectColors" is optional and gets value if the template has default colors. Both lego & non-lego templates might have default colors.

  • Both "themeVariableName" & "themeVariableValue" are optional and are added (both) if template has theme. Both lego & non-lego templates might have a theme.

See example

Get Trial Project

This endpoint retrieves a trial project. Designed to allow the user to make a project (trial - without saving) before getting logged in to get an overall idea. The data can be used later to create real project (create project, update project-data with this data).

No authorization is required for this endpoint.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTrialProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Get a Specific Project

Gets a specific project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000295
}
renderforest.getProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Update the Project - partial update

Updates the project (partial update).

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000658,
  customTitle: 'Graduation'
}
renderforest.updateProjectPartial(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Delete a Specific Project

Deletes a specific project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000658
}
renderforest.deleteProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Apply Template Preset on the Project

Applies template preset on the project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000658,
  presetId: 55
}
renderforest.applyTemplatePresetOnProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Duplicate the Project

Duplicates the project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000658
}
renderforest.duplicateProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Render the Project

Renders the project.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5000658,
  quality: 1080
}
renderforest.renderProject(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The possible values of the quality are: 0, 360, 720, and 1080.

See example

Projects-data API

Get Project-data

Retrieves a specific project-data.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 5180504
}
renderforest.getProjectData(payload)
  .then((projectDataInstance) => {
    console.log('Project id:', projectDataInstance.getProjectId())
    console.log('Template id:', projectDataInstance.getTemplateId())
    console.log('Is equalizer:', projectDataInstance.isEqualizer())
    console.log('Is lego:', projectDataInstance.isLego())
    console.log('Title:', projectDataInstance.getTitle())
    console.log('Mute music:', projectDataInstance.getMuteMusic())
    console.log('Sounds:', projectDataInstance.getSounds())
    console.log('Styles:', projectDataInstance.getStyles())
    console.log('VoiceOver:', projectDataInstance.getVoiceOver())
    console.log('Project colors:', projectDataInstance.getProjectColors())
    console.log('Screens:', projectDataInstance.getScreens())
 
    const screens = projectDataInstance.getScreens()
    const firstScreenAreas = screens && screens[0] && screens[0].getAreas()
    console.log('First screen area:', firstScreenAreas)
  })
  .catch(console.error) // handle the error

See example

See the Getters and Setters of Project-data Instance

Update Project-data - partial update

Updates the project-data (partial update).

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  projectId: 7096113
}
 
async function sample () {
  const projectDataInstance = await renderforest.getProjectData(payload)
 
  // make some change
  projectDataInstance.setMuteMusic(true)
 
  // get payload data
  const projectId = projectDataInstance.getProjectId()
  const data = projectDataInstance.getPatchObject()
 
  const result = await renderforest.updateProjectDataPartial({ projectId, data })
 
  projectDataInstance.resetPatchObject()
 
  return result
}
 
sample()
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • You can update the following list of properties: currentScreenId, duration, generator, muteMusic, themeVariableName, themeVariableValue, projectColors, simple, sounds, screens, voiceSoundId.

  • Any top-level properties (writable) can be updated separately (except themeVariableName & themeVariableValue), as well as all of them at the same time.

  • The themeVariableName & themeVariableValue are related to the template theme and both should be updated at the same time. Possible values you can get in the template theme section (https://developers.renderforest.com/#get-theme-of-the-template).

  • The iconAdjustable field of the screen takes one of the 0, 1 or 2 values. If iconAdjustable is 0, then the icon is not updatable. The value 1 indicates that the icon is on the left side, and the value 2 indicates that the icon is on the right side. You can update 1 <-> 2 to change the icon from left <-> right.

  • No blob data accepted for the value field of a screen area.

  • See example

  • See advanced example

See the Getters and Setters of Project-data Instance

Getters and Setters of Project-data Instance

Getters

Get project id
projectDataInstance.getProjectId()  // 7096113
Get template id
projectDataInstance.getTemplateId()  // 701
Check whether is equalizer or not
projectDataInstance.isEqualizer()  // false
Check whether is lego or not
projectDataInstance.isLego()  // true
Get title
projectDataInstance.getTitle()  // 'Explainer Video Toolkit'
Get mute music
projectDataInstance.getMuteMusic()  // false
Get sounds
projectDataInstance.getSounds()  // Array of sound objects
Get styles
projectDataInstance.getStyles()  // { theme: '1', transition: '2' }
Get voice-over
projectDataInstance.getVoiceOver() // { path: 'https://example.com/voice-over.mp3' }
Get project colors
projectDataInstance.getProjectColors()  // Array of color objects
Get screens
projectDataInstance.getScreens()  // Array of screen objects
Get screen areas
const screens = projectDataInstance.getScreens()
 
const firstScreenAreas = screens && screens[0] && screens[0].getAreas()  // Array of area objects
Get patch object
projectDataInstance.getPatchObject()  // Object containing local updates. Used to update project-data (partial). 

Setters

Set styles
// get theme/transition from .templates API
const styles = {
  theme: '1', // optional
  transition: '2' // optional
}
projectDataInstance.setStyles(styles)
Set voice-over
const voiceOver = {
  path: 'https://example.com/voice-ower.mp3' // optional
}
projectDataInstance.setVoiceOver(voiceOver)
Set mute music
projectDataInstance.setMuteMusic(true)
Set sounds
// sound from ./sounds API
const sound1 = {
  duration: 120,
  id: 559,
  genre: 'Rock', // optional
  lowQuality: 'https://example.com/sample-low.mp3',
  path: 'https://example.com/sample.mp3',
  title: 'Inspiring Piano'
}
 
// your own sound
const sound2 = {
  duration: 12,
  fileSize: 198658,
  id: 952626,
  path: 'https://example.com/sample.mp3',
  title: 'sound sample.mp3',
  userId: 1469277,
  voiceOver: false
}
 
const sounds = [ sound1, sound2 ]
projectDataInstance.setSounds(sounds)
Set text on text holder area
const screens = projectDataInstance.getScreens()
 
if (screens && screens[0]) {
  const areas = screens[0].getAreas()
 
  const area = areas[0]
  if (area && area.type === 'text') {
    area.setText('sample text')
  }
}
Set image on image holder area
const screens = projectDataInstance.getScreens()
 
if (screens && screens[1]) {
  const areas = screens[1].getAreas()
 
  const area = areas[0]
  if (area && area.type === 'image') {
    const image = {
      fileName: 'sample file name', // optional
      mime: 'image/png', // optional
      filePath: 'https://example.com/sample.png',
      webpPath: 'https://example.com/sample.webp', // optional
      fileType: 'image', // optional
      thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
      imageCropParams: {
        transform: 0,
        top: 11,
        left: 0,
        width: 798,
        height: 456
      }
    }
 
    area.setImage(image)
  }
}
Set video on video holder area
const screens = projectDataInstance.getScreens()
 
if (screens && screens[2]) {
  const areas = screens[2].getAreas()
 
  const area = areas[0]
  if (area && area.type === 'video') {
    const video = {
      fileName: 'sample file name', // optional
      mime: 'video/mp4', // optional
      filePath: 'https://example.com/sample.png',
      webpPath: 'https://example.com/sample.webp', // optional
      fileType: 'video', // optional
      videoCropParams: {
        duration: 6,
        mime: 'video/mp4',
        thumbnail: 'https://example.com/sample-thumbnail.png',
        thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
        trims: [0, 2, 3, 5],
        volume: {
          music: 10,
          video: 100
        }
      }
    }
 
    area.setVideo(video)
  }
}
Set project colors
// get project colors from ./templates API
const projectColors = [
  'ffffff', 'a1d4ec', '1d2e54', '61a371', 'a0b6e7', 'e0d0ef', '5c1313', 'b2e1f4', '706bb5', 'b4ddf5'
]
projectDataInstance.setProjectColors(projectColors)
Set screens
// get screen from ./templates API
const screen = {
  id: 2125620,
  characterBasedDuration: true,
  compositionName: '191_man_Angry_2',
  duration: 5,
  extraVideoSecond: 0,
  iconAdjustable: 0,
  gifPath: 'https://example.com/191_man_Angry_2_1.gif',
  gifBigPath: 'https://example.com/191_man_Angry_2_1.gif',
  gifThumbnailPath: 'https://example.com/191_man_Angry_2_n.jpg',
  hidden: false,
  maxDuration: 15,
  order: 1900,
  path: 'https://example.com/191_man_Angry_2_n.jpg',
  tags: 'business, computer, chair, desk, laptop, occupation, office, worker, arms, boss, boy, businessman,chef, company, employer, professional',
  title: 'Angry Office worker with arms crossed',
  type: 1,
  areas: [
    {
      id: 3562168,
      cords: [ 656, 224, 1048, 224, 1048, 332, 656, 332 ],
      height: 108,
      order: 0,
      title: 'char_Angry_2',
      type: 'text',
      value: '',
      wordCount: 40,
      width: 392
    }
  ]
}
const _screens = projectDataInstance.getScreens()
_screens.push(screen)
projectDataInstance.setScreens(_screens)

Sounds API

Get All Sounds

Retrieves sounds given the duration.

The endpoint supports both authorized and unauthorized requests. If the authorization is not present, then response limits to 5.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  duration: 4
}
 
Renderforest.getCompanySoundsLimited(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  duration: 4
}
renderforest.getSounds(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The sounds will have greater or equal duration to the specified one.
  • Remember — any given value of the duration greater than 180 will be overridden by 180!

See example

See example

Get Recommended Sounds

Retrieves recommended sounds for the given template.

The endpoint supports both authorized and unauthorized requests. If the authorization is not present, then response limits to 5.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701,
  duration: 5
}
 
Renderforest.getRecommendedSoundsLimited(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  templateId: 701,
  duration: 5
}
renderforest.getRecommendedSounds(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • These sounds will have greater or equal duration to the specified one.
  • Remember — any given value of the duration greater than 180 will be overridden by 180!

See example

See example

Supports API

Add Supports Ticket

Creates supports ticket.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
 
const payload = {
  message: 'I need to...',
  mailType: 'Sales',
  subject: 'Some help in ..'
}
renderforest.addSupportsTicket(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The possible values of ticket mailType are: 'Sales', 'Report a bug', 'Editing process', 'Creative team', 'Other'.

See example

Templates API

No authorization is required for ./templates API's.

Get All Templates

Retrieves all templates.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  categoryId: 3,
  equalizer: false,
  limit: 4,
  offset: 10
}
Renderforest.getTemplates(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

Get Templates Categories

Retrieves templates categories.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  language: 'en'
}
Renderforest.getTemplatesCategories(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The supported language codes are: ar, de, en, es, fr, pt, ru, tr.

See example

Get a Specific Template

Retrieves a specific template.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701,
  language: 'en'
}
Renderforest.getTemplate(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The supported language codes are: ar, de, en, es, fr, pt, ru, tr.

See example

Get Color-Presets of the Template

Retrieves color-presets of the template. You can apply these color presets to your project to give it better and unique look.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTemplateColorPresets(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The number of color-presets is varying from template to template.

See example

Get Pluggable-Screens of the Template

Retrieves pluggable-screens of the template.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTemplatePluggableScreens(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • Only lego templates might have a pluggable-screen.
  • The number of pluggable-screens is varying from template to template. Pluggable-Screens are grouped by categories.

See example

Get Recommended-Custom-Colors of the Template

Retrieves recommended-custom-colors of the template. You can apply these recommended custom colors to your project to give it better and unique look.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTemplateRecommendedCustomColors(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • The number of recommended-custom-colors is varying from template to template.

See example

Get Template-Presets of the Template

Retrieves template-presets of the template.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTemplatePresets(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • Only lego templates might have a template-preset.

  • The number of template-presets is varying from template to template. Template-presets are ready-made stories created from this template to fasten your video production.

See example

Get Theme of the Template

Retrieves theme of the template.

const Renderforest = require('@renderforest/sdk-node')
 
const payload = {
  templateId: 701
}
Renderforest.getTemplateTheme(payload)
  .then(console.log) // handle the success
  .catch(console.error) // handle the error
  • Both lego & non-lego templates might have a theme.

See example

Users API

Get Current User

Retrieves the current user.

const Renderforest = require('@renderforest/sdk-node')
 
const renderforest = new Renderforest({ signKey: 'signKey', clientId: -1 })
 
renderforest.getCurrentUser()
  .then(console.log) // handle the success
  .catch(console.error) // handle the error

See example

install

npm i @renderforest/sdk-node

Downloadsweekly downloads

4

version

0.3.0

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability