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, and REV-API-KEY.
    • Specify the Source language & Target language(s) code.
    • Enter the content you want to localize and mention the domain.
  • 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

curl --location --request POST 'https://revapi.reverieinc.com/' \
--header 'Content-Type: application/json' \
--header 'REV-API-KEY: <YOUR API KEY>' \
--header 'REV-APP-ID: <YOUR APP-ID>' \
--header 'src_lang: en' \
--header 'tgt_lang: hi' \
--header 'domain: generic' \
--header 'REV-APPNAME: localization' \
--header 'REV-APPVERSION: 3.0' \
--data '{
    "data": [
        "Reverie Language Technologies was established in 2009.",
        "The company head office is located in Bengaluru."
    ],
   "nmtMask": true,
    "nmtMaskTerms": {
        "Reverie Language Technologies":"Reverie Language Technologies"
    },
    "enableNmt": true,
    "enableLookup": true
}'

Response

{
    "responseList": [
        {
            "inString": "Reverie Language Technologies was established in 2009.",
            "outString": "Reverie Language Technologies की स्थापना 2009 में की गई थी।",
            "apiStatus": 3
        },
        {
            "inString": "The company head office is located in Bengaluru.",
            "outString": "कंपनी का मुख्यालय बेंगलुरु में स्थित है।",
            "apiStatus": 3
        }
    ],
    "tokenConsumed": 102
}

Translate content to multiple target languages

Request

curl --location --request POST 'https://revapi.reverieinc.com/' \
--header 'Content-Type: application/json' \
--header 'REV-API-KEY: <YOUR API KEY>' \
--header 'REV-APP-ID: <YOUR APP-ID>' \
--header 'src_lang: en' \
--header 'tgt_lang: hi,ta' \
--header 'domain: generic' \
--header 'REV-APPNAME: localization' \
--header 'REV-APPVERSION: 3.0' \
--data '{
    "data": [
        "Reverie Language Technologies was established in 2009.",
        "The company head office is located in Bengaluru."
    ],
   "nmtMask": true,
    "nmtMaskTerms": {
        "Reverie Language Technologies":"Reverie Language Technologies"
    },
    "enableNmt": true,
    "enableLookup": true
}'

Response

{
    "responseList": [
        {
            "inString": "Reverie Language Technologies was established in 2009.",
            "apiStatus": 3,
            "outStrings": {
                "hi": "रेवरी लैंग्वेज टेक्नोलॉजीस की स्थापना 2009 में की गई थी।",
                "ta": "ரெவரி லாங்வேஜ் டெக்னாலஜிஸ் 2009 இல் நிறுவப்பட்டது ."
            },
            "api_statuses": {
                "hi": 3,
                "ta": 3
            }
        },
        {
            "inString": "The company head office is located in Bengaluru.",
            "apiStatus": 3,
            "outStrings": {
                "hi": "कंपनी का प्रधान कार्यालय बंगलुरू में स्थित है।",
                "ta": "நிறுவனத்தின் தலைமை அலுவலகம் பெங்கலூரில் அமைந்துள்ளது ."
            },
            "api_statuses": {
                "hi": 3,
                "ta": 3
            }
        }
    ],
    "tokenConsumed": 204
}

Error Response

{
    "message": "unauthorized to use this src/tgt language",
    "status": 403
}

API References

HTTP Request URL

URL ElementsSample URL
https://(hostname)https://revapi.reverieinc.com/

Headers

Content-Type
string
required

The format of the data to be posted: application/json

REV-API-KEY
string
required

A unique key/token provided by Reverie to identify the user using the Translation API.

REV-APP-ID
string
required

The unique account ID to identify the user and the default account settings.

REV-APPNAME
string
required

The parameter to identify the API : localization

REV-APPVERSION
string
required
  • The version refers to the specific iteration of the API that is being called.
  • Note: The default version is 2.0.
src_lang
string
required
  • The language of the input text
  • Example : or, hi, bn
  • Refer to section Language Codes for valid language code.
tgt_lang
string
required
  • 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.
domain
string
required
  • 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

data
array[]
required
  • List of input text for Translation.
enableNmt
boolean
  • 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
enableTransliteration
boolean
  • 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
enableLookup
boolean
  • 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
nmtMask
boolean
  • 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 the src_lang = en (English).
nmtMaskTerms
array[]
  • Determines the words that are to be masked.
  • Note - On defining values in the nmtMaskTerms, then automatically the nmtMask is set to true.
  • Example - Masking a term:
    nmtMaskTerms: ["Reverie Language Technologies"]
    Here, the API will mask the term Reverie Language Technologies, if found in the source content, and will transliterate the word.
filterProfane
boolean
  • Specify whether you want to filter out profane content from the input.
  • Note - By default, the filterProfane= true

Response

responseList
array[]
  • The API will return the string(s) in the target language(s).
inString
string
  • The input text in the source language.
outString
string
  • The localized content in the requested target language(s).
apiStatus
integer
  • Status of API Moderated / Partial /Unmoderated (Aggregate of all segments). Refer to API Messages to know about the available apiStatus and its description.
api_statuses
Map<String, Integer>
  • 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.
status
string
  • Error status code for the invalid request.
  • Note: The status is shown only for the invalid request.
msg
string
  • A Human-readable error message.
  • Refer to API Messages to know about the available apiStatus and its description.
tokenConsumed
integer
  • The payload length served by NMT.
  • Note - if LookUp DB serves the payload and if the content is moderated, then the tokenConsumed = 0` (Zero).
uuid
string
  • 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.

{ 
    "documentation": "http://beta.revup.reverieinc.com/dashboard/documentation", 
    "message": "Oops! something wrong happened", 
    "error_cause": "Target language is mandatory", 
    "status": "BAD_REQUEST" 
}

API Messages

Status CodeStatus TypeStatusDescription
2SuccessLOOKUP_MODERATEDAPI fetched Translation content from the database.
3SuccessMT_SUCCESSSource content translated using Neural Machine Translation (NMT).
4SuccessLOOKUP_UNMODERATEDLocalized content in database, but verification status is “unmoderated.”
5SuccessLOOKUP_INPROGRESSLocalized content in database; content moderation in progress.
6SuccessLOOKUP_PARTIALAPI partially localized a segment from LookUp DB.
10SuccessT13N_SUCCESSAPI fetched content from transliteration.
-2ErrorUNLOCALIZEDRequested content is transliterated, not translated.
-3ErrorROSETTA_ERRORError occurred while preprocessing the sentence.
-4ErrorMT_ERRORError occurred during NMT translation.
-5ErrorMT_TIME_OUTTimeout error while fetching response from NMT Engine.
-6ErrorLOCMAN_ERRORError occurred while processing content in LocMan.
-7ErrorSEGMENTATION_API_ERRORError while segmenting the sentence.
403Errorunauthorized to use this src/tgt languageInvalid or unauthorized language code provided.
403ErrorInvalid REV-API-KEY or REV-APP-IDInvalid credentials provided.
403Errorusage exhaustedProvided credit limit is exhausted.
403ErrorAPI key expiredAPI key provided has expired.
403Errorunauthorized to use this APIUser is not authorized to use the Translation API.
403ErrorPlease provide data stringData is missing.
403ErrorTarget language is mandatoryTarget language (tgt_lang) is missing.
403ErrorSource language is mandatorySource language (src_lang) is missing.