Orilango API

Application Programming Interface for all Orilango services

API for Orilango Spellcheck

Welcome to the Orilango spellcheck API. The API enables you to deliver clever spellcheck to your application or web site. The API is a simple HTTP-API using. Data is sent and returned in JSON-format.

In short, you send a text to Orilango Spellcheck and get back the first spelling error that is found in the text. You present the result in your application or web site and let the user take an action. Using an offset, you perform a new request to find the next spelling error. Continue this until the complete text has been checked

Request format

The API accepts requests using HTTP POST. The url to the API is

https://api.orilango.com/v2/spellcheck/
The request data is sent as a JSON-object. In addition to the data you send your api-key in the header. The JSON-object contains these parts:

Parameter Required? Explanation
text Required The text you want spellchecked
type Optional

The type can either be to return the first spelling error that is found or all spelling errors found in the text.

Values can be either checknext or checkall. Default is checknext

NOTE: Since new spelling errors can be found when the user corrects the text, it is recommended to use checknext

selectionStart Optional If, in the previous request, a spelling error was found you set
selectionStart
to the position in the text where the misspelled word begins. When Orilango receives the request it then skips this word and return the next misspelled word. Used together with
selectionLength
selectionLength Optional If, in the previous request, a spelling error was found you set
selectionLength
to be the length of the misspelled word. When Orilango receives the request it then skips this word and return the next misspelled word. Used together with
selectionStart
wasChanged Optional If you have used on of the provided spelling suggestions to correct the text, set this to 1. Otherwise, set it to 0 or do not send the parameter at all. Used together with
selectionStart
and
selectionLength


Example

This example shows how you can use cURL to perform a spellcheck using the required parameters. Be sure to replace {api-key} with your own api-key

					curl https://api.orilango.com/v2/spellcheck \
					    -d '{
					        "text":"My firsst mispeled text wich I chek"
					    }' \
					    -H "Api-Key: {api-key}"
					

Response format

The API returns JSON-encoded objects (content-type: application/json). The response contains these parts:
Name Explanation Example value
type The type of the spelling error 0 = No error is found 1 = Word not found in wordlist (i.e a typo) 2 = Confusable word 3 = Grammar
original The word that is misspelled "firsst"
selectionStart The position of the first character in the misspelled word 3
selectionLength The length of the misspelled word 6
message A user friendly message indicating the type of spelling error "Not found in wordlist"
suggestions An array of correct suggestions to the misspelled word See section suggestions below

Suggestions

The suggestions is an array where each entry is a JSON-object containing the following parts:
word The suggested correct word
sentence An example sentence associated with the word. If no example sentence exists, this is an empty string.

Example

Using the example request above, this is the example result:

					{
					    "type": 1,
					    "original": "firsst",
					    "selectionStart": 3,
					    "selectionLength": 6,
					    "message": "Not found in wordlist",
					    "suggestions": [
					        {
					            "word": "first",
					            "sentence": "Today is the <first> of April."
					        },
					        {
					            "word": "first",
					            "sentence": "I was the <first> in the queue."
					        },
					        {
					            "word": "thirst",
					            "sentence": "Hunger and <thirst>."
					        },
					        {
					            "word": "fairest",
					            "sentence": ""
					        },
					        {
					            "word": "fitted",
					            "sentence": ""
					        },
					        {
					            "word": "forest",
					            "sentence": ""
					        },
					        {
					            "word": "forced",
					            "sentence": ""
					        },
					        {
					            "word": "firsts",
					            "sentence": ""
					        },
					        {
					            "word": "fist",
					            "sentence": ""
					        },
					        {
					            "word": "frost",
					            "sentence": ""
					        },
					        {
					            "word": "fetch",
					            "sentence": ""
					        }
					    ]
					}
					

Spellcheck all

If you set type to checkall Orilango Spellcheck will return all spelling errors in the text. The response is then simply an array containing the JSON-objects described above.

Scenario - building a text editor that uses Orilango Spellcheck

In this scenario you will be guided through the necessary steps to integrate Orilango Spellcheck in a text editor. For the scenario we assume that you have the code for the text editor and you are responsible for presenting the results from Orilango Spellcheck to the user in the most suitable way.

When the user wants to check the text for spelling errors, it's typically four different actions that are involved:

  1. The user starts the spellcheck by pressing a button or something similar. The user is then presented with the first spelling error along with a list of suggestions.
  2. The user can accept one of the suggestions provided by Orilango Spellcheck
  3. If the user think he/she has spelled correctly, he/she skips to the next spelling error instead
  4. When the complete text has been checked, the spellcheck is finished.

We will cover all four actions in the following sections.

For this scenario we assume that the api-key we are using are myapikey and the text the user has written is Hav you had inof of tis?

Action 1 - Starting the spellcheck

When the user chooses to start the spellcheck you perform the first request to Orilango Spellcheck. Since it's the first request we only have to send the required parameters. Using cUrl, the request would look like:

					curl https://api.orilango.com/v2/spellcheck \
					    -d '{
					        "text":"Hav you had inof of tis?"
					    }' \
					    -H "Api-Key: myapikey"
					

When you get the response you can use the selectionStart and selectionLength positions to highlight the word in the text in your editor. Show the message so the user knows what kind of error he/she has made. Loop through the suggestions and display the word and its associated example sentence (if available). An example of how this could look like is shown below.

Action 2 - User accepts a suggestion

The user realizes that Hav is misspelled and chooses the first suggestion in the list. In your editor, you can use the selectionStart and selectionLength parameters to extract the misspelled word, and replace it with the chosen suggestion.

When the word is replaced you send in the text again to Orilango Spellcheck, you set the selectionStart, selectionLength and wasChanged parameters in the request. For selectionStart and selectionLength, simply use the values of these parameter from the response and set it in the request. wasChanged is set to 1 Then, perform a new request:

					curl https://api.orilango.com/v2/spellcheck \
					    -d '{
					        "text":"Hav you had inof of tis?",
					        "selectionStart":"0",
					        "selectionLength":"3",
					        "wasChanged":"1"
					    }' \
					    -H "Api-Key: myapikey"

Orilango Spellcheck will now return a new response where inof is the misspelled word. Let's assume that the user accepts a suggestion from the list, and you send the text to Orilango Spellcheck again, along with updated values for the selectionStart and selectionLength parameters:

					curl https://api.orilango.com/v2/spellcheck \
					    -d '{
					        "text":"Have you had enough of tis?",
					        "selectionStart":"13",
					        "selectionLength":"4",
					        "wasChanged":"1"
					    }' \
					    -H "Api-Key: myapikey"

Action 3 - User skips a suggestion

This time, Orilango finds that of is a confusable word and returns this as a response:

					{
					    "type": 2,
					    "original": "of",
					    "selectionStart": 20,
					    "selectionLength": 2,
					    "message": "Confusable word",
					    "suggestions": [
					        {
					            "word": "of",
					            "sentence": "He lived within a mile <of> the school."
					        },
					        {
					            "word": "of",
					            "sentence": "He is a friend <of> mine."
					        },
					        {
					            "word": "of",
					            "sentence": "A cup <of> coffee."
					        },
					        {
					            "word": "off",
					            "sentence": "A light is switched on or <off>."
					        },
					        {
					            "word": "off",
					            "sentence": "He is <off> to Italy next week."
					        },
					        {
					            "word": "off",
					            "sentence": "We are <off> school today."
					        },
					        {
					            "word": "eve",
					            "sentence": ""
					        },
					        {
					            "word": "if",
					            "sentence": ""
					        },
					        {
					            "word": "Eve",
					            "sentence": ""
					        },
					        {
					            "word": "wife",
					            "sentence": ""
					        },
					        {
					            "word": "we've",
					            "sentence": ""
					        },
					        {
					            "word": "roof",
					            "sentence": ""
					        },
					        {
					            "word": "cough",
					            "sentence": ""
					        },
					        {
					            "word": "I've",
					            "sentence": ""
					        }
					    ]
					}
					
You use the same method as in Action 1 to display the result to the user. However, this time the user knows that of is correct and thus, he/she chooses to skip to the next error.

In this scenario, you keep the text intact update the selectionStart and selectionLength parameters and set wasChanged to 0. Then, perform a new request:

					curl https://api.orilango.com/v2/spellcheck \
					    -d '{
					        "text":"Have you had enough of tis?",
					        "selectionStart":"20",
					        "selectionLength":"2",
					        "wasChanged":"0"
					    }' \
					    -H "Api-Key: myapikey"
					

Orilango Spellcheck will now check for spelling errors but skip the word of at position 20 in the text, so it will return a new response where tis is found as the misspelled word.

Action 4 - Finishing the spellcheck

When the spellcheck is finished you probably want to show this to the user in some way. Continuing on our example, when the user has chosen one of the suggestions to tis and you perform a new request to Orilango Spellcheck, the request will indicate that no more spelling errors are found. When you get this respone you know that the spellcheck is complete and you can show a message to the user. The response when the spellcheck is complete is shown below:

					{
					    "type": 0,
					    "original": "",
					    "selectionStart": 0,
					    "selectionLength": 0,
					    "suggestions": [],
					    "message": "Finished"
					}
					






Login




Whoops, incorrect email/password

Forgot your password?

Enter your email to reset your password.






Get started with Orilango





There is already an account connected to your email.