Statistics
The Statistics endpoint computes simple statistics for a given text document. These statistics include word and sentence counts as well as Flesch-Kincaid score.
tip
This endpoint is free of charge.
Statistics POST
Sample Code
- cURL
- JavaScript
- Python
curl -X POST https://api.sapling.ai/api/v1/statistics \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "text":"Hi, how are you doing?"}'
import axios from 'axios';
async function run(text) {
try {
const response = await axios.post(
'https://api.sapling.ai/api/v1/statistics',
{
"key": '<api-key>',
text,
},
);
const {status, data} = response;
console.log({status});
console.log(JSON.stringify(data, null, 4));
} catch (err) {
const { msg } = err.response.data;
console.log({err: msg});
}
}
run('Hi, how are you doing?');
import requests
from pprint import pprint
response = requests.post(
"https://api.sapling.ai/api/v1/statistics",
json={
"key": "<api-key>",
"text": "Hi, how are you doing?"
}
)
pprint(response.json())
Request Parameters
https://api.sapling.ai/api/v1/statistics
HTTP method: POST
The Statistics API POST endpoint takes JSON parameters documented below:
key: String
32-character API key.
text: String
Text to compute statistics for. The current length limit is 50,000 characters; contact us for longer lengths or use our chunking API.
lang: String
Language to compute statistics for.
Currently supported languages: en
, de
, fr
, it
, nl
, pl
, ru
, ar
.
Contact us if you need support for other languages.
Response Parameters
The Statistics POST endpoint returns JSON of the following format:
{
"chars": 22,
"readability": 0.5, // Flesch-Kincaid readability grade
"readability_scores": {
"automated_readability_index": -2.1,
"coleman_liau_index": -3.17,
"dale_chall_readability_score": 10.2,
"difficult_words": 1,
"flesch_kincaid_grade": 0.5,
"flesch_reading_ease": 100.24,
"gunning_fog": 2.0,
"linsear_write_formula": 1.5,
"mcalpine_eflaw": 9.0,
"smog_index": 0.0,
"spache_readability": 3.26,
"text_standard": "1st and 2nd grade"
},
"reading_time_min": 1,
"reading_time_sec": 1.13,
"sentences": 1,
"words": 5
}