📚 API DOCUMENTATION! 🚀
Everything you need to integrate VisualizeAnything into your applications! ⚡
QUICK START ⚡
🎯 Base URL
http://localhost:3000/api
🚀 Basic Example
// Generate an awesome diagram!
const response = await fetch('http://localhost:3000/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Netflix streaming architecture with CDN and user devices',
format: 'png',
visualType: 'auto',
theme: 'vibrant'
})
});
const imageBlob = await response.blob();
// 💥 BAM! Your visual is ready!API ENDPOINTS 🎯
/api/generateGenerate Visual
Create amazing visuals from text descriptions!
📤 Request:
{
"text": "User authentication flow for web app",
"format": "gif",
"visualType": "flowchart",
"theme": "vibrant",
"background": "white",
"padding": 50,
"gifOptions": {
"frameDuration": 100,
"loop": true,
"frameRate": 10
}
}📥 Response:
// Returns binary image data // Headers: X-Generated-HTML: diagram_v1_1234567890.html X-Screenshot-File: diagram_v1_1234567890.png X-Base-Filename: diagram X-Version: 1
/api/editEdit Visual
Modify existing visuals with AI-powered editing!
📤 Request:
{
"htmlFileName": "diagram_v1_1234567890.html",
"editPrompt": "Make the boxes bigger and add more colors",
"format": "png"
}📥 Response:
// Returns updated binary image data // Headers: X-Generated-HTML: diagram_v2_1234567891.html X-Screenshot-File: diagram_v2_1234567891.png X-Version: 2
/api/upload-v2Upload File
Upload images, PDFs, CSVs, and more for enhanced visuals!
📤 Request:
// Form data with file
const formData = new FormData();
formData.append('file', file);
fetch('/api/upload-v2', {
method: 'POST',
body: formData
})📥 Response:
{
"url": "/uploads/file-1234567890.csv",
"content": "name,age,city\nJohn,25,NYC\nJane,30,LA"
}/api/filesList Files
Get all generated HTML files and screenshots!
📤 Request:
// No body required
📥 Response:
{
"html_files": [
"diagram_v1_1234567890.html",
"flowchart_v2_1234567891.html"
],
"screenshots": [
"diagram_v1_1234567890.png",
"flowchart_v2_1234567891.gif"
]
}/api/healthHealth Check
Check if the API is running and configured properly!
📤 Request:
// No body required
📥 Response:
{
"status": "healthy",
"timestamp": "2024-01-01T12:00:00.000Z",
"openai_configured": true
}PARAMETERS GUIDE 📋
Generate Request Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
| text | string | YES | Description of the visual you want to create | - |
| format | string | NO | Output format: "png", "jpg", "jpeg", or "gif" | png |
| visualType | string | NO | Type of visual: "auto", "flowchart", "timeline", "mindmap", "chart", "system", "infographic" | auto |
| theme | string | NO | Visual theme: "vibrant", "modern", "minimal", "dark" | vibrant |
| background | string | NO | Background style: "white", "transparent", "gradient" | white |
| padding | number | NO | Padding around the visual in pixels | 50 |
| quality | number | NO | Image quality (10-100) | 95 |
| uploadedFiles | array | NO | Array of uploaded file objects for context | - |
| gifOptions | object | NO | GIF-specific options (frameDuration, loop, frameRate, etc.) | - |
GIF Options
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
| frameDuration | number | NO | Duration between frames in milliseconds | 100 |
| totalDuration | number | NO | Total GIF duration in milliseconds | 3000 |
| frameRate | number | NO | Frames per second | 10 |
| loop | boolean | NO | Whether to loop the GIF | true |
| detectAnimations | boolean | NO | Auto-detect and enhance animations | true |
CODE EXAMPLES 💻
🐍 Python
import requests
def generate_diagram(text, format='png'):
response = requests.post('http://localhost:3000/api/generate',
json={
'text': text,
'format': format,
'visualType': 'auto',
'theme': 'vibrant'
})
if response.status_code == 200:
return response.content
else:
raise Exception(f"Error: {response.status_code}")
# Usage
diagram_data = generate_diagram("Database schema for e-commerce app")
with open('schema.png', 'wb') as f:
f.write(diagram_data)🚀 Node.js
const fs = require('fs');
async function generateDiagram(text, format = 'png') {
try {
const response = await fetch('http://localhost:3000/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: text,
format: format,
visualType: 'auto',
theme: 'vibrant',
gifOptions: format === 'gif' ? { loop: true, frameRate: 10 } : undefined
}),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const buffer = await response.arrayBuffer();
return Buffer.from(buffer);
} catch (error) {
console.error('Error generating diagram:', error);
throw error;
}
}
// Usage
generateDiagram('Microservices architecture diagram', 'gif')
.then(buffer => {
fs.writeFileSync('architecture.gif', buffer);
console.log('✅ Diagram saved!');
})
.catch(console.error);🌐 React/Next.js
import { useState } from 'react';
function DiagramGenerator() {
const [loading, setLoading] = useState(false);
const [imageUrl, setImageUrl] = useState(null);
const generateDiagram = async (text) => {
setLoading(true);
try {
const response = await fetch('/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: text,
format: 'png',
visualType: 'auto',
theme: 'vibrant'
}),
});
if (!response.ok) throw new Error('Generation failed');
const blob = await response.blob();
const url = URL.createObjectURL(blob);
setImageUrl(url);
} catch (error) {
console.error('Error:', error);
} finally {
setLoading(false);
}
};
return (
<div>
<button
onClick={() => generateDiagram('User onboarding flow')}
disabled={loading}
>
{loading ? 'Generating...' : 'Generate Diagram'}
</button>
{imageUrl && <img src={imageUrl} alt="Generated diagram" />}
</div>
);
}🚨 ERROR HANDLING
Common Error Codes
- 400 Bad Request: Missing or invalid parameters
- 404 Not Found: File or endpoint not found
- 500 Internal Server Error: AI generation or screenshot failed
- 413 Payload Too Large: File upload too big (max 10MB)
// Always handle errors gracefully
try {
const response = await fetch('/api/generate', { /* ... */ });
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || 'Generation failed');
}
const imageBlob = await response.blob();
// Success! 🎉
} catch (error) {
console.error('Generation error:', error.message);
// Show user-friendly error message
}WATERMARKS ⚡
Generated images include watermarks based on your subscription plan! 🎨
🆓 Free Plan
All generated images include the "⚡ VisualizeAnything" watermark in the bottom-right corner.
💎 Paid Plans
Pro, Business, and Enterprise plans generate clean images without any watermarks.
💡 API Behavior: The watermark is automatically applied during image generation based on your account's subscription status. No additional parameters needed!
SUPPORT & FEEDBACK 💖
Having issues? Want to contribute? We're here to help! 🤗