Estimate Reading Time with the Text Analysis API

Reading time badges have become standard on blogs and content platforms. Medium, Dev.to, and most modern CMSs display "X min read" alongside every article. Building this feature from scratch means deciding on a words-per-minute rate, handling edge cases, and maintaining the logic. The Apixies Text Analyzer API returns reading_time_min and speaking_time_min alongside word counts, so you can add reading time to your content in a single API call.

How Reading Time Is Calculated

The API estimates reading time using an average adult reading speed of approximately 200-250 words per minute. Speaking time uses a slightly lower rate (~150 wpm) to account for natural speech pacing.

Metric Rate Use Case
reading_time_min ~200-250 wpm Blog posts, articles, documentation
speaking_time_min ~150 wpm Podcast scripts, presentations, speeches

Both values are returned as decimal minutes (e.g., 2.5 = 2 minutes 30 seconds), making them easy to format however your UI requires.

Adding Reading Time to a Blog

Step 1 -- Get Reading Time from the API

curl -X POST "https://apixies.io/api/v1/analyze-text" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Your full blog post content goes here..."}'

The response includes:

{
  "status": "success",
  "data": {
    "words": 1250,
    "reading_time_min": 5.0,
    "speaking_time_min": 8.3
  }
}

Step 2 -- Display a Reading Time Badge (JavaScript)

async function addReadingTimeBadge(articleElement) {
  const text = articleElement.textContent;

  const response = await fetch("https://apixies.io/api/v1/analyze-text", {
    method: "POST",
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ text }),
  });

  const { data } = await response.json();

  // Round up to nearest minute for display
  const minutes = Math.ceil(data.reading_time_min);
  const badge = document.createElement("span");
  badge.className = "reading-time-badge";
  badge.textContent = `${minutes} min read`;

  articleElement.querySelector(".article-meta").appendChild(badge);
}

Step 3 -- Server-Side Rendering (PHP / Laravel)

Calculate reading time when saving a post, then store it for fast rendering:

// In your Post controller or observer
$stats = analyzeText(strip_tags($post->content));

$post->update([
    'word_count'    => $stats['words'],
    'reading_time'  => (int) ceil($stats['reading_time_min']),
]);

Then in your Blade template:

<div class="article-meta">
    <span>{{ $post->reading_time }} min read</span>
    <span>{{ number_format($post->word_count) }} words</span>
</div>

Step 4 -- Python / Django Integration

import requests
import math
import os

api_key = os.environ["APIXIES_KEY"]

def update_reading_time(post):
    response = requests.post(
        "https://apixies.io/api/v1/analyze-text",
        json={"text": post.plain_text_content},
        headers={"X-API-Key": api_key},
    )
    data = response.json()["data"]

    post.word_count = data["words"]
    post.reading_time = math.ceil(data["reading_time_min"])
    post.save()

    return post.reading_time

Formatting Reading Time for Display

The raw reading_time_min value is a decimal. Here are common display formats:

function formatReadingTime(minutes) {
  if (minutes < 1) return "Less than 1 min read";
  if (minutes < 2) return "1 min read";
  return `${Math.ceil(minutes)} min read`;
}

function formatSpeakingTime(minutes) {
  const mins = Math.floor(minutes);
  const secs = Math.round((minutes - mins) * 60);
  if (mins === 0) return `${secs}s`;
  return secs > 0 ? `${mins}m ${secs}s` : `${mins}m`;
}

Use Cases Beyond Blogs

  • Email newsletters -- Show reading time in the subject line or preview to improve open rates.
  • Documentation -- Help developers estimate how long a setup guide will take.
  • E-learning platforms -- Display lesson duration for text-based courses.
  • Podcast show notes -- Use speaking_time_min to estimate episode length from a script.
  • Content planning -- Calculate total reading time across a series of articles.

Next Steps

Get your free API key and add reading time to your content today.

Try the Text Analyzer API

Free tier is for development & small projects. 75 requests/day with a registered account.

Getting Started

Explore

Resources

Get Started Free

Free for development and small projects.

Get Free API Key