Cloud Render API

What is Cloud Render API?

Using Polotno SDK you can generate images directly on the client. But sometimes you need to generate images on the backend. For example if you want to generate a 1,000 images with different text on it or if you want to simply offload rendering work from the client.

You can render images on the backend using Polotno Node.js SDK. But it requires you to have your own backend infrastructure.

Polotno Cloud Render API allows you to generate images on the cloud without any backend infrastructure. You can use it to generate images on the fly or to generate images in bulk.


What does it look like?

const req = await fetch('https://api.polotno.com/api/render?KEY=YOUR_API_KEY', {
  method: 'POST',
  headers: {
    // it is important to set a json content type
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    // polotno json from store.toJSON()
    design: json,
    // optional output format for export
    outputFormat: 'dataURL',
    // optional export options for store.toDataURL() method
    exportOptions: {},
  }),
});

const { url } = await req.json();

document.getElementById('image').src = url;


Options

When you send request to the API, you need to pass JSON into request's body.

{
  "design": {},
  "outputFormat": "dataURL",
  "exportOptions": {}
}


design

design - JSON data from polotno export store.toJSON(). Remember that you can generate such JSON on the fly from your backend (e.g. replace text on some elements dynamically).

outputFormat

outputFormat - defines response format. Possible values are: dataURL (default), url and file.

If you use dataURL or url, API will return json { url: '...' } where url is the generated image url.

file format will return file buffer. You can save it directly on the backend.

⚠️ Important
Cloud API has 5mb limit for its payload!. So it will be not able to return large data in dataURL or file format. You can use url format instead.
Images generated using url format expire in 24 hours. After that time, access to the files is not guaranteed.
You will have to set up the infrastructure for storing files to guarantee the access.

format

File format of generated result. Possible values are: png (default), jpeg, pdf.

exportOptions

Additional options to pass into export function. For more details see store.toDataURL() and store.toPDFDataURL().\

{
  "design": {},
  "exportOptions": {
    "pixelRatio": 2
  }
}


htmlTextRenderEnabled

Optional boolean value to enable Rich Text Feature

{
  "design": {},
  "htmlTextRenderEnabled": true
}


textVerticalResizeEnabled

Optional boolean value to enable Vertically Resized Text

{
  "design": {},
  "textVerticalResizeEnabled": true
}

Get a personalized walkthrough of Polotno's capabilities

News, updates and promos –
subscribe now