GitHub Social Preview template
The github-social-preview template renders a developer image as a PNG. POST a JSON payload to the endpoint below and you receive a CDN URL in the response.
Endpoint
POST https://html2img.com/api/v1/templates/github-social-preview
X-API-Key: <your-api-key>
Content-Type: application/json
Authentication uses the X-API-Key header. See the
authentication docs
for details on issuing and rotating keys.
Inputs
The full set of inputs the template accepts:
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
repo_name | string | Yes | Text value for the repo name. | acme/feather |
description | string | No | Text value for the description. | A 12kb React state management library that fits in your head. |
language | string | No | Text value for the language. | TypeScript |
language_color | string | No | Hex colour code for the language. | #3178C6 |
stars | string | No | Text value for the stars. | 12.4k |
forks | string | No | Text value for the forks. | 482 |
owner_name | string | No | Text value for the owner name. | Acme |
owner_avatar_url | url | No | URL of the owner avatar to include in the rendered image. | https://i.pravatar.cc/160?img=8 |
background_color | string | No | Hex colour code for the background. | #0D1117 |
accent_color | string | No | Hex colour code for the accent. | #58A6FF |
Defaults
Defaults applied automatically when not overridden in the request:
| Option | Default value |
|---|---|
width | 1280 |
height | 640 |
Code examples
curl -X POST https://app.html2img.com/api/v1/templates/github-social-preview \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"repo_name":"acme/feather","description":"A 12kb React state management library that fits in your head.","language":"TypeScript","language_color":"#3178C6","stars":"12.4k","forks":"482","owner_name":"Acme","owner_avatar_url":"https://i.pravatar.cc/160?img=8","background_color":"#0D1117","accent_color":"#58A6FF"}' <?php
$response = \Illuminate\Support\Facades\Http::withHeaders([
'X-API-Key' => 'YOUR_API_KEY',
])->post('https://app.html2img.com/api/v1/templates/github-social-preview', ['repo_name' => 'acme/feather', 'description' => 'A 12kb React state management library that fits in your head.', 'language' => 'TypeScript', 'language_color' => '#3178C6', 'stars' => '12.4k', 'forks' => '482', 'owner_name' => 'Acme', 'owner_avatar_url' => 'https://i.pravatar.cc/160?img=8', 'background_color' => '#0D1117', 'accent_color' => '#58A6FF']);
$url = $response->json('url'); const response = await fetch('https://app.html2img.com/api/v1/templates/github-social-preview', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"repo_name": "acme/feather",
"description": "A 12kb React state management library that fits in your head.",
"language": "TypeScript",
"language_color": "#3178C6",
"stars": "12.4k",
"forks": "482",
"owner_name": "Acme",
"owner_avatar_url": "https://i.pravatar.cc/160?img=8",
"background_color": "#0D1117",
"accent_color": "#58A6FF"
}),
});
const { url } = await response.json(); import requests
response = requests.post(
'https://app.html2img.com/api/v1/templates/github-social-preview',
headers={'X-API-Key': 'YOUR_API_KEY'},
json={'repo_name': 'acme/feather', 'description': 'A 12kb React state management library that fits in your head.', 'language': 'TypeScript', 'language_color': '#3178C6', 'stars': '12.4k', 'forks': '482', 'owner_name': 'Acme', 'owner_avatar_url': 'https://i.pravatar.cc/160?img=8', 'background_color': '#0D1117', 'accent_color': '#58A6FF'},
)
url = response.json()['url'] Looking for a fuller integration sketch in your language? The usage guides cover PHP, Laravel, Rails, Python, JavaScript, React and Vue.
Response
A successful render returns:
{
"success": true,
"id": "abc123",
"url": "https://i.html2img.com/abc123.png",
"credits_remaining": 1234,
"template": "github-social-preview"
}
The url field is a CDN URL for the rendered PNG. credits_remaining tracks your monthly quota. Shared response fields are documented in the
API parameters reference.
Errors
The template endpoint returns the following error responses:
422 Validation failed
Returned when one or more inputs fail validation. The errors object lists field-specific messages.
{
"success": false,
"error": "validation_failed",
"errors": {
"title": ["The title field is required."]
}
} 404 Template not found
Returned with {"code": "template_not_found"} if the slug is not registered. Check the template list for current slugs.
401 Unauthorised
Missing or invalid API key. See the authentication docs.
429 Too many requests
You have hit the rate limit or used your monthly credits. The pricing page covers higher-volume plans.
Related templates
- Project Showcase — "We shipped X" hero cards for changelogs and launch announcements
- Code Screenshot — Beautiful syntax-highlighted code screenshots with window chrome
See the GitHub Social Preview template in our gallery for sample renders and use cases.