Grammar Check API
This guide helps you easily integrate the Trinka Grammar Check API into your applications to automatically check and correct grammar errors in text content.
Use Cases
Here are some of the things that Grammar Check API can do for you:
- Find and fix grammar mistakes in text
- Receive real-time grammar & spelling suggestions in text editors
- Correct grammar and spelling mistakes in translated text
- Automate essay marking
- Integrate with learning management systems (LMS)
How to Get Started:
-
Get an API key - You need an API key to get started. After login go to Trinka AI Developer Portal, and generate your Test API Key. The Test API Key can be used for testing the functionality or during development of your application. Once your application is ready to go live, you need to generate a Production API Key for using on your live application. Both the keys have different rate limits, as mentioned on Trinka AI Developer Portal API Keys.
-
Send an API request - Send an HTTPs request to send text to Trinka for checking your text. Note that the API uses RESTful architecture, and the input/output is in JSON format. Standard HTTP response codes, authentication, and verbs are used. The content-type of both request and response must be application/json. All the data must be UTF-8 encoded.
-
Get the results - Trinka will send back suggestions for corrections, including the location of errors via indexes of characters to be changed. Trinka will also send back the category of errors.
-
Show the corrections - Use the index and category information to selectively highlight or suggest edits to your users.
-
Handle errors - Trinka uses standard codes to indicate success or problems.
API Request-Response
Trinka's Grammar Check API provisions clients to use it for checking a paragraph for grammar errors. Trinka uses conventional HTTP response codes to indicate the success or failure of an API request. A list of error codes and error description is given here.
API Input
Request URL: https://api-platform.trinka.ai/api/v2/plugin/check/paragraph
Curl:
curl --location --request POST 'https://api-platform.trinka.ai/api/v2/plugin/check/paragraph' \
--header 'x-api-key: <<<<>>>>>' \
--header 'Content-Type: application/json' \
--data-raw '{
"paragraph": " Wood is a natural material used in indoor environment. It is utilized as not only a structural component but also an interior finishing material.",
"language": "US",
"pipeline": "advanced",
"style_guide": "",
"is_sensitive_data": false
}'
What does this endpoint do?
- Check your paragraph for grammar errors and style issues.
- Provide a breakdown of errors by sentence.
The expected input is the paragraph that you want to check and the language style - "US" or "UK". Please note that a paragraph cannot have more than 500 words.
Input Response Structure
This endpoint takes JSON parameters documented below:
| Variable | Type | Required? | Value Options | Details |
|---|---|---|---|---|
| x-api-key | string | Required | NA | A 32-character API key must be entered in order to use Trinka APIs. You can generate a test or production API key from your dashboard. |
| paragraph | string | Required | NA | The text to be processed by the API should be passed under this parameter. Max 500 words can be processed in one request. |
| language | string | Optional | US, UK | US: American English. This is the default value in case the language parameter is not set. UK: British English |
| pipeline | string | Optional | basic, advanced | Choose basic for making only corrections, and advanced for moderately extensive changes. The default is advanced. |
| is_sensitive_data | boolean | Optional | true, false | When this parameter is set to "true", the content passed to our API is not stored on our servers. The default setting for this parameter is "false". Please refer to the confidential data plan documentation for more details. |
| style_guide | string | Optional | ACS, AGU, AMA, APA, IEEE | If you want language alerts to conform to a particular style guide, please pass the style guide name as a string under this parameter. The default value is null, which means no style guide alerts will be shown if the style_guide parameter does not have one of the five values given in the Value Options column |
API Output
{
"status": true,
"message": "Success",
"input": " Wood is a natural material used in indoor environment. It is utilized as not only a structural component but also an interior finishing material.",
"response": [
{
"sentence": "Wood is a natural material used in indoor environment.",
"start_index": 1,
"end_index": 55,
"sentence_result": [
{
"start_index": 42,
"end_index": 52,
"covered_text": "environment",
"output": [
{
"revised_text": "environments",
"comment": "Replace 'environment' with 'environments'.",
"type": 1,
"cta_present": true,
"error_id": "c02143cc-890e-48dd-9c0f-1816b04bab45",
"error_category": "Singular-Plural nouns"
}
],
"category_details_v2": {
"id": 1,
"category": "Correctness",
"sub_category": "Grammar",
"lang_category": "Singular-Plural Nouns",
"critical_error": false
}
}
]
},
{
"sentence": "It is utilized as not only a structural component but also an interior finishing material.",
"start_index": 56,
"end_index": 146,
"sentence_result": [
{
"start_index": 6,
"end_index": 16,
"covered_text": "utilized as",
"output": [
{
"revised_text": "used",
"comment": "Change 'utilized as' to 'used'",
"type": 1,
"cta_present": true,
"error_id": "a5b0c132-1218-49c2-bcee-26debc261963",
"error_category": "Syntax"
}
],
"category_details_v2": {
"id": 1,
"category": "Correctness",
"sub_category": "Syntax & Vocabulary",
"lang_category": "Syntax",
"critical_error": false
}
},
{
"start_index": 27,
"end_index": 27,
"covered_text": "a",
"output": [
{
"revised_text": "as a",
"comment": "Change 'a' to 'as a'",
"type": 1,
"cta_present": true,
"error_id": "7e342a52-868a-4fc7-8f96-736f03d03a20",
"error_category": "Prepositions"
}
],
"category_details_v2": {
"id": 1,
"category": "Correctness",
"sub_category": "Grammar",
"lang_category": "Prepositions",
"critical_error": false
}
},
{
"start_index": 59,
"end_index": 60,
"covered_text": "an",
"output": [
{
"revised_text": "as an",
"comment": "Change 'an' to 'as an'",
"type": 1,
"cta_present": true,
"error_id": "4dedc4cf-b7af-4da0-ac71-24dea5fdca99",
"error_category": "Prepositions"
}
],
"category_details_v2": {
"id": 1,
"category": "Correctness",
"sub_category": "Grammar",
"lang_category": "Prepositions",
"critical_error": false
}
}
]
}
],
"language": "US",
"style_guide": ""
}
Output Response Structure
| Variable | Type | Details |
|---|---|---|
| status | boolean | This denotes a Boolean value, indicating whether the request processing was successful (status: true) or failed (status: false). |
| message | string | A message describing the outcome of the operation. |
| input | string | This is the text to be processed sent in the request. You can pass up to 500 words in one request. We will break up the input into distinct sentences. |
| response | array | A list of sentences with Grammar Error Correction responses. |
| sentence | string | Each sentence contained in the input is separated and presented in the "sentence" key. |
| start_index | integer | Identify the starting index of a particular sentence within the overall context of the paragraph. |
| end_index | integer | Identify the ending index of a particular sentence within the overall context of the paragraph. |
| sentence_result | array | This is a list containing details of all errors identified in the sentence. |
| start_index | integer | Identify the starting index of a particular word within the overall context of the sentence. |
| end_index | integer | Identify the ending index of a particular word within the overall context of the sentence. |
| covered_text | string | The text within the sentence, as indicated by the start and end indices, for which Trinka API has suggesed a revision. |
| output | array | The array of multiple suggestions for the covered_text. |
| revised_text | string | The suggested replacement. |
| comment | string | Description of the suggestion. |
| type | integer | Major type of the error. Here, 1 denotes grammar error, 2 spelling, 3 advisor, 4 enhancement, and 5 style guide. |
| cta_present | boolean | Indicates if a call-to-action (CTA) for the correction is present. If the value is false, the revised_text key will be an empty string. |
| error_id | string | Unique identifier for the error. |
| error_category | string | Category of the error, for example, Articles. |
| category_details_v2 | array | Detailed category labels, giving the category, subcategory (if necessary), and language category. |
| id | integer | integer values for different categories. 1 = Correctness, 2 = Clarity, 3 = Fluency, 4 = Style, 6 = Inclusivity, and 5 =Style Guide Compliance |
| category | string | Possible values: Correctness, Clarity, Fluency, Style, Inclusivity, and Style Guide Compliance |
| sub_category | string | Correctness category is further divided into Grammar, Punctuation, Spellings and so on |
| lang_category | string | Specific language error categories such as Articles, Prepositions and so on |
| critical_error | boolean | This label will be used in future to mark critical errors. |
| language | string | Indicates the language used in the input text. |
| style_guide | string | Indicates the style guide present in the input request. |
API Limits
- Grammar Check API can currently accept 20 requests/second when called using the Production API Key and 1 request/second when called using the Test API Key.
- Grammar Check API can currently process a maximum of 500 words in each request.
Trinka API Response Codes
| Response Code | Explanation |
|---|---|
| 200 - OK | Everything worked as expected. |
| 400 - Bad request | The request was unacceptable, often due to missing a required parameter or file format not acceptable. |
| 401 - Unauthorized | No valid API key provided. |
| 403 - Forbidden | The API key doesn't have permissions to perform the request. |
| 404 - Not found | The requested resource doesn't exist |
| 500 -Server error | Trinka server issue |
Solutions to Common Issues
If you have trouble using the Trinka Grammar Check API, try these:
- Make sure your API key is valid and set up correctly.
- Check that your app has a good internet connection.
- Confirm that your API request is correctly formatted.
For any queries feel free to connect with us at support@trinka.ai.