Sapling Logo
Tone API quickstart

Clojure Tone Checker

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

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

Clojure 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.
Clojure /api/v1/tone

This example uses clj-http with JSON request and response support.

(require '[clj-http.client :as http])

(def api-key
  (or (System/getenv "SAPLING_API_KEY")
      (throw (ex-info "Set SAPLING_API_KEY first." {}))))

(def response
  (http/post
    "https://api.sapling.ai/api/v1/tone"
    {:headers {"Authorization" (str "Bearer " api-key)}
     :content-type :json
     :accept :json
     :form-params
       {:text "Really stoked about this! Will it be ready by next week?"}
     :as :json}))

(println (:body response))
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 Clojure

Clojure is a dialect of Lisp, a class of programming languages that provide a macro system that treats code as mutable data. Clojure runs on the Java platform.