npm install --save orshotyarn add orshotpnpm install orshotimport { Orshot } from "orshot";const orshot = new Orshot(<ORSHOT_API_KEY>);base64 response formatimport { 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 formatimport { 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 formatimport { 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.
Use this function to render an image/pdf. Render template takes in 4 options passed as an object
{
templateId,
modifications,
responseType,
responseFormat
}| key | required | description |
|---|---|---|
templateId | Yes | ID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...) |
modifications | Yes | Modifications for the selected template. |
responseType | No | base64, binary, url (Defaults to base64). |
responseFormat | No | png, webp, pdf, jpg, jpeg (Defaults to png). |
For available templates and their modifications refer Orshot Templates Page
Use this function to generate signed URLs
{
templateId,
modifications,
renderType,
responseFormat,
expiresAt
}| key | required | description |
|---|---|---|
templateId | Yes | ID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...) |
modifications | Yes | Modifications for the selected template. |
expiresAt | Yes | Expires at in unix timestamp (Number). |
renderType | No | images, pdfs (Defaults to images). |
responseFormat | No | png, webp, pdf, jpg, jpeg (Defaults to png). |
