Backend Documentation
Import the Sapling client with:
import { Client } from "@saplingai/sapling-js/client";
constructor(...)
Returns a Sapling HTTP API Client wrapper.
Request Parameters
apiKey: String
32-character API key
options: Optional Object
Supported option fields:
- timeout: Optional Integer
Timeout for API call in seconds. Defaults to 120000 milliseconds. - hostname: Optional String
Hostname override for SDK and self-hosted deployments. - pathname: Optional String
Pathname override for SDK and self-hosted deployments as well as version requirements.
edits(...)
Request Parameters
text: String
Text to process for edits.
sessionId: Optional String
Unique name or UUID of document or portion of text that is being checked
options: Optional Object
Supported options fields:
- lang: Optional String
Specifies language for grammar and spell checking.
Supported Languages
Specifies language for grammar and spell checking. Defaults to English, or the language specified in the dashboard.
Supported languages:
auto
: Autodetect languagede
: German (Deutsch)el
: Greek (Ελληνικά)en
: English (US/UK/CA/AU)es
: Spanish (Español)fr
: French (Français) (fr-fr
andfr-ca
coming soon)it
: Italian (Italiano)jp
: Japanese (日本語)ko
: Korean (한국어)nl
: Dutch (Nederlands)pl
: Polish (Polski)pt
: Portuguese (Português) (pt-pt
andpt-br
coming soon)sv
: Swedish (Svenska)tl
: Tagalogzh
: Chinese (中文)
- variety: Optional String
Supported Varieties
This option is currently available for: English, Chinese (中文). Specifies regional English/Chinese spelling options. The setting defaults to the configuration in the Sapling dashboard.
Supported varieties:
English:
us-variety
: American Englishgb-variety
: British Englishau-variety
: Australian Englishca-variety
: Canadian Englishnull-variety
: Don’t suggest any changes based on English variety
Chinese (中文)
s-variety
: Simplified Chineset-variety
: Traditional Chinese
-
auto_apply: Optional Boolean
Default is false. If true, will return field containing text with edits applied. Note: this argument does not support HTML. -
medical: Optional Boolean
Default is false. If true, the backend will apply Sapling's medical dictionary. You can test the medical spellcheck system here. -
advancedEdits: Optional Object
Supported advancedEdits fields:
- advanced_edits
- adverbs
- simplifications
- hard_to_read
- qualifiers
- voice
- dei
- gender
- gender_pronoun
- gender_noun
- gender_id
- sensitivity
- disability
- age
- race
- social_class
- violence
Response Parameters
Promise, returns JSON with parameters documented below:
edits: Array
Array of Edit
objects for the text sent in the request.
Edit Data Structure:
{
"id": <str, UUID>, // Opaque edit id, used to give feedback
"sentence": <str>, // Unedited sentence
"sentence_start": <int>, // Offset of sentence from start of text
"start": <int>, // Offset of edit start relative to sentence
"end": <int>, // Offset of edit end relative to sentence
"replacement": <str>, // Suggested replacement
"error_type": <str>, // Error type, see "Error Categories"
"general_error_type": <str>, // See "Error Categories"
}
accept(...)
Use this method to have Sapling adapt its system over time.
Each suggested edit has an edit UUID. You can pass this information back to Sapling to indicate the edit suggestion was helpful. For each unique edit in each document, use the accept or reject method only once in total.
Request Parameters
editUUID:String (UUID)
ID of an Edit
.
sessionId: String
Unique name or UUID of article or portion of text that is being checked
Response Parameters
null
reject(...)
Use this method to have Sapling not recommend the same edit anymore.
Each suggested edit has an edit UUID. You can pass this information back to Sapling to indicate the edit suggestion was not helpful. For each unique edit in each document, use the accept or reject method only once in total.
Request Parameters
editUUID: String (UUID)
ID of an Edit
.
sessionId: String
Unique name or UUID of article or portion of text that is being checked
Response Parameters
null