Text Statistics API
Count words, characters, sentences, paragraphs and lines, estimate reading and speaking time, and list the most frequent words of a text.
Send a text (JSON or form field, or raw text body) and get its statistics: characters (Unicode code points), characters_no_spaces, bytes_utf8, words, unique_words, sentences, paragraphs, lines and average_word_length. Words are counted with Unicode letters and digits, so Vietnamese and other non-English texts are handled correctly.
reading_time_seconds is based on wpm words per minute (default 230, range 50-1000) and speaking_time_seconds on 150 words per minute. top_words lists the most frequent words longer than 2 characters (case-insensitive); set top from 0 to 100 (default 10).
The text may contain up to 2,000,000 characters (request body up to 5 MB).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | body | string | yes | Text to analyze (max 2,000,000 characters). Can also be sent as a raw text body. | |
wpm | body|query | number | no | 230 | Reading speed in words per minute (50-1000). |
top | body|query | number | no | 10 | Number of most frequent words to return (0-100). |
Example
curl -X POST "https://apibox.io.vn/v1/text-stats" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"APIBox offers small developer APIs. They run on Cloudflare Workers!\n\nEach API is fast and simple. APIs are easy to use.","top":5}'const res = await fetch('https://apibox.io.vn/v1/text-stats', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "APIBox offers small developer APIs. They run on Cloudflare Workers!\n\nEach API is fast and simple. APIs are easy to use.",
"top": 5
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/text-stats",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"text": "APIBox offers small developer APIs. They run on Cloudflare Workers!\n\nEach API is fast and simple. APIs are easy to use.", "top": 5},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/text-stats');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"text":"APIBox offers small developer APIs. They run on Cloudflare Workers!\\n\\nEach API is fast and simple. APIs are easy to use.","top":5}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"characters": 119,
"characters_no_spaces": 98,
"bytes_utf8": 119,
"words": 21,
"unique_words": 20,
"sentences": 4,
"paragraphs": 2,
"lines": 3,
"reading_time_seconds": 6,
"speaking_time_seconds": 9,
"average_word_length": 4.48,
"top_words": [
{
"word": "apis",
"count": 2
},
{
"word": "apibox",
"count": 1
},
{
"word": "offers",
"count": 1
},
{
"word": "small",
"count": 1
},
{
"word": "developer",
"count": 1
}
]
}
Use cases
- Show word count and reading time on blog posts
- Check length limits of essays, descriptions or SMS
- Find the most used keywords of an article for SEO
- Estimate the duration of a speech or video script
FAQ
How is reading time calculated?
Words divided by the reading speed, 230 words per minute by default, rounded up to seconds. Change it with wpm.
Does it count Vietnamese words correctly?
Yes. Words are sequences of Unicode letters and digits, so accented characters are part of the word.
Are stop words excluded from top words?
Only words of 1 or 2 characters are excluded; there is no stop-word list, so frequent words like "the" may appear.
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.
AaCase Converter
Convert text to lower, UPPER, Title, Sentence, camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE or dot.case in one call.