TextLens API for Ruby

Add text analysis to your Ruby app in 5 lines. Readability grades (8 formulas), sentiment scoring, keyword extraction, and SEO analysis — no gems to install, no NLP library to configure.

From the team behind textlens — 96 npm downloads/week

require 'net/http'
require 'json'

uri = URI('https://api.ckmtools.dev/v1/analyze')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

req = Net::HTTP::Post.new(uri,
  'Content-Type' => 'application/json',
  'X-API-Key' => ENV['TEXTLENS_KEY']
)
req.body = { text: 'Your content here...' }.to_json

result = JSON.parse(http.request(req).body)
puts result['readability']['consensusGrade']  # "Grade 8"
puts result['sentiment']['label']             # "positive"
puts result['keywords'].first(5).map { |k| k['word'] }.join(', ')
Join the Waitlist

What you get

8 Readability Formulas

Flesch-Kincaid, Gunning Fog, SMOG, Coleman-Liau, ARI, Dale-Chall, Linsear Write, plus a consensus grade. No Ruby gem covers all 8 in one call.

Sentiment Analysis

AFINN scoring calibrated for long-form content. Label + score + confidence. Works on blog posts, docs, marketing copy, reviews.

Keyword Extraction

TF-IDF keywords with relevance scores. Top keywords weighted by importance. SEO scoring: keyword density, optimization grade.

The response

One endpoint returns everything you need:

{
  "readability": {
    "fleschKincaidGrade": 8.2,
    "gunningFog": 10.1,
    "smog": 9.4,
    "colemanLiau": 11.3,
    "ari": 9.7,
    "daleChall": 7.8,
    "linsearWrite": 8.5,
    "consensusGrade": "Grade 9",
    "fleschReadingEase": { "score": 62.3, "interpretation": "Standard" }
  },
  "sentiment": {
    "label": "positive",
    "score": 4.2,
    "confidence": 0.71
  },
  "keywords": [
    { "word": "content", "score": 5.1, "count": 4, "density": 1.87 },
    { "word": "readability", "score": 4.8, "count": 3, "density": 1.40 }
  ],
  "seo": { "score": 74, "grade": "B" },
  "statistics": { "words": 342, "sentences": 18, "paragraphs": 5 },
  "meta": { "processing_time_ms": 14 }
}

Ruby examples

net/http — stdlib, zero dependencies recommended
require 'net/http'
require 'json'

class TextLensClient
  BASE_URI = URI('https://api.ckmtools.dev/v1/analyze').freeze

  def initialize(api_key)
    @api_key = api_key
    @http = Net::HTTP.new(BASE_URI.host, BASE_URI.port)
    @http.use_ssl = true
  end

  def analyze(text)
    req = Net::HTTP::Post.new(BASE_URI,
      'Content-Type' => 'application/json',
      'X-API-Key' => @api_key
    )
    req.body = { text: text }.to_json
    res = @http.request(req)
    JSON.parse(res.body)
  end
end

client = TextLensClient.new(ENV['TEXTLENS_KEY'])
result = client.analyze(article.body)

puts "Grade: #{result['readability']['consensusGrade']}"
puts "Sentiment: #{result['sentiment']['label']}"
puts "SEO score: #{result['seo']['score']}/100"
Faraday
require 'faraday'
require 'faraday/json_request'
require 'faraday/json_response_middleware'

conn = Faraday.new('https://api.ckmtools.dev') do |f|
  f.request :json
  f.response :json
  f.headers['X-API-Key'] = ENV['TEXTLENS_KEY']
end

response = conn.post('/v1/analyze', { text: article.body })
result = response.body

grade = result['readability']['consensusGrade']
sentiment = result['sentiment']['label']
HTTParty
require 'httparty'

class TextLens
  include HTTParty
  base_uri 'https://api.ckmtools.dev'

  def initialize(api_key)
    @options = {
      headers: {
        'X-API-Key' => api_key,
        'Content-Type' => 'application/json'
      }
    }
  end

  def analyze(text)
    self.class.post('/v1/analyze', @options.merge(body: { text: text }.to_json))
  end
end

client = TextLens.new(ENV['TEXTLENS_KEY'])
result = client.analyze(params[:content])
render json: { grade: result['readability']['consensusGrade'] }

Why not a gem?

No Ruby gem covers all 8 readability formulas plus AFINN sentiment plus TF-IDF keyword extraction in a single call. ruby-readability only handles Flesch-Kincaid. textstat ports exist but lag behind formula accuracy fixes. Building your own pipeline means installing and maintaining multiple gems, each with different APIs and result formats. TextLens API delivers the complete analysis from a single HTTP request — the same endpoint works in Ruby, Python, Go, or any language with an HTTP client.

Join the Waitlist

TextLens API is in development. Join the waitlist to get notified at launch.

Backed by the textlens npm package — 96 downloads/week.

Get Early Access

$0 — no credit card required

Pricing

Free

$0 /mo
  • 1,000 requests/mo
  • 10 req/min rate limit
  • 5,000 char max per request
Get Started

Starter

$9 /mo
  • 25,000 requests/mo
  • 60 req/min rate limit
  • 25,000 char max per request
Subscribe

Enterprise

$99 /mo
  • 500,000 requests/mo
  • 300 req/min rate limit
  • 500,000 char max per request
Subscribe

Using Python instead? Compare textstat vs TextLens API →

See all library comparisons →