Black FridayA full year of Eden for up to 50% off, until MondaySee the deal
Guides

Build a transcript tool

A small web app that turns any YouTube, Instagram, or TikTok link into text. Build it with the test key, then switch to your own.

View as markdown

A one-file Node server with a box for a link and a button. It calls GET /v1/transcripts from the server, waits when Eden is still fetching, and shows the words. About 50 lines.

1. Start with the test key

You need Node 18 or newer. Make a folder and a file called server.mjs:

import { createServer } from "node:http";

const EDEN_KEY = process.env.EDEN_API_KEY ?? "eden_test_demo";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

// Calls Eden from the server, so the key never reaches the browser.
async function transcribe(link) {
  for (let attempt = 0; attempt < 5; attempt++) {
    const params = new URLSearchParams({ url: link });
    const res = await fetch(`https://api.eden.so/v1/transcripts?${params}`, {
      headers: { Authorization: `Bearer ${EDEN_KEY}` },
    });
    const data = await res.json();
    if (res.status === 202) {
      await sleep(data.retry_after_seconds * 1000);
      continue;
    }
    if (!data.ok) return `Eden said: ${data.message}`;
    return data.transcript.text ?? data.on_screen_text?.text ?? "This video has no words to show.";
  }
  return "Eden is still fetching this one. Try again in a minute.";
}

const page = `<!doctype html>
<form method="get" action="/">
  <input name="url" placeholder="Paste a YouTube, Instagram, or TikTok link" size="60" />
  <button>Get transcript</button>
</form>`;

createServer(async (req, res) => {
  const link = new URL(req.url, "http://localhost").searchParams.get("url");
  res.setHeader("Content-Type", "text/html; charset=utf-8");
  if (!link) return res.end(page);
  const text = await transcribe(link);
  const safe = text.replace(/[&<>]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;" })[c]);
  res.end(`${page}<pre style="white-space:pre-wrap">${safe}</pre>`);
}).listen(3000, () => console.log("Open http://localhost:3000"));

Run it:

node server.mjs

Open http://localhost:3000, paste any video link, and click Get transcript. With no key set, it uses eden_test_demo and shows the same sample transcript every time. That's free, so build and style it as much as you like.

2. Switch to your own key

Make a key in Settings → API (or click below), then run the server with it:

Get a free key
EDEN_API_KEY="paste-your-key-here" node server.mjs

Now every link returns its real transcript. Each one costs 0.1 credit. A video with no words is free, and so is any error.

What the code handles

  • First-time links. A link Eden has never seen can answer 202. The loop waits retry_after_seconds and asks again, up to five times.
  • Videos with no speech. It falls back to on_screen_text, the words shown on screen in reels and TikToks.
  • Errors. Any "ok": false answer shows Eden's message, like an unsupported link or an empty balance. See Errors.
  • Your key. It stays in an environment variable on the server.

Ideas to take it further

  • Add a Copy button and a word count.
  • Use GET /v1/posts?url= instead to also show the caption, stats, and creator.
  • Turn the text into a blog post or a thread with your own AI key.