Snapshark API
Generate dynamic images from your templates using simple HTTP requests. Each template has a unique ID that you use to generate images with custom text and images.
Base URL
https://snapshark.io/api/v1How It Works
Every template you create in the editor gets a unique UUID. Use this ID to generate images via the API with your custom data.
a1b2c3d4-e5f6-7890-abcd-ef1234567890Error Handling
All API responses follow a consistent format. Errors include a descriptive message.
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 404 | Not Found - Template doesn't exist |
| 500 | Server Error |
{
"status": false,
"type": "error",
"title": "Not Found",
"message": "Template not found",
"http_code": 404
}Simple URL
Generate images using a simple GET request. Pass template variables as query parameters. Perfect for embedding directly in HTML or sharing links.
GET https://snapshark.io/api/v1/images/:templateIdQuery Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| :templateId | UUID | required | Your template ID (in URL path) |
| title | string | optional | Any text variable name from your template |
| image.src | URL | optional | Any image variable with .src suffix |
| output | string | optional | "json" (default) or "image" for binary |
Examples
https://snapshark.io/api/v1/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890?title=Hello&subtitle=Worldhttps://snapshark.io/api/v1/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890?title=Hello&output=imageHTML Embed
<!-- Embed generated image directly in HTML -->
<img src="https://snapshark.io/api/v1/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890?title=My%20Title&output=image" alt="Generated" />
<!-- Dynamic OG Image for social sharing -->
<meta property="og:image" content="https://snapshark.io/api/v1/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890?title=Article%20Title&output=image" />JSON Response
{
"status": true,
"type": "success",
"title": "OK",
"message": "Image generated successfully",
"http_code": 200,
"href": ".../generated/2024/01/abc123.png",
"data": {
"id": "abc123-uuid",
"image_url": ".../generated/2024/01/abc123.png",
"width": 1200,
"height": 630,
"format": "png",
"file_size": 125000,
"render_time_ms": 450,
"created_at": "2024-01-15T10:30:00.000Z"
}
}API Request
Generate images with a POST request. Ideal for server-side integration and complex variable data.
POST https://snapshark.io/api/v1/imagesRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| template | UUID | required | Your template ID |
| data | array | required | Array of variable modifications |
| output | string | optional | "json" (default) or "image" for binary |
Data Array Format
Each item in the data array specifies a variable to modify:
{
"template": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"data": [
{ "name": "title", "text": "Hello World" },
{ "name": "subtitle", "text": "Welcome to Snapshark" },
{ "name": "avatar", "src": "https://example.com/photo.jpg" },
{ "name": "background", "color": "#FF5733" }
],
"output": "json"
}cURL Example
curl -X POST 'https://snapshark.io/api/v1/images' \
-H 'Content-Type: application/json' \
-d '{
"template": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"data": [
{ "name": "title", "text": "Hello World" },
{ "name": "subtitle", "text": "Generated via API" }
],
"output": "json"
}'Node.js Example
const response = await fetch('https://snapshark.io/api/v1/images', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
template: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
data: [
{ name: 'title', text: 'Hello World' },
{ name: 'avatar', src: 'https://example.com/photo.jpg' }
],
output: 'json'
})
});
const result = await response.json();
console.log(result.href); // Image URLDownload Image Directly
curl -X POST 'https://snapshark.io/api/v1/images' \
-H 'Content-Type: application/json' \
-d '{
"template": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"data": [{ "name": "title", "text": "Hello" }],
"output": "image"
}' \
--output generated-image.pngTemplate Variables
Variables are based on layer names in your template. Each editable layer becomes an API variable.
Variable Types
For text layers. Use text property in POST, or pass value directly in GET query.
?title=Hello%20World{ "name": "title", "text": "Hello World" }For image layers. Provide an image URL to replace the placeholder.
?avatar.src=https://example.com/photo.jpg{ "name": "avatar", "src": "https://..." }For shape fill colors. Provide a hex color code.
?background.fill=%23FF5733{ "name": "background", "color": "#FF5733" }Output Options
Control the API response format using the output parameter.
| Value | Response | Use Case |
|---|---|---|
| json | JSON with image URL and metadata | API integrations, store URL |
| image | Binary image data (PNG/JPG) | Direct embed, download |
Output Formats
Images are generated in PNG format by default. JPG is also supported for templates configured with JPG export.
Need help? Contact us at support@snapshark.io
View Pricing →