Skip to content

Generate a SWOT Slide

This guide demonstrates how to use the SlideSpeak API’s slide-by-slide endpoint to generate a single SWOT analysis slide. We’ll walk through the process step by step, including the required request body and example code.

Tip: For more about the SWOT layout, see the Layouts documentation.

A SWOT slide requires exactly 4 items: Strengths, Weaknesses, Opportunities, and Threats. Below is an example request body for a SWOT slide analyzing an electric vehicle (EV) startup:

{
"template": "default",
"language": "ENGLISH",
"include_cover": false,
"include_table_of_contents": false,
"slides": [
{
"title": "SWOT Analysis: EV Startup",
"layout": "swot",
"item_amount": 4,
"content": "Strengths: Compact and affordable EVs tailored for city driving, strong focus on sustainability and low maintenance; Weaknesses: Limited charging infrastructure in key markets, lower brand recognition compared to established automakers; Opportunities: Growing global demand for clean transportation, government incentives for EV adoption, potential for ride-sharing partnerships; Threats: Rapid technological advancements by major EV competitors, fluctuating battery supply chain costs, evolving environmental regulations"
}
]
}

Send a POST request to the /presentation/generate/slide-by-slide endpoint. Below is a JavaScript example using fetch:

const API_KEY = 'your-api-key';
const API_BASE = 'https://api.slidespeak.co/api/v1';
async function generateSwotSlide() {
const response = await fetch(`${API_BASE}/presentation/generate/slide-by-slide`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
template: 'default',
language: 'ENGLISH',
include_cover: false, // We don't want a cover slide
include_table_of_contents: false, // We don't want a table of contents
slides: [
{
title: 'SWOT Analysis: EV Startup',
layout: 'swot',
item_amount: 4,
content: "Strengths: Compact and affordable EVs tailored for city driving, strong focus on sustainability and low maintenance; Weaknesses: Limited charging infrastructure in key markets, lower brand recognition compared to established automakers; Opportunities: Growing global demand for clean transportation, government incentives for EV adoption, potential for ride-sharing partnerships; Threats: Rapid technological advancements by major EV competitors, fluctuating battery supply chain costs, evolving environmental regulations"
}
]
})
});
const result = await response.json();
return result;
}
{
"task_id": "353509d6-8efe-401c-a8a9-53ca64b520a3"
}

Use the returned task_id to poll the task status until it is SUCCESS.

async function pollTask(taskId) {
const response = await fetch(`${API_BASE}/task_status/${taskId}`, {
headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }
});
const result = await response.json();
if (result.task_status === 'SUCCESS') {
return result;
} else if (result.task_status === 'FAILED') {
throw new Error('Task failed');
}
await new Promise(res => setTimeout(res, 2000)); // Wait 2 seconds
return pollTask(taskId); // Recursive call
}
{
"task_id": "353509d6-8efe-401c-a8a9-53ca64b520a3",
"task_status": "SUCCESS",
"task_result": {
"url": "https://slidespeak-files.s3.us-east-2.amazonaws.com/24d89111-71a1-4c05-a909-2d84123c9ba9.pptx"
},
"task_info": {
"url": "https://slidespeak-files.s3.us-east-2.amazonaws.com/24d89111-71a1-4c05-a909-2d84123c9ba9.pptx"
}
}

Once the task is successful, download your SWOT slide using the provided URL.

async function downloadPresentation(downloadUrl, filename = 'swot-slide.pptx') {
const response = await fetch(downloadUrl);
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}

SWOT Analysis

  • The swot layout requires exactly 4 items: Strengths, Weaknesses, Opportunities, and Threats.
  • All API requests require your X-API-Key header.

For more details, see the API Reference and Layouts.