Node.js

Get started with Orshot Node SDK


Installation#

npm install --save orshot
yarn add orshot
pnpm install orshot

Import#

import { Orshot } from "orshot";

Initialise#

const orshot = new Orshot(<ORSHOT_API_KEY>);

Render from a template#

Generate a Signed URL#

Examples#

base64 response format

import { Orshot } from "orshot";
const orshot = new Orshot("<ORSHOT_API_KEY>");
let templateId = "open-graph-image-1";
let modifications = {
  title: "Orshot",
  description: "Create Visuals and Automate Image Generation",
  textColor: "",
  backgroundImageUrl: "",
  backgroundColor: "",
};
const response = await orshot.renderFromTemplate({
  templateId,
  modifications,
  responseType: "base64",
  responseFormat: "png",
});

url response format

import { Orshot } from "orshot";
const orshot = new Orshot("<ORSHOT_API_KEY>");
let templateId = "open-graph-image-1";
let modifications = {
  title: "Orshot",
  description: "Create Visuals and Automate Image Generation",
  textColor: "",
  backgroundImageUrl: "",
  backgroundColor: "",
};
const response = await orshot.renderFromTemplate({
  templateId,
  modifications,
  responseType: "url",
  responseFormat: "png",
});

binary response format

import { Orshot } from "orshot";
import { createWriteStream } from "fs";

const orshot = new Orshot("<ORSHOT_API_KEY>");

let templateId = "open-graph-image-1";
let modifications = {
  title: "Orshot",
  description: "Create Visuals and Automate Image Generation",
  textColor: "",
  backgroundImageUrl: "",
  backgroundColor: "",
};

const response = await orshot.renderFromTemplate({
  templateId,
  modifications,
  responseType: "binary",
  responseFormat: "png",
});
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);

createWriteStream("og.png").write(buffer);

This example writes the binary image to the file og.png in the current directory.

renderFromTemplate#

Use this function to render an image/pdf. Render template takes in 4 options passed as an object

{
  templateId,
  modifications,
  responseType,
  responseFormat
}
keyrequireddescription
templateIdYesID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...)
modificationsYesModifications for the selected template.
responseTypeNobase64, binary, url (Defaults to base64).
responseFormatNopng, webp, pdf, jpg, jpeg, avif (Defaults to png).

For available templates and their modifications refer Orshot Templates Page

generateSignedUrl#

Use this function to generate signed URLs

{
  templateId,
  modifications,
  renderType,
  responseFormat,
  expiresAt
}
keyrequireddescription
templateIdYesID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...)
modificationsYesModifications for the selected template.
expiresAtYesExpires at in unix timestamp (Number).
renderTypeNoimages, pdfs (Defaults to images).
responseFormatNopng, webp, pdf, jpg, jpeg, avif (Defaults to png).

Ready to automate?

Start rendering images, PDFs and videos from your templates in under 2 minutes. Free plan, no credit card.

Get your API key
  • Image, PDF and video generation via API
  • Visual editor with AI and smart layouts
  • Zapier, Make, MCP and 50+ integrations
  • White-label embed for your own app
  • 60 free renders — no credit card required