Grammar Check API
Trinka Grammar Check API offers a robust suite of features to analyze and improve the grammatical accuracy of your text. We present here a comprehensive guide for developers looking to integrate Trinka's Grammar Check API into their applications. This guide explains the technical aspects of the API, with a specific focus on input and output parameters. Here, you'll find clear explanations of:
Input Parameters: This section details the specific format and data structures required for submitting text to the API for grammar checking.
Output Parameters: This section explains the format and structure of the response you receive from the API, which includes the corrected text and detailed information about the identified grammatical errors.
Understanding these parameters will enable you to effectively leverage the Trinka Grammar Check API to improve your application's functionality and deliver grammatically polished text to your users.
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)
For more details, please refer to our section on Use Cases.
How to Get Started:
-
Get an API key - You need an API key to get started. After login go to https://developer.trinka.ai/landing/apikeys, 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 https://developer.trinka.ai/landing/apikeys.
-
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": "panini1",
"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. |
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 | panini1, eagles, panini2 | Choose eagles for making only corrections, panini2 for extensive paraphrase-like changes, and panini1 for moderately extensive changes. The default is panini1. |
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 sensitive data plan documentation (link to https://developer.trinka.ai/docs/sensitive-data) 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. ",
"response": [
{
"sentence": "Wood is a natural material used in indoor environment.",
"start_index ": 0,
"end_index ": 54,
"sentence_result": [
{
"start_index": 35,
"end_index": 40,
"covered_text": "indoor",
"output": [
{
"revised_text": "the indoor",
"comment": "Change 'indoor' to 'the indoor'.",
"type": 1,
"cta_present": true,
"error_id": "132d47d3-5fc5-49f0-9ca6-7ead64b02506",
"error_category": "Articles"
}
]
}
]
},
{
"sentence": "It is utilized as not only a structural component but also an interior finishing material.",
"start_index": 55,
"end_index": 145,
"sentence_result": [
{
"start_index ": 6,
"end_index": 13,
"covered_text ": "utilized",
"output": [
{
"revised_text": "used",
"comment": "Plain language tip: Replace 'utilized' with 'used'",
"type": 1,
"cta_present": true,
"error_id": "be1b9772-0b0d-4d08-ba54-29b7bc7357ff",
"error_category": "Plain Language"
}
]
}
]
}
],
"language": "US",
"style_guide": "ACS"
}
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. |
response | array | A list of sentences with Grammar Error Correction responses. |
sentence | string | This key contains the sentence text. |
begin | integer | Identify the starting index of a particular sentence within the overall context of the paragraph. |
end | 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. |
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.