Sapling Logo
Grammar API quickstart

R Grammar Checker

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

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

R 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.
R /api/v1/edits

This example uses the httr2 package.

library(httr2)

api_key <- Sys.getenv("SAPLING_API_KEY")
if (!nzchar(api_key)) {
  stop("Set SAPLING_API_KEY first.")
}

response <- request("https://api.sapling.ai/api/v1/edits") |>
  req_headers(Authorization = paste("Bearer", api_key)) |>
  req_body_json(list(
    text = "Lets get started!",
    session_id = "quickstart"
  )) |>
  req_perform()

resp_body_json(response, simplifyVector = TRUE)
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 R

R is a programming language and environment for statistical computing, data analysis, and visualization. It is widely used by data scientists, researchers, and teams working with quantitative data.