The automatic translation API is an API that allows you to easily set the translation type and translator. It supports both real-time synchronous translation and asynchronous translation, providing a flexible translation environment.
The API server generates a Signature using the service key and secret key.
Select key management in the Hive console > AI services > Automatic translation > Automatic translation system > Service management to check the generated signature. An example of the generated signature code is as follows.
The signature is the Base64 value encoded with HmacSHA256 using the service key and secret key.
importhmacimporthashlibimportbase64service_key="your_service_key"secret_key="your_secret_key"# Using hmac sha-256signature_bytes=hmac.new(secret_key.encode('utf-8'),service_key.encode('utf-8'),hashlib.sha256).digest()signature=base64.b64encode(signature_bytes).decode('utf-8')# Add signature to HTTP request# ...
publicstaticvoidmain(String[]args)throwsNoSuchAlgorithmException,InvalidKeyException{StringserviceKey="your_service_key";StringsecretKey="your_secret_key";// Using HMAC SHA-256Macsha256_HMAC=Mac.getInstance("HmacSHA256");SecretKeySpecsecretKeySpec=newSecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8),"HmacSHA256");sha256_HMAC.init(secretKeySpec);// Signature generationbyte[]signatureBytes=sha256_HMAC.doFinal(serviceKey.getBytes(StandardCharsets.UTF_8));Stringsignature=Base64.getEncoder().encodeToString(signatureBytes);// Add signature to HTTP request// ...}
Processes translation requests and results in real-time synchronous mode with a single API request and response. Since the translation result is provided directly in the API response, there is no API available to check the translation result.
This is a synchronous translation text type that supports plain text and HTML text formats that do not require pre/post-processing.
Values that are not aggregated in the automatic translation service but are stored in logs
Object
N
When converting to JSON Object String, within 1kb
{“game” : “MLB”} or [{“key1”:“blabla”}]
text
Translation request content
String
Y
※ String Json escape required
“ \”Inquiry about the registration procedure\”
from
Translation request language
String
Y
Language code corresponding to “text” Translation support languages and Hive language codes reference ※ Entering “auto” will automatically detect (lowercase)
1. (Automatic detection) “auto” 2. (Korean) “ko”
to
Translation response language
String
Y
Multiple languages can be requested by separating with “,” Translation support languages and Hive language codes reference
1. (Single language translation) “en” 2. (Multi-language translation)“en, fr, de"
curl --request POST \
--url https://ats.withhive.com/api/translate/sync \
--header 'Content-Type: application/json' \
--header 'Signature: IWusOMIBN8D/0HqgZ7/58e4rgS05E+nka3Ya9vc+yiY=' \
--data '{
"info":{
"service_key":"802890479467404e"
},
"text":"Request for the procedure for creating a server account application and managing multilingual content",
"to":"en,fr,de",
"from" : "ko"
}'
importrequestsurl="https://ats.withhive.com/api/translate/sync"payload={"info":{"service_key":"802890479467404e"},"text":"Inquiry about the multilingual content management process for server account application and account creation","to":"en,fr,de","from":"ko"}headers={"Content-Type":"application/json","Signature":"IWusOMIBN8D/0HqgZ7/58e4rgS05E+nka3Ya9vc+yiY="}response=requests.request("POST",url,json=payload,headers=headers)print(response.text)
{"result":{"code":200,"msg":"Success"},"content":{"data":{"translateMsg":[{"detectedLanguage":{"language":"ko","score":-1.0},"translations":[{"text":"Server Account Application Create an account Inquiries about the multilingual content management process","to":"en"},{"text":"Demande de compte serveur Créer un compte Demandes de renseignements sur le processus de gestion de contenu multilingue","to":"fr"},{"text":"Server-Konto-Anwendung Konto erstellen Anfragen zum mehrsprachigen Content-Management-Prozess","to":"de"}]}]}}}
The asynchronous translation API processes translation requests and responses separately through two APIs. There are two main APIs: the 'Asynchronous Translation Request API' for requests and the 'Asynchronous Translation Result Check API' for responses.
This is a translation text type for the body, supporting markdown text format that requires pre/post-processing.
Value that is not aggregated in the automatic translation service but is saved in logs
Object
N
When converting to JSON Object String, within 1kb
{“game” : “MLB”} or [{“key1”:“blabla”}]
text
Content of the translation request
String
Y
※ String JSON escape required
“ \”Inquiry about the registration procedure”
from
Language of the translation request
String
Y
Language code corresponding to “text” Translation support languages and Hive language codes reference ※ Async translation does not support automatic language detection for the translation request content.
to
Translation response language
String
Y
Multiple language requests are possible by separating with a “,” Translation support languages and Hive language code reference
The Asynchronous Translation Result Check API returns the translation results for asynchronous translation requests. In other words, it is the API corresponding to the response among asynchronous APIs that handle requests and responses separately.