cURL Examples

Learn how to interact with the MagicSlides API directly using cURL commands.

Recommended: Use the unified /api/ppt-from-text endpoint with API key authentication for all new integrations.

Unified API - Generate from Topic (Recommended)

curl -X POST https://api.magicslides.app/public/api/ppt-from-text \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "ms-api-your-api-key-here",
    "topic": "Introduction to Quantum Computing: Understanding quantum mechanics, qubits, superposition, and quantum algorithms.",
    "template": "bullet-point1",
    "slideCount": 10,
    "language": "en",
    "imageForEachSlide": true
  }'

Example Response:

{
  "status": "success",
  "message": "Presentation generated successfully",
  "inputType": "topic",
  "url": "https://storage.googleapis.com/magicslides-presentations/presentation-123.pptx",
  "pptId": "presentation-id",
  "pdfUrl": "https://storage.googleapis.com/magicslides-presentations/presentation-123.pdf",
  "tokenUsed": 1234
}

Unified API - Generate from YouTube

curl -X POST https://api.magicslides.app/public/api/ppt-from-text \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "ms-api-your-api-key-here",
    "youtubeURL": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "template": "bullet-point1",
    "slideCount": 15,
    "language": "en",
    "imageForEachSlide": true
  }'

Example Response:

{
  "status": "success",
  "message": "Presentation generated successfully",
  "inputType": "youtube",
  "url": "https://storage.googleapis.com/magicslides-presentations/presentation-789.pptx",
  "pptId": "presentation-id",
  "tokenUsed": 2345
}

Unified API - Generate from Website

curl -X POST https://api.magicslides.app/public/api/ppt-from-text \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "ms-api-your-api-key-here",
    "websiteURL": "https://www.wikipedia.org/wiki/Artificial_intelligence",
    "template": "custom1",
    "slideCount": 12,
    "language": "en",
    "presentationCategory": {
      "category": "Technology",
      "subCategory": "AI",
      "tone": "Professional"
    }
  }'

Error Responses

Authentication Error:

{
  "status": "failed",
  "message": "Invalid API key",
  "error": {
    "field": "apiKey",
    "message": "Invalid API key",
    "code": "AUTH_ERROR"
  }
}

Rate Limit Error:

{
  "status": "failed",
  "message": "Rate limit exceeded",
  "error": {
    "code": "RATE_LIMIT_ERROR",
    "message": "Rate limit exceeded",
    "details": {
      "limit": 10,
      "remaining": 0,
      "reset": "2024-03-21T15:00:00Z"
    }
  }
}

Invalid Parameters:

{
  "status": "failed",
  "message": "Invalid parameters provided",
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Invalid parameters provided",
    "details": {
      "slideCount": "Must be between 1 and 50"
    }
  }
}

Shell Script Example

#!/bin/bash

API_URL="https://api.magicslides.app/public/api"
API_KEY="ms-api-your-api-key-here"

generate_presentation() {
  local topic="${1}"
  local slide_count="${2:-10}"
  
  response=$(curl -s -X POST "${API_URL}/ppt-from-text" \
    -H "Content-Type: application/json" \
    -d "{
      \"apiKey\": \"${API_KEY}\",
      \"topic\": \"${topic}\",
      \"slideCount\": ${slide_count}
    }")
  
  # Check if the request was successful
  if echo "${response}" | grep -q '"status":"success"'; then
    url=$(echo "${response}" | grep -o '"url":"[^"]*"' | cut -d'"' -f4)
    echo "Presentation generated successfully: ${url}"
  else
    error=$(echo "${response}" | grep -o '"message":"[^"]*"' | cut -d'"' -f4)
    echo "Error generating presentation: ${error}"
    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