GET /v1/proofing/check
GET https://api.reporting.cloud/v1/proofing/check
Description
Checks a text for spelling errors with a dictionary and returns the misspelled words, and repeated words such as "the the", each with its position in the text. A text without errors returns an empty array. The names of the dictionaries come from GET /v1/proofing/availabledictionaries. See Spell Checking.
Warning
Spell Checking Quota. Each successful request counts 1 against the spell checking quota. It counts 1 also when the text has several misspelled words. Plans and Licensing lists the quota of each plan.
Examples
Request:
curl username:password \
GET "https://api.reporting.cloud/v1/proofing/check?text=Thiss%20is%20a%20testt&language=en_US.dic"
Results:
[{"length":5,"start":0,"text":"Thiss","isDuplicate":false,"language":"en_US.dic"},
{"length":5,"start":11,"text":"testt","isDuplicate":false,"language":"en_US.dic"}]
Request:
using System;
using System.Collections.Generic;
using TXTextControl.ReportingCloud;
class RCSamples
{
public static void CheckText()
{
ReportingCloud rc = new ReportingCloud(
"username",
"password",
new Uri("https://api.reporting.cloud"));
// Check the text with the US English dictionary
List<IncorrectWord> incorrectWords = rc.CheckText("Thiss is a testt", "en_US.dic");
foreach (IncorrectWord incorrectWord in incorrectWords)
{
Console.WriteLine(incorrectWord.Text + " at " + incorrectWord.Start + ", length " + incorrectWord.Length);
}
}
}
Results:
Thiss at 0, length 5
testt at 11, length 5
Request:
import com.textcontrol.reportingcloud.IncorrectWord;
import com.textcontrol.reportingcloud.ReportingCloud;
import java.io.IOException;
import java.util.List;
public class ReportingCloudSample {
public static void main(String[] args) throws IOException {
ReportingCloud r = new ReportingCloud("username", "password");
List<IncorrectWord> incorrectWords = r.checkText("Thiss is a testt", "en_US.dic");
for (IncorrectWord incorrectWord : incorrectWords) {
System.out.println(incorrectWord.getText() + " at " + incorrectWord.getStart() + ", length " + incorrectWord.getLength());
}
}
}
Results:
Thiss at 0, length 5
testt at 11, length 5
Request:
#!/usr/bin/env ruby
require "txtextcontrol/reportingcloud"
reporting_cloud = TXTextControl::ReportingCloud::ReportingCloud.new("username", "password")
incorrect_words = reporting_cloud.check_text("Thiss is a testt", "en_US.dic")
incorrect_words.each do |incorrect_word|
puts "#{incorrect_word.text} at #{incorrect_word.start}, length #{incorrect_word.length}"
end
Results:
Thiss at 0, length 5
testt at 11, length 5
Request:
require_once __DIR__ . '/vendor/autoload.php';
use TextControl\ReportingCloud\ReportingCloud;
$reportingCloud = new ReportingCloud([
'api_key' => (string) getenv('REPORTINGCLOUD_API_KEY'),
]);
var_dump($reportingCloud->proofingCheck('Thiss is a testt', 'en_US.dic'));
Results:
array(2) {
[0]=>
array(5) {
["length"]=>
int(5)
["start"]=>
int(0)
["text"]=>
string(5) "Thiss"
["is_duplicate"]=>
bool(false)
["language"]=>
string(9) "en_US.dic"
}
[1]=>
array(5) {
["length"]=>
int(5)
["start"]=>
int(11)
["text"]=>
string(5) "testt"
["is_duplicate"]=>
bool(false)
["language"]=>
string(9) "en_US.dic"
}
}
Authorization
This endpoint requires a "ReportingCloud-APIKey" or a "Basic" user authorization to access the user account, data and templates. Only one of these two methods is required.
API Keys describes how to create an API key, and Authentication explains both header forms.
ReportingCloud-APIKey
| Header field | Description |
|---|---|
| Authorization | Required. A valid ReportingCloud account is required. The Authorization field is constructed as follows: An API key needs to be generated in the portal or with PUT /v1/account/apikey. The authorization method and a space, "ReportingCloud-APIKey ", is then put before the actual API key string. For example: Authorization: ReportingCloud-APIKey oMDM4MrAqL9QEOpyzupnQW5NjvCNtvE5cVDaaLqxI |
Basic
| Header field | Description |
|---|---|
| Authorization | Required. A valid ReportingCloud account is required. The Authorization field is constructed as follows: The user name and password are combined into a string separated by a colon, for example username:password. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space, "Basic ", is then put before the encoded string. For example: Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l |
Request Parameters
| Name | Type | Value | Optional |
|---|---|---|---|
| text | String | Specifies the text to spell check. A text that is empty or holds only spaces answers 400. The query string may have at most 2,048 characters, URL-encoded, so a longer text answers 404 and has to be checked in parts. | no |
| language | String | The dictionary that is used to spell check the specified text: one of the names that /v1/proofing/availabledictionaries returns, such as en_US.dic, matched case-sensitively. Another value answers 400. | no |
Success Response
| Status | Description |
|---|---|
| 200 | On success, the HTTP status code in the response header is 200 (OK). The response body contains an array of IncorrectWord objects, one for each misspelled word and each repeated word, in the order of the text. A text without either returns an empty array. |
IncorrectWord
| Name | Type | Value | Optional |
|---|---|---|---|
| length | Integer | Gets the length of the word, in UTF-16 code units. | no |
| start | Integer | Gets the position of the word's first character in the text, counted from 0 in UTF-16 code units: a character such as an emoji counts 2. | no |
| text | String | Gets the text of the spelled word. | no |
| isDuplicate | Boolean | Gets a value indicating whether the word is returned because the word before it has the same text, compared without regard to case, as in "The the". Such a word is spelled correctly; a repetition across the end of a sentence isn't returned, and a misspelled word that is repeated is returned each time, with false. | no |
| language | String | Gets the dictionary the word was checked with: the language of the request, such as en_US.dic. | no |
Error Response
| Status | Description |
|---|---|
| 400 | A 400 (Bad Request) with the plain text "Spell checking failed" is returned, if the text is empty or holds only spaces, or if the language is empty or not the name of an available dictionary. |
| 403 | A 403 (Forbidden) is returned, if the user is not authorized or the spell checking quota is exceeded. |
| 404 | A 404 (Not Found) is returned, if a required query parameter is missing or the query string is longer than 2,048 characters. |
| 405 | A 405 (Method Not Allowed) is returned, if the request uses another HTTP method than GET. The Allow header of the response names GET. |
| 500 | A 500 (Internal Server Error) is returned, if the request has no Authorization header, an empty one or one that is not the authorization method, a space and the credentials. |