GenerateBanners.com • API documentation • Twitter
Automate image generation with ease.
Use the GenerateBanners.com visual editor to create your templates. Use this SDK to generate many image variations.
To install the GenerateBanners SDK with NPM, run:
npm i @generatebanners/node-sdk
If you want to install it with Yarn instead, run:
yarn add @generatebanners/node-sdk
Load the module via require:
constGenerateBanners=require('@generatebanners/node-sdk');Get your API key and secret on the account page. We recommand you use environment variables to keep your crendentials secure.
constclient=newGenerateBanners({apiKey: process.env.GB_API_KEY,apiSecret: process.env.GB_API_SECRET,});You would then run your file in the following way (if you have called your file index.js):
GB_API_KEY=p_123 GB_API_SECRET=s_123 node index.js
constGenerateBanners=require('@generatebanners/node-sdk');constclient=newGenerateBanners({apiKey: process.env.GB_API_KEY,apiSecret: process.env.GB_API_SECRET,});// Find TEMPLATE_ID by going to https://www.generatebanners.com/app then clicking on your templateconstimageUrl=client.image.signedUrl({templateId: "TEMPLATE_ID",variables: {title_text: "My title",},});constfs=require("fs").promises;constGenerateBanners=require('@generatebanners/node-sdk');asyncfunctionmain(){constclient=newGenerateBanners({apiKey: process.env.GB_API_KEY,apiSecret: process.env.GB_API_SECRET,});// Find TEMPLATE_ID by going to https://www.generatebanners.com/app then clicking on your templateconstimageUrl=client.image.signedUrl({templateId: "TEMPLATE_ID",variables: {title_text: "My title",},});constimg=awaitclient.utils.download(imageUrl);awaitfs.writeFile(`./generated-${Date.now()}.jpg`,img);}main();MIT
