Sapling Logo
Grammar API quickstart

Ruby Grammar Checker

Add spelling and grammar suggestions to a Ruby application with Sapling's edits API.

  • HTTPS POST
  • HTTP API
  • API key required
POST Ruby logo Ruby /api/v1/edits

Ruby grammar checker quickstart

Send text to the edits endpoint. Sapling returns suggested replacements with character offsets so your application can review or apply each correction.

No language-specific SDK is required. The example uses a standard or commonly used HTTP client to call Sapling's JSON API.
Ruby /api/v1/edits
require 'net/http'
require 'json'

uri = URI('https://api.sapling.ai/api/v1/edits')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
req.body = {key: 'API_KEY', text: 'Lets get started!',
session_id: 'Test Document UUID'}.to_json
res = http.request(req)
puts "response #{res.body}"
Example response application/json
{
  "edits": [
    {
      "start": 0,
      "end": 4,
      "replacement": "Let's",
      "sentence": "Lets get started!",
      "error_type": "R:OTHER"
    }
  ]
}

Each edit identifies the source range and replacement text. Preserve the original offsets when applying more than one edit.

About Ruby

Ruby is a programming language that shares design philosophies of Python and Perl around scripting, usability, and programming productivity but with a more object-oriented approach. Its popularity and adoption increased with Ruby on Rails, an MVC web framework written in Ruby.