Skip to main content

OG Image Generation

The core endpoint for generating Open Graph images.

POST /og/generate

Generate an OG image from a template.

Request

curl -X POST https://ssiat.dev/api/v1/og/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "blog",
"data": {
"title": "My Amazing Blog Post",
"description": "A deep dive into something interesting",
"author": "Jane Doe"
},
"options": {
"format": "png",
"width": 1200,
"height": 630
}
}'

Request Body

FieldTypeRequiredDescription
templatestringYesTemplate name
dataobjectYesTemplate-specific data
optionsobjectNoOutput options

Template Options

Blog Template

{
"template": "blog",
"data": {
"title": "string (required)",
"description": "string",
"author": "string",
"date": "string",
"readTime": "string",
"category": "string"
}
}

Product Template

{
"template": "product",
"data": {
"name": "string (required)",
"tagline": "string",
"price": "string",
"badge": "string",
"image": "string (URL)"
}
}

Event Template

{
"template": "event",
"data": {
"title": "string (required)",
"date": "string (required)",
"time": "string",
"location": "string",
"host": "string"
}
}

Output Options

OptionTypeDefaultDescription
widthinteger1200Image width (200-2048)
heightinteger630Image height (200-2048)
formatstring"png"png, jpeg, webp
qualityinteger901-100, for jpeg/webp
cachebooleantrueEnable caching

Response

{
"success": true,
"data": {
"url": "https://ssiat.dev/og/abc123.png",
"width": 1200,
"height": 630,
"format": "png",
"size": 45678,
"expiresAt": "2024-01-16T00:00:00Z"
}
}

Response Fields

FieldTypeDescription
urlstringDirect URL to the image
widthintegerActual image width
heightintegerActual image height
formatstringImage format
sizeintegerFile size in bytes
expiresAtstringCache expiration (ISO 8601)

GET /og/templates

List all available templates.

Request

curl https://ssiat.dev/api/v1/og/templates \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"success": true,
"data": {
"templates": [
{
"id": "blog",
"name": "Blog Post",
"description": "Perfect for articles and blog posts",
"fields": ["title", "description", "author", "date"]
},
{
"id": "product",
"name": "Product",
"description": "Showcase products",
"fields": ["name", "tagline", "price", "image"]
}
]
}
}