API to Generate Preview Images from JSON

Send JSON data, receive a professionally designed PNG image. The simplest way to generate social share images programmatically.

Start Free → API Docs

How It Works

Our REST API accepts JSON input and returns a PNG image. It's that simple.

POST https://ogimageapi.io/api/generate

Request

POST /api/generate
Content-Type: application/json
X-API-Key: your_api_key

{
  "title": "Your Image Title",
  "subtitle": "Optional subtitle text",
  "theme": "dark",
  "template": "default"
}

Response

Content-Type: image/png
Content-Length: 42568

[PNG binary data]

JSON Schema

Full specification of accepted parameters:

{
  // Required
  "title": string,        // Main text (max 100 chars)
  
  // Optional
  "subtitle": string,     // Secondary text (max 200 chars)
  "theme": "dark" | "light",  // Color scheme
  "template": string,     // Template ID (default, vibrant, etc.)
  "author_name": string,  // Author display name
  "author_avatar": string // URL to avatar image
}

Language Examples

cURL

curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key" \
  -d '{"title": "Hello World", "theme": "dark"}' \
  --output image.png

JavaScript / Node.js

const response = await fetch('https://ogimageapi.io/api/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key'
  },
  body: JSON.stringify({
    title: 'Hello World',
    subtitle: 'Generated via API',
    theme: 'dark'
  })
});

const imageBuffer = await response.arrayBuffer();

Python

import requests

response = requests.post(
    'https://ogimageapi.io/api/generate',
    json={
        'title': 'Hello World',
        'subtitle': 'Generated via API',
        'theme': 'dark'
    },
    headers={
        'X-API-Key': 'your_api_key'
    }
)

with open('image.png', 'wb') as f:
    f.write(response.content)

PHP

$response = file_get_contents('https://ogimageapi.io/api/generate', false, stream_context_create([
    'http' => [
        'method' => 'POST',
        'header' => "Content-Type: application/json\r\nX-API-Key: your_api_key",
        'content' => json_encode([
            'title' => 'Hello World',
            'theme' => 'dark'
        ])
    ]
]));

file_put_contents('image.png', $response);

Response Codes

Image Output

Start Generating Images from JSON

Get your API key and start making requests in minutes.

Get Your API Key →

Related Resources