Response Format
The MagicSlides API returns responses in a consistent JSON format across all endpoints. This guide explains the structure and fields in our API responses.
Success Response
When a request is successful, the API returns a JSON object with the following structure:
{
"success": true,
"url": "https://storage.magicslides.com/presentations/abc123.pptx",
"message": "Presentation generated successfully",
"metadata": {
"slideCount": 10,
"generatedAt": "2024-03-15T10:30:00Z",
"fileSize": 2048576
}
}
Response Fields
Field
Type
Description
success
boolean
Always true for successful responses
url
string
URL to download the generated presentation
message
string
Human-readable success message
metadata
object
Additional information about the generated presentation
Metadata Fields
Field
Type
Description
slideCount
number
Number of slides in the presentation
generatedAt
string
ISO 8601 timestamp of generation
fileSize
number
Size of the presentation in bytes
Response Examples
Topic to PPT Response
{
"success": true,
"url": "https://storage.magicslides.com/presentations/topic-123.pptx",
"message": "Presentation generated from topic successfully",
"metadata": {
"slideCount": 12,
"generatedAt": "2024-03-15T10:30:00Z",
"fileSize": 1548576,
"topic": "Artificial Intelligence in Healthcare"
}
}
Summary to PPT Response
{
"success": true,
"url": "https://storage.magicslides.com/presentations/summary-456.pptx",
"message": "Presentation generated from summary successfully",
"metadata": {
"slideCount": 8,
"generatedAt": "2024-03-15T11:45:00Z",
"fileSize": 1024576,
"summaryLength": 2500
}
}
YouTube to PPT Response
{
"success": true,
"url": "https://storage.magicslides.com/presentations/youtube-789.pptx",
"message": "Presentation generated from YouTube video successfully",
"metadata": {
"slideCount": 15,
"generatedAt": "2024-03-15T12:15:00Z",
"fileSize": 2097152,
"videoTitle": "Introduction to Machine Learning",
"videoDuration": "15:30"
}
}
Working with Responses
import axios from 'axios';
interface PresentationMetadata {
slideCount: number;
generatedAt: string;
fileSize: number;
[key: string]: any;
}
interface ApiResponse {
success: true;
url: string;
message: string;
metadata: PresentationMetadata;
}
async function generatePresentation() {
try {
const response = await axios.post<ApiResponse>(
'https://magicslides-tools-api.onrender.com/public/api/ppt_from_topic',
{
topic: 'Machine Learning Basics',
email: 'user@example.com',
accessId: 'your-access-id'
}
);
const { url, metadata } = response.data;
console.log(`Presentation generated with ${metadata.slideCount} slides`);
console.log(`Download URL: ${url}`);
console.log(`Generated at: ${new Date(metadata.generatedAt).toLocaleString()}`);
console.log(`File size: ${(metadata.fileSize / 1024 / 1024).toFixed(2)} MB`);
return response.data;
} catch (error) {
console.error('Error generating presentation:', error);
throw error;
}
}
Response Headers
In addition to the JSON response body, the API includes useful information in response headers:
Content-Type
Always application/json
X-Request-ID
Unique identifier for the request (useful for support)
X-Processing-Time
Time taken to process the request in milliseconds