Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@generatebanners/node-sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@generatebanners/node-sdk

GenerateBanners SDK for JavaScript.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

GenerateBanners logo

GenerateBanners.comAPI documentationTwitter

Automate image generation with ease.

Use the GenerateBanners.com visual editor to create your templates. Use this SDK to generate many image variations.

Table of contents

  1. Installation
  2. Loading and configuring the module
  3. Common usage
    1. Create an image url from a template
    2. Generate an image and download it

Installation

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

Loading and configuring the module

Load the module via require:

const GenerateBanners = 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.

const client = new GenerateBanners({
    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

Common usage

Create an image url from a template

const GenerateBanners = require('@generatebanners/node-sdk');

const client = new GenerateBanners({
    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 template
const imageUrl = client.image.signedUrl({
  templateId: "TEMPLATE_ID",
  variables: {
    title_text: "My title",
  },
});

Generate an image and download it

const fs = require("fs").promises;
const GenerateBanners = require('@generatebanners/node-sdk');

async function main() {
    const client = new GenerateBanners({
        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 template
    const imageUrl = client.image.signedUrl({
      templateId: "TEMPLATE_ID",
      variables: {
        title_text: "My title",
      },
    });
    
    const img = await client.utils.download(imageUrl);
    await fs.writeFile(`./generated-${Date.now()}.jpg`, img);
}

main();

Keywords

FAQs

Package last updated on 21 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc