Getting Started
This guide will walk you through making your first API call to Shorts Planner. We'll cover how to upload a video using cURL, JavaScript (fetch), and Python (requests).
Prerequisites
Before you begin, you'll need:
- An active Shorts Planner account.
- An API key. You can generate one from your dashboard.
- A video file to upload.
Uploading a Video
Here are examples of how to upload a video to the /upload/video endpoint. Remember to replace YOUR_API_KEY with your actual API key.
cURL
This example uses curl to upload a video from your local machine.
curl -X POST "https://api.shortsplanner.com/upload/video" \
-H "x-api-key: YOUR_API_KEY" \
-F "title=My First Video" \
-F "video=@/path/to/your/video.mp4"
JavaScript (Fetch API)
This example uses the fetch API in a browser or Node.js environment to upload a video.
const apiKey = 'YOUR_API_KEY';
const videoFile = document.querySelector('input[type="file"]').files[0]; // Or get the file from another source
const formData = new FormData();
formData.append('title', 'My First Video');
formData.append('video', videoFile);
fetch('https://api.shortsplanner.com/upload/video', {
method: 'POST',
headers: {
'x-api-key': apiKey,
},
body: formData,
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));
Python (requests)
This example uses the popular requests library in Python to upload a video.
import requests
api_key = 'YOUR_API_KEY'
video_path = '/path/to/your/video.mp4'
url = 'https://api.shortsplanner.com/upload/video'
headers = {
'x-api-key': api_key
}
files = {
'video': open(video_path, 'rb')
}
data = {
'title': 'My First Video'
}
response = requests.post(url, headers=headers, files=files, data=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.status_code, response.text)