cURL Examples
Learn how to interact with the MagicSlides API directly using cURL commands.
Generate from Topic
curl -X POST https://magicslides-tools-api.onrender.com/public/api/ppt_from_topic \
-H "Content-Type: application/json" \
-d '{
"topic": "Artificial Intelligence in Healthcare",
"extraInfoSource": "Focus on recent developments",
"email": "your-email@example.com",
"accessId": "your-access-id",
"slideCount": 12
}'
Example Response:
{
"success": true,
"url": "https://storage.googleapis.com/magicslides-presentations/presentation-123.pptx",
"message": "Presentation generated successfully",
"metadata": {
"slideCount": 12,
"generatedAt": "2024-03-21T14:30:00Z",
"fileSize": 2048576
}
}
Generate from Summary
curl -X POST https://magicslides-tools-api.onrender.com/public/api/ppt_from_summery \
-H "Content-Type: application/json" \
-d '{
"msSummaryText": "Your detailed summary text here...",
"email": "your-email@example.com",
"accessId": "your-access-id",
"slideCount": 8
}'
Example Response:
{
"success": true,
"url": "https://storage.googleapis.com/magicslides-presentations/presentation-456.pptx",
"message": "Presentation generated successfully",
"metadata": {
"slideCount": 8,
"generatedAt": "2024-03-21T14:35:00Z",
"fileSize": 1572864
}
}
Generate from YouTube
curl -X POST https://magicslides-tools-api.onrender.com/public/api/ppt_from_youtube \
-H "Content-Type: application/json" \
-d '{
"youtubeURL": "https://www.youtube.com/watch?v=example",
"email": "your-email@example.com",
"accessId": "your-access-id",
"slideCount": 15
}'
Example Response:
{
"success": true,
"url": "https://storage.googleapis.com/magicslides-presentations/presentation-789.pptx",
"message": "Presentation generated successfully",
"metadata": {
"slideCount": 15,
"generatedAt": "2024-03-21T14:40:00Z",
"fileSize": 3145728
}
}
Error Responses
Authentication Error:
{
"success": false,
"error": "Invalid access ID provided",
"code": "AUTH_ERROR"
}
Rate Limit Error:
{
"success": false,
"error": "Rate limit exceeded",
"code": "RATE_LIMIT_ERROR",
"details": {
"limit": 10,
"remaining": 0,
"reset": "2024-03-21T15:00:00Z"
}
}
Invalid Parameters:
{
"success": false,
"error": "Invalid parameters provided",
"code": "INVALID_PARAMS",
"details": {
"slideCount": "Must be between 1 and 50"
}
}
Shell Script Example
#!/bin/bash
API_URL="https://magicslides-tools-api.onrender.com/public/api"
ACCESS_ID="your-access-id"
EMAIL="your-email@example.com"
generate_presentation() {
local topic="${1}"
local slide_count="${2:-10}"
response=$(curl -s -X POST "${API_URL}/ppt_from_topic" \
-H "Content-Type: application/json" \
-d "{
\"topic\": \"${topic}\",
\"email\": \"${EMAIL}\",
\"accessId\": \"${ACCESS_ID}\",
\"slideCount\": ${slide_count}
}")
# Check if the request was successful
if echo "${response}" | grep -q '"success":true'; then
url=$(echo "${response}" | grep -o '"url":"[^"]*"' | cut -d'"' -f4)
echo "Presentation generated successfully: ${url}"
else
error=$(echo "${response}" | grep -o '"error":"[^"]*"' | cut -d'"' -f4)
code=$(echo "${response}" | grep -o '"code":"[^"]*"' | cut -d'"' -f4)
echo "Error generating presentation: ${error} (Code: ${code})"
exit 1
fi
}
Tips and Best Practices
- Always include proper headers, especially Content-Type: application/json
- Handle rate limits by checking response headers
- Implement exponential backoff for retries
- Store your access ID securely
- Validate input parameters before sending requests
Testing with Different HTTP Methods
# GET request (not supported)
curl -X GET "$API_URL/ppt_from_topic"
# HEAD request for checking endpoint availability
curl -I -X HEAD "$API_URL/ppt_from_topic"
# OPTIONS request for allowed methods
curl -X OPTIONS "$API_URL/ppt_from_topic" -i