Skip to main content

Cloud Render API

If you are interested to use it on production, please contact anton at polotno.com. You will need to have "Enterprise plan" to call this 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 1000 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.

Cloud Render Scheme

How does it look?

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;

Demo?

Template JSON (result of store.toJSON() export):

Output options:

File type:
Pixel ratio:
1

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 on your backend. For example 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.

Note: 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 has expiration time of 24 hour. After that time, access to the file is not guaranteed. If you want to keep file, please save it on your backend.

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
}