Sapling Logo
Tone API quickstart

R Tone Checker

Analyze overall and sentence-level tone from a R application across 28 fine-grained categories.

  • HTTPS POST
  • JSON HTTP API
  • Bearer API key
POST R logo R /api/v1/tone

R tone checker quickstart

Send text to the tone endpoint. The response ranks overall tones and returns a separate probability breakdown for every sentence.

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/tone

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/tone") |>
  req_auth_bearer_token(api_key) |>
  req_body_json(list(
    text = "Really stoked about this! Will it be ready by next week?"
  )) |>
  req_perform()

resp_body_json(response, simplifyVector = TRUE)
Example response application/json
{
  "overall": [
    [0.9247, "curious", "🤓"],
    [0.0455, "excited", "😀"],
    [0.0057, "confused", "😕"]
  ],
  "results": [
    [[0.9937, "excited", "😀"]],
    [[0.5469, "confused", "😕"], [0.3993, "curious", "🤓"]]
  ],
  "sents": [
    "Really stoked about this!",
    "Will it be ready by next week?"
  ]
}

Probabilities are returned in descending order as probability, tone, and emoji tuples. Use sentence results when a message contains mixed tones.

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.