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 (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 (Defaults to png).

All Set? Let's Start Automating

Get Your API Key →
  • Image, PDF and Video Generation via API
  • Canva like editor with AI and smart features
  • No-Code Integrations (Zapier, Make, n8n etc.)
  • Embed Orshot Studio in your app
  • Start Free. No credit card required. Cancel anytime.