imgrender

Quick start

Design a template in the template editor, then call the API with variables to generate an image

Introduction

imgrender is a high-performance image generation service that lets your application generate images quickly. Use it for posters, certificates, product covers, blog covers, personalized ads, and more.

Recommended workflow: design a template in HTML and define variables in the template editor, publish it, then call the Generate image from template API. Pass in the variable values to generate an image.

Core features

The template is the image

Design a template in HTML and define variables in the template editor. When your application calls the API, pass the template ID and variable values to render a high-quality image (WebP, PNG, or JPEG). Inline styles and Tailwind CSS classes are supported, so front-end developers can get started right away.

FeatureDescription
Reusable templatesDesign a template once. Your application only sends variables, not a full HTML document each time
Simple to usePass a template ID and variables and get an image URL back. No rendering service to run
High performanceServer-side rendering with responses in milliseconds, without browser runtime overhead
Flexible outputOverride size, format, and quality per request. Templates can use variables, conditions, and loops
Rich stylingTemplates support inline styles and Tailwind CSS classes for complex layouts

Get started

Start using imgrender in 3 steps:

1. Sign up and get an API key

Go to the imgrender dashboard, create an account, and sign in.

After you sign in, open the API Keys page and click "Create API key" to generate an API key. The format is number.random-string.

Security note

An API key authenticates calls to the service. Keep it private. Do not commit it to a public repository or share it with anyone else.

2. Create and publish a template

Open the template editor, write the template in HTML, and parameterize anything that should change with {$ name $}. Save and publish it, then copy the template ID from the template details page in the dashboard.

For how to write templates and use variables, see the template guide and Variables.

Publish first

The live API uses published content by default. If the template is unpublished or archived, the call returns 409. To debug a draft, set useDraft: true on the request.

3. Call the API

Replace YOUR_API_KEY and {template_id} in the example below with your API key and template ID to generate an image:

const response = await fetch(
  'https://api.imgrender.net/open/v1/images/templates/{template_id}/render',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': 'YOUR_API_KEY',
    },
    body: JSON.stringify({
      variables: {
        title: 'Hello imgrender!',
      },
      format: 'png',
    }),
  },
)

const result = await response.json()
console.log('Image URL:', result.data.url)
curl -X POST 'https://api.imgrender.net/open/v1/images/templates/:template_id/render' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{
    "variables": {
      "title": "Hello imgrender!"
    },
    "format": "png"
  }'

A successful response looks like this:

{
  "code": 0,
  "message": "ok",
  "data": {
    "url": "https://res.imgrender.net/xxx.jpg?sign=xxx"
  }
}

Image URL lifetime

The returned image URL is valid for 5 minutes. Download or display the image promptly. After it expires, send the request again to get a new URL.

Other ways to call the API

To send the full HTML on every request without saving a template, use the Generate image from HTML API. In production, the template-based API is the better fit.


Next steps

On this page