Translation API
Translation is the REST API developed for localizing the contents from English to Indic languages. Using the Translation API, you can either localize a single sentence or multiple sentences in a fraction of time.
How Does API Work?
The Translation API will use the App Id and API key to authenticate requests. Your credentials carry many privileges, so be sure to keep them secure.
-
Post the request by:
- Enter the valid
REV-APPNAME
,REV-APP-ID
, andREV-API-KEY
. - Specify the Source language & Target language(s) code.
- Enter the content you want to localize and mention the domain.
- Enter the valid
-
On posting the request:
- The API will validate user credentials.
- Validate the key-value pairs in the API request.
- If all the information is valid, then initially, the API will refer to the Database (Lookup DB & Template DB) to localize the content.
- If the content is not available in the Database, then the NMT (Neural Machine Translation) technology is adapted.
-
On successfully translating the content:
- The API returns the content in the requested target language(s).
cURL for Integration
Translate content to one target language
Request
Response
Translate content to multiple target languages
Request
Response
Error Response
API References
HTTP Request URL
URL Elements | Sample URL |
---|---|
https://(hostname) | https://revapi.reverieinc.com/ |
Headers
The format of the data to be posted: application/json
A unique key/token provided by Reverie to identify the user using the Translation API.
The unique account ID to identify the user and the default account settings.
The parameter to identify the API : localization
- The version refers to the specific iteration of the API that is being called.
- Note: The default version is 2.0.
- The language of the input text
- Example :
or
,hi
,bn
- Refer to section Language Codes for valid language code.
- Language to which you want to localize the input text
- Note: To enter multiple target languages, separate the value using the comma separator(,). For example:
tgt_lang
:hi, ta
- Example :
or
,hi
,bn
- Refer to section Language Codes for valid language code.
- The Domain refers to the universe in which you use the Translation API. Example- Health Care, Insurance, Legal, etc.
- Refer to section Domain Codes for valid language code.
Request
- List of input text for Translation.
- Specify whether the content Translation process should use NMT technology or not.
- For Example, When the enableNmt value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then the NMT is used for translation.
- Note - By default, the
enableNmt
=true
- Specify whether the content Translation process should use transliteration technology or not.
- For Example, When the enableTransliteration value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then nmt is used for translation. If nmt fails, transliteration is called.
- Note - By default, the
enableTransliteration
=true
- The parameter will specify whether the application should refer to the Lookup DB or not.
- For Example, when the enableLookup is true, the system will initially refer to the Database to fetch contents.
- Note - By default, the
enableLookup
=true
- The feature to screen the non-dictionary words used in a sentence. In other words, the mask will indicate the words that should not be translated into the target language.
- Note - By default, the
enableLookup
=true
- Note - To set the
nmtMask
=true
, it is mandatory thesrc_lang
=en
(English).
- Determines the words that are to be masked.
- Note - On defining values in the
nmtMaskTerms
, then automatically thenmtMask
is set to true. - Example - Masking a term:
nmtMaskTerms: ["Reverie Language Technologies"]
Here, the API will mask the termReverie Language Technologies
, if found in the source content, and will transliterate the word.
- Specify whether you want to filter out profane content from the input.
- Note - By default, the
filterProfane
=true
Response
- The API will return the string(s) in the target language(s).
- The input text in the source language.
- The localized content in the requested target language(s).
- Status of API Moderated / Partial /Unmoderated (Aggregate of all segments). Refer to API Messages to know about the available apiStatus and its description.
- A dictionary/object with language codes as keys and integer status codes as values. Represents the status of the API output for each language, indicating the moderation level of the response content. Each key is a language code (e.g.,”hi” for Hindi,”ta” for Tamil), and each value is an integer status code representing the moderation level.
- Note: This
api_statuses
field will be displayed only if multiple languages are requested in the same API payload. - Refer to section Language Codes for valid language code.
- Refer to API Messages to know about the available apiStatus and its description.
- Error status code for the invalid request.
- Note: The status is shown only for the invalid request.
- A Human-readable error message.
- Refer to API Messages to know about the available apiStatus and its description.
- The payload length served by NMT.
- Note - if LookUp DB serves the payload and if the content is moderated, then the token
Consumed =
0` (Zero).
- It is a 128-bit Universally Unique Identifier. It is likely being used for tracking a request in the Translation API.
Handling Errors
The Translation API raises exceptions for many reasons, such as failed conversions, invalid parameters, authentication errors, and network unavailability. It will provide more specific machine-readable messages with an error response so that users can react to errors more effectively.
Refer to: API Messages section to know the error code and corresponding messages.
API Messages
Status Code | Status Type | Status | Description |
---|---|---|---|
2 | Success | LOOKUP_MODERATED | API fetched Translation content from the database. |
3 | Success | MT_SUCCESS | Source content translated using Neural Machine Translation (NMT). |
4 | Success | LOOKUP_UNMODERATED | Localized content in database, but verification status is “unmoderated.” |
5 | Success | LOOKUP_INPROGRESS | Localized content in database; content moderation in progress. |
6 | Success | LOOKUP_PARTIAL | API partially localized a segment from LookUp DB. |
10 | Success | T13N_SUCCESS | API fetched content from transliteration. |
-2 | Error | UNLOCALIZED | Requested content is transliterated, not translated. |
-3 | Error | ROSETTA_ERROR | Error occurred while preprocessing the sentence. |
-4 | Error | MT_ERROR | Error occurred during NMT translation. |
-5 | Error | MT_TIME_OUT | Timeout error while fetching response from NMT Engine. |
-6 | Error | LOCMAN_ERROR | Error occurred while processing content in LocMan. |
-7 | Error | SEGMENTATION_API_ERROR | Error while segmenting the sentence. |
403 | Error | unauthorized to use this src/tgt language | Invalid or unauthorized language code provided. |
403 | Error | Invalid REV-API-KEY or REV-APP-ID | Invalid credentials provided. |
403 | Error | usage exhausted | Provided credit limit is exhausted. |
403 | Error | API key expired | API key provided has expired. |
403 | Error | unauthorized to use this API | User is not authorized to use the Translation API. |
403 | Error | Please provide data string | Data is missing. |
403 | Error | Target language is mandatory | Target language (tgt_lang) is missing. |
403 | Error | Source language is mandatory | Source language (src_lang) is missing. |