import Link from "next/link"; import { redirect } from "next/navigation"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; import { hasProFeatures } from "@/lib/edition"; import { prisma } from "@/lib/db"; import { DashboardShell } from "@/components/DashboardShell"; import { UpgradeProLink } from "@/components/UpgradeProLink"; function CodeBlock({ children }: { children: string }) { return (
{children}
);
}
export default async function ApiDocsPage() {
const session = await getServerSession(authOptions);
if (!session?.user?.email) redirect("/");
const user = await prisma.user.findUnique({
where: { email: session.user.email },
include: { youtubeConnection: true },
});
if (!user) redirect("/");
const isPro = hasProFeatures(user.plan);
return (
Programmatic uploads and batch jobs for Pro subscribers. Generate your API key in{" "} Settings .
{!isPro && (
API access requires Pro.
Send your API key on every request. Keys start with s2yt_live_.
Default is 60 requests per minute per account. Approved rate-limit extensions increase that ceiling. Check live usage and request an extension in{" "} Settings → API access . Video quota limits from your Pro plan still apply to job creation.
Recommended for most jobs (especially 5+ audio files):{" "}
two-step: upload each file with POST /api/v1/upload, then
create the job with POST /api/v1/jobs (JSON).
One-shot batch{" "}
(POST /api/v1/jobs/batch) is for small packs only, typically
1 cover + up to a few audio files. Large multipart bodies often fail with{" "}
failed to parse body as FormData. Prefer two-step for albums
or long tracklists.
Content-Type manually for multipart; the client must include the boundary.audio (type File).Returns endpoint list and requirements (no auth).
Response includes path,{" "}
filename, and{" "}
size. Upload the image once, then each audio file. Keep the{" "}
path values for the next step.
Use the exact path strings returned by upload. Add one{" "}
items[] entry per track.
List existing playlists, create a new one, or create one inline when starting a job.
Pass playlistId in item metadata / batch{" "}
defaults, or use{" "}
createPlaylist to make a playlist and attach all
videos to it. Privacy may be public,{" "}
unlisted, or{" "}
private. If playlist permission was just added,
sign out and sign in again for youtube.force-ssl.
Upload one cover image and a few audio files in a single multipart request. Not recommended for large batches: use two-step instead if you see FormData parse errors.
Optional metadata JSON supports{" "}
defaults applied to every item and per-item overrides in{" "}
items. Item order should match the order of{" "}
audio files.