Ssemble API

Examples

Complete code examples for common API workflows in JavaScript and Python.

JavaScript (Node.js)

Full workflow — Create short and download result

const API_KEY = 'sk_ssemble_your_key';
const BASE_URL = 'https://aiclipping.ssemble.com/api/v1';
 
async function createAndDownloadShort(youtubeUrl) {
  // Step 1: Create a short
  const createRes = await fetch(`${BASE_URL}/shorts/create`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': API_KEY,
    },
    body: JSON.stringify({
      url: youtubeUrl,
      start: 0,
      end: 600,
      preferredLength: 'under60sec',
      language: 'en',
      music: true,
      musicVolume: 10,
      layout: 'auto',
    }),
  });
 
  const { data: createData } = await createRes.json();
  const requestId = createData.requestId;
  console.log(`Request created: ${requestId}`);
 
  // Step 2: Poll for completion
  let status = 'processing';
  while (status !== 'completed' && status !== 'failed') {
    await new Promise((r) => setTimeout(r, 10000)); // Wait 10s
 
    const statusRes = await fetch(`${BASE_URL}/shorts/${requestId}/status`, {
      headers: { 'X-API-Key': API_KEY },
    });
    const { data: statusData } = await statusRes.json();
    status = statusData.status;
    console.log(`Status: ${status} (${statusData.progress}%)`);
  }
 
  if (status === 'failed') {
    throw new Error('Processing failed');
  }
 
  // Step 3: Get the generated shorts
  const shortsRes = await fetch(`${BASE_URL}/shorts/${requestId}`, {
    headers: { 'X-API-Key': API_KEY },
  });
  const { data: shortsData } = await shortsRes.json();
 
  console.log(`Generated ${shortsData.shorts.length} shorts:`);
  for (const short of shortsData.shorts) {
    console.log(`  - "${short.title}" (${short.duration}s, score: ${short.viral_score})`);
    console.log(`    URL: ${short.video_url}`);
  }
 
  return shortsData.shorts;
}
 
createAndDownloadShort('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

Browse and select specific music

async function createShortWithSpecificMusic(youtubeUrl) {
  // List available music
  const musicRes = await fetch(`${BASE_URL}/music?limit=50`, {
    headers: { 'X-API-Key': API_KEY },
  });
  const { data: musicData } = await musicRes.json();
 
  // Pick a track
  const track = musicData.music[0];
  console.log(`Using music: ${track.name} (${track.duration}s)`);
 
  // Create short with specific music
  const createRes = await fetch(`${BASE_URL}/shorts/create`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': API_KEY,
    },
    body: JSON.stringify({
      url: youtubeUrl,
      start: 0,
      end: 600,
      music: true,
      musicName: track.name,
      musicVolume: 20,
    }),
  });
 
  return await createRes.json();
}

Create short with game video overlay

async function createShortWithGameplay(youtubeUrl) {
  // List game videos
  const gamesRes = await fetch(`${BASE_URL}/game-videos?limit=50`, {
    headers: { 'X-API-Key': API_KEY },
  });
  const { data } = await gamesRes.json();
 
  // Pick "Minecraft Parkour" or first available
  const game = data.gameVideos.find(g => g.name.includes('Minecraft'))
    || data.gameVideos[0];
 
  const createRes = await fetch(`${BASE_URL}/shorts/create`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': API_KEY,
    },
    body: JSON.stringify({
      url: youtubeUrl,
      start: 0,
      end: 600,
      gameVideo: true,
      gameVideoName: game.name,
      layout: 'fill',
    }),
  });
 
  return await createRes.json();
}

Python

Full workflow

import requests
import time
 
API_KEY = "sk_ssemble_your_key"
BASE_URL = "https://aiclipping.ssemble.com/api/v1"
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
 
 
def create_and_download_short(youtube_url: str):
    # Step 1: Create a short
    create_res = requests.post(
        f"{BASE_URL}/shorts/create",
        headers=HEADERS,
        json={
            "url": youtube_url,
            "start": 0,
            "end": 600,
            "preferredLength": "under60sec",
            "language": "en",
            "music": True,
            "musicVolume": 10,
            "layout": "auto",
        },
    )
    create_res.raise_for_status()
    request_id = create_res.json()["data"]["requestId"]
    print(f"Request created: {request_id}")
 
    # Step 2: Poll for completion
    status = "processing"
    while status not in ("completed", "failed"):
        time.sleep(10)
        status_res = requests.get(
            f"{BASE_URL}/shorts/{request_id}/status",
            headers={"X-API-Key": API_KEY},
        )
        status_data = status_res.json()["data"]
        status = status_data["status"]
        print(f"Status: {status} ({status_data['progress']}%)")
 
    if status == "failed":
        raise Exception(f"Processing failed: {status_data.get('failureReason')}")
 
    # Step 3: Get the generated shorts
    shorts_res = requests.get(
        f"{BASE_URL}/shorts/{request_id}",
        headers={"X-API-Key": API_KEY},
    )
    shorts_data = shorts_res.json()["data"]
 
    print(f"Generated {len(shorts_data['shorts'])} shorts:")
    for short in shorts_data["shorts"]:
        print(f'  - "{short["title"]}" ({short["duration"]}s, score: {short["viral_score"]})')
        print(f'    URL: {short["video_url"]}')
 
    return shorts_data["shorts"]
 
 
create_and_download_short("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

List all available assets

def list_all_assets():
    """Fetch all available music, game videos, and meme hooks."""
 
    music = requests.get(
        f"{BASE_URL}/music?limit=100",
        headers={"X-API-Key": API_KEY},
    ).json()["data"]["music"]
 
    games = requests.get(
        f"{BASE_URL}/game-videos?limit=100",
        headers={"X-API-Key": API_KEY},
    ).json()["data"]["gameVideos"]
 
    hooks = requests.get(
        f"{BASE_URL}/meme-hooks?limit=100",
        headers={"X-API-Key": API_KEY},
    ).json()["data"]["memeHooks"]
 
    print(f"Music tracks: {len(music)}")
    print(f"Game videos: {len(games)}")
    print(f"Meme hooks: {len(hooks)}")
 
    return {"music": music, "gameVideos": games, "memeHooks": hooks}

On this page

Ssemble Logo
Copyright © 2026 Ssemble Inc.
All rights reserved