Skip to main content
POST
/
prepare-stream
curl -X POST "https://vibestream-production-64f3.up.railway.app/prepare-stream?url=https://youtube.com/watch?v=abc123"
{
  "success": true,
  "message": "Stream URL cached in 234ms",
  "cached": true,
  "embed_url": "https://www.youtube.com/embed/abc123?autoplay=1&mute=1",
  "embed_type": "iframe"
}

Request

url
string
required
Live stream URL to prepare. Supports YouTube (youtube.com/watch?v=, youtu.be/) and Twitch (twitch.tv/channel) formats.

Response

success
boolean
Whether the stream URL was successfully cached.
message
string
Status message with timing information.
cached
boolean
Whether the URL is now in cache.
embed_url
string
URL for embedding the stream preview. For YouTube, this is an embed URL. For Twitch, this is a player URL. For other streams, this is the direct stream URL.
embed_type
string
Type of embed: iframe (YouTube, Twitch) or video (direct stream).
curl -X POST "https://vibestream-production-64f3.up.railway.app/prepare-stream?url=https://youtube.com/watch?v=abc123"
{
  "success": true,
  "message": "Stream URL cached in 234ms",
  "cached": true,
  "embed_url": "https://www.youtube.com/embed/abc123?autoplay=1&mute=1",
  "embed_type": "iframe"
}

Use Cases

Live Preview: After validating a URL with /validate-url, call /prepare-stream to get an embeddable preview URL for your frontend:
// After URL validation shows it's live
const prepareRes = await fetch(
  `/prepare-stream?url=${encodeURIComponent(url)}`,
  { method: "POST" },
);
const { embed_url, embed_type } = await prepareRes.json();

// Render preview based on embed_type
if (embed_type === "iframe") {
  return <iframe src={embed_url} />;
} else {
  return <video src={embed_url} autoPlay muted />;
}
Performance Optimization: Calling /prepare-stream caches the stream URL, making subsequent /live-monitor, /live-digest, or /check-once calls faster.
This endpoint is optional. The main endpoints (/live-monitor, /live-digest, /check-once) will fetch and cache stream URLs automatically if not already cached.