NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

Text Summarizer Template

  • Next.js
  • TypeScript

Turn any long text into its key sentences, with how much shorter it got and the reading time you saved.

A Next.js app that summarizes text. Paste an article, email thread or report, pick how many sentences to keep, and get the key sentences as a short list with how much shorter it is and how much reading time it saves. Save the summaries you want to keep. Use it as a reading tool, or lift the API route to add TL;DRs to your own newsletter, CMS or support inbox.

The text summarizer app running

What it does

You choose the length
A slider sets how many key sentences to keep, from one to six.
Time saved, at a glance
Shows how much shorter the summary is, the word count before and after, and the reading time saved.
Key points as a list
Each kept sentence becomes a bullet, ready to copy into an email or a doc.
Saved summaries
Keep the summaries you want on the device, and delete them when you’re done.
Keeps your key private
The browser only talks to your own API route, which checks the text, caches answers and limits each visitor to 10 summaries a minute.

How it works

The API route: it checks the text and length, answers from the cache when it can, and calls Text Summarizer.

app/api/summarize/route.ts
/** POST /api/summarize { text, sentences }: picks the key sentences of a passage. */
export async function POST(request: Request) {
  const body = await request.json().catch(() => null);
  const text = String(body?.text ?? '').trim().slice(0, MAX_CHARS);
  const sentences = Math.min(10, Math.max(1, Math.round(Number(body?.sentences) || 3)));
  if (!text) return fail('Paste some text to summarize');
  if (text.split(/\s+/).length < 20 || (text.match(/[.!?](\s|$)/g) || []).length < 2) {
    return fail('Paste at least a few sentences (20 words or more): there’s nothing to shorten yet');
  }

  const key = `summarize:${sentences}:${text}`;
  const hit = fromCache<Summary>(key, TTL_MS);
  if (hit) return Response.json(hit);

  const blocked = guard(request);
  if (blocked) return blocked;

  return respond(async () => {
    const data = await callApi<Summary>('textsummarizer', { json: { text, sentences } });
    toCache(key, data);
    return data;
  });
}

See the whole file on GitHub →

Deploy it

  1. Get a free API key

    The free plan includes 200 credits a month, no card needed. Create your key.

  2. Deploy it

    Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for APIVERVE_API_KEY: paste your key there.

  3. Open your app

    Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.

Try the Text Summarizer API — the call this template makes

Request
POSTapi.apiverve.com/v1/textsummarizer
Body
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "originalWords": 67,
    "summaryWords": 30,
    "percentDifference": 44.78,
    "summary": "Headlines can be used to focus the reader's attention on a particular (or main) part of the article. A news article can include accounts of eyewitnesses to the happening event."
  }
}

Build your own with Text Summarizer. Start with 200 free credits. One key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs