Skip to main content

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:

  1. 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.

  2. 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.

  3. 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.

  4. Show the corrections - Use the index and category information to selectively highlight or suggest edits to your users.

  5. 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:

VariableTypeRequired?Value OptionsDetails
x-api-keystringRequiredNAA 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.
paragraphstringRequiredNAThe text to be processed by the API should be passed under this parameter.
languagestringOptionalUS, UKUS: American English. This is the default value in case the language parameter is not set. UK: British English
pipelinestringOptionalpanini1, eagles, panini2Choose eagles for making only corrections, panini2 for extensive paraphrase-like changes, and panini1 for moderately extensive changes. The default is panini1.
is_sensitive_databooleanOptionaltrue, falseWhen 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_guidestringOptionalACS, AGU, AMA, APA, IEEEIf 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

VariableTypeDetails
statusbooleanThis denotes a Boolean value, indicating whether the request processing was successful (status: true) or failed (status: false).
messagestringA message describing the outcome of the operation.
inputstringThis is the text to be processed sent in the request.
responsearrayA list of sentences with Grammar Error Correction responses.
sentencestringThis key contains the sentence text.
beginintegerIdentify the starting index of a particular sentence within the overall context of the paragraph.
endintegerIdentify the ending index of a particular sentence within the overall context of the paragraph.
sentence_resultarrayThis is a list containing details of all errors identified in the sentence.
start_indexintegerIdentify the starting index of a particular word within the overall context of the sentence.
end_indexintegerIdentify the ending index of a particular word within the overall context of the sentence.
covered_textstringThe text within the sentence, as indicated by the start and end indices, for which Trinka API has suggesed a revision.
outputarrayThe array of multiple suggestions for the covered_text.
revised_textstringThe suggested replacement.
commentstringDescription of the suggestion.
typeintegerMajor type of the error. Here, 1 denotes grammar error, 2 spelling, 3 advisor, 4 enhancement, and 5 style guide.
cta_presentbooleanIndicates 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_idstringUnique identifier for the error.
error_categorystringCategory of the error, for example, Articles.
languagestringIndicates the language used in the input text.
style_guidestringIndicates the style guide present in the input request.

API Limits

  1. 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.
  2. Grammar Check API can currently process a maximum of 500 words in each request.

Trinka API Response Codes

Response CodeExplanation
200 - OKEverything worked as expected.
400 - Bad requestThe request was unacceptable, often due to missing a required parameter or file format not acceptable.
401 - UnauthorizedNo valid API key provided.
403 - ForbiddenThe API key doesn't have permissions to perform the request.
404 - Not foundThe requested resource doesn't exist
500 -Server errorTrinka 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.