Text Summarizer API
Summarise Vietnamese or English articles by picking their most important sentences (TextRank), with keywords and scores; fast, deterministic and without AI costs.
The summarize API produces an extractive summary: it splits the text into sentences, represents each one by its words (Vietnamese words are segmented first, so “ngân hàng” counts as one word), builds a similarity graph between sentences with TF-IDF weights and ranks them with TextRank, the algorithm behind PageRank. The best sentences (or a ratio of the text) are returned in their original order, with their scores, the main keywords and the compression ratio.
Because sentences are copied from the text, the summary never invents facts, and the same text always gives the same summary. Abbreviations such as “TP.” and decimals are handled when splitting sentences, and the language is detected automatically (or set with lang).
Extractive summaries work best on news, reports and documentation. For rewritten, abstractive summaries an AI model is needed; this API deliberately avoids them to stay fast and cheap.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body | string | yes | The text (max 200,000 characters). | |
sentences | body | number | no | Number of sentences (1–50; default about 25%, max 5). | |
ratio | body | number | no | Share of sentences to keep (0.05–0.9), instead of sentences. | |
lang | body | string | no | vi or en (default: detected). |
Example
curl -X POST "https://apibox.io.vn/v1/summarize" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Ngân hàng Nhà nước vừa công bố giảm lãi suất điều hành thêm 0,5 điểm phần trăm… (8 câu)","sentences":3}'const res = await fetch('https://apibox.io.vn/v1/summarize', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "Ngân hàng Nhà nước vừa công bố giảm lãi suất điều hành thêm 0,5 điểm phần trăm… (8 câu)",
"sentences": 3
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/summarize",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"text": "Ngân hàng Nhà nước vừa công bố giảm lãi suất điều hành thêm 0,5 điểm phần trăm… (8 câu)", "sentences": 3},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/summarize');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"text":"Ngân hàng Nhà nước vừa công bố giảm lãi suất điều hành thêm 0,5 điểm phần trăm… (8 câu)","sentences":3}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"lang": "vi",
"sentences_total": 8,
"sentences_selected": 3,
"summary": "Ngân hàng Nhà nước vừa công bố giảm lãi suất điều hành thêm 0,5 điểm phần trăm, áp dụng từ ngày 15/11. Các ngân hàng thương mại dự kiến sẽ giảm lãi suất cho vay trong tháng tới. Ngân hàng Nhà nước cho biết sẽ theo dõi chặt chẽ diễn biến thị trường để điều hành linh hoạt.",
"sentences": [
"…"
],
"keywords": [
"ngân hàng",
"lãi suất",
"…"
],
"compression": 0.4,
"method": "Extractive (TextRank over TF-IDF sentence similarity); …"
}
Use cases
- News digests and article previews
- Summaries of long support tickets or reports
- Meta descriptions from article bodies
- Pre-reading of documents in internal tools
FAQ
Is this AI?
No large language model is used: TextRank is a graph algorithm. Results are deterministic and cost the same as any other request.
How long should the text be?
From a few paragraphs; with fewer than 3 sentences the text itself is returned.
Does it work for Vietnamese?
Yes, with Vietnamese word segmentation and stop words.
Related APIs
Text Diff
Compare two texts by lines, words, characters, sentences or JSON and get the changes, a similarity score and a unified diff patch.
a-bSlugify
Turn titles into clean URL slugs: accents removed (Vietnamese đ included), custom separator, optional case keeping and maximum length.
123Text Statistics
Count words, characters, sentences, paragraphs and lines, estimate reading and speaking time, and list the most frequent words of a text.