Skip to content

Automatic translation API

The automatic translation API is an API that allows you to easily set translation types and translators. It supports both real-time synchronous translation and asynchronous translation, providing a flexible translation environment.

There are two types of automatic translation APIs:

synchronous translation API that allows real-time translation, asynchronous translation request API that does not allow real-time translation, and asynchronous translation result confirmation API.

Notes

Supported text formats

The text formats supported by the synchronous translation API and the asynchronous translation API are as follows.

  • Synchronous Translation API: Supports plain text and HTML formats
  • Asynchronous Translation API: Supports Markdown format

Project Matching Methods

The automatic translation API provides two ways to match translation services for each game project registered in the App Center.

  • 1:1 matching with automatic translation services: Register the service used for each project
  • When calling one automatic translation service, enter the project ID to match: Call the API by adding each project ID

Translation Supported Languages

A total of 16 translation languages ​​are supported by Hive platform, as follows.

Language Language-specific notation language code
Korean Korean ko
English English en
Japanese 日本語 ja
Simplified Chinese 简体中文 zh-hans
Traditional Chinese 繁體中文 zh-hant
French Français fr
German Deutsch de
Russian русский ru
Spanish Español es
Portuguese Português pt
Indonesian Bahasa Indonesia id
Vietnamese tiếng Việt vi
Thai ไทย th
Italian Italiano it
Turkish Türkçe tr
Arabic العربية ar

Prerequisites

Prerequisites for using the automatic translation API are as follows.

1. Check service key (appKey), secret key

  1. Register the service in Hive Console > AI Service > Automatic Translation > Automatic Translation System > Service Management.
  2. Check the service key (old app key) and secret key for the product.

2. Check Signature

The back office of the API server generates a Signature using the service key and secret key.

Check the generated signature by selecting Key Management in Hive Console > AI Service > Automatic Translation > Automatic Translation System > Service Management. An example of the generated signature code is as follows.

※ The signature is a Base64 value encoded with HmacSHA256 using the app key and encryption key.

import hmac
import hashlib
import base64

app_key = "your_app_key"
secret_key = "your_secret_key"

# Use HMAC SHA-256
signature_bytes = hmac.new(secret_key.encode('utf-8'), app_key.encode('utf-8'), hashlib.sha256).digest()
signature = base64.b64encode(signature_bytes).decode('utf-8')

# Add signature to HTTP request
# ...
public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException {
String appKey = "your_app_key";
String secretKey = "your_secret_key";

// Use HMAC SHA-256
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
sha256_HMAC.init(secretKeySpec);

// Create signature
byte[] signatureBytes = sha256_HMAC.doFinal(appKey.getBytes(StandardCharsets.UTF_8));
String signature = Base64.getEncoder().encodeToString(signatureBytes);

// Add signature to HTTP request
// ...
}

Synchronous translation API

Process translation request and translation result as one API request and response in real-time synchronous manner. Since translation result is provided directly in API response, there is no API to check translation result.

It is a synchronous translation text type, supporting plain text and HTML text formats that do not require pre/post processing.

Request URL

LIVE URL https://ats.withhive.com/api/translate/Sync https://ats.withhive.com/api/translate/sync/{project_id}
HTTP Method POST
Content-Type application/json
Data Format JSON

Request path

Field name Description Type Required Whether Details Example
project_id App Center Project ID String N 1. If there is a value: Aggregate by project ID 2. If there is no value: Aggregate by “None” com.com2us.project1

Request header

Field name Description Type Required or not Details Example
Signature Signature value for authentication String Y HmacSHA256 encoded value of the app key value using the secret key IWusOMIBN8D/0HqgZ7/58e4rgS05E+nka3Ya9vc+yiY=

Request body

Field name Description Type Required or not Details Example
info App key information object Object Y
info > app_key App key value String Y 802890479467404e
info > meta_data Value not aggregated by automatic translation service, but saved as log Object N When converting JSON Object String, within 1kb {“game” : “MLB”} or [{“key1”:“blabla”}]
text Translation request content String Y ※ String JSON escaping required “Inquiry about \”registration\” procedure”
from Language of translation request String Y Language code corresponding to “text” Translation support language and language code reference ※ When entering “auto”, automatic detection (lowercase) 1. (Automatic detection) “auto” 2. (Korean) “ko”
to Translation response language String Y Multiple languages ​​can be requested by separating them with “,” Translation support languages ​​and language code reference 1. (Single language translation) “en” 2. (Multi-language translation) “en, fr, de"

Response

Field name Description Type Details Example
result Result value Object
result > code Result code Integer Response Code reference '200' in case of success
result > msg Result message String Response Code reference 'Success' in case of success
content Translation result Object
content > data > translateMsg Array of translation values Array
content > data > translateMsg > detectedLanguage Input language related values Object ※ Exists when “Translation request language (from)” is “auto”
content > data > translateMsg > detectedLanguage > language Input language detection values String Translation support languages ​​and language codes Reference
content > data > translateMsg > detectedLanguage > score Input language detection score (closer to 1 is more accurate) Number (Float) 1.0
content > data > translateMsg > translations Array of translated text Array Exposed as an array by language
content > data > translateMsg > translations > text Translated text String Json Escape string Inquiries about the \"Registration\" process
content > data > translateMsg > translations > to Translation language country code String "en"

Response code

Code Text Note
200 "success" Success
400 <> is Missing or Incorrect request Failed - Request parameter missing or Failed - Unparsable (JSON error)
401 Wrong Signature Failed - Signature key error
404 Unregistered app key Failed - Unregistered app key
404 Unregistered job uuid Failed - Unregistered job uuid
500 Internal Server Error (or Some message) Failed - Internal server Error

Request example

    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":{
                "app_key":"802890479467404e"
        },
        "text": "Server Account Application Account Creation Multilingual Content Management Procedure Inquiry",
        "to":"en,fr,de",
        "from": "ko"
        }'
    import requests

    url = "https://ats.withhive.com/api/translate/sync"

    payload = {
            "info": {"app_key": "802890479467404e"},
            "text": "Server Account Application Account Creation Multilingual Content Management Procedure Inquiry",
            "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)
    OkHttpClient client = new OkHttpClient();

    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{\n    \"info\":{\n        \"app_key\":\"802890479467404e\"\n    },\n    \"text\":\"Server Account Application Account Creation Inquiry about Multilingual Content Management Procedure\",\n    \"to\":\"en,fr,de\",\n    \"from\" : \"ko\"\n}");
    Request request = new Request.Builder()
        .url("https://ats.withhive.com/api/translate/sync")
        .post(body)
        .addHeader("Content-Type", "application/json")
        .addHeader("Signature", "IWusOMIBN8D/0HqgZ7/58e4rgS05E+nka3Ya9vc+yiY=")
        .build();

    Response response = client.newCall(request).execute();

Response example

    {
    "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"
                }]
            }]
        }
    }
  }

Asynchronous translation request API

The asynchronous translation API is divided into two APIs, translation request and translation response. It is processed as. There is an 'asynchronous translation request API' corresponding to the request and an 'asynchronous translation result confirmation API' corresponding to the response.

It is a synchronous translation text type, and supports the Markdown text format that requires pre/post-processing.

Request URL

LIVE URL https://ats.withhive.com/api/translate/async https://ats.withhive.com/api/ translate/async/{project_id}
HTTP Method POST
Content-Type application/json
Data Format JSON

Request Path

Field name Description Type Required Whether Details Example
project_id App Center Project ID String Y 1. If there is a value: Aggregate by project ID 2. If there is no value: “None” Aggregation com.com2us.project1

Request header

Field name Description< /th> Type Required Details Example
Signature Signature value for authentication String Y Encode the app key value using the secret key to HmacSHA256 One value pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c=

Request body

Field name Description< /th> Type Required Details Example
info App Key Info Object Object Y
info > app_key App key value String Y 802890479467404e
info > meta_data Not aggregated by automatic translation service, but stored as a log value Object N When converting JSON Object String, within 1kb {“game” : “MLB”} or [{“key1”:“blabla”}]
text Translation request content String Y ※ String Json Escape Required “Inquiry about \”Registration\” Procedure”
from Translation request language String Y Language code corresponding to “text” Translation support languages ​​and language code reference ※ async translation Automatic language detection for translation requests is not supported.
to Translation response language String Y Multiple language requests can be made by separating with “,” Translation support languages ​​and language code reference 1. (Single language translation) “en” 2. (Multi-language translation) “en , fr, de"

Response

Field name Description Type Details Example
result Result value Object
result > code Result code Integer Response Code Reference '200' on success
result > msg Result message String Response Code Reference 'Success' on success
content Translation result value Object
content > uuid Translation result ID String UUID4 format ID ID for checking translation status 62fe5786-0bb8-4cd0-b51a-6d6f6bfe2bac
content > resultUrl URL for checking translation status String /api/translate/async/result/{uuid} 임

Response code

Code Text Note
200 "success" Success
400 <> is Missing or Incorrect request Failed - Request parameter missing or Failed - Unparsable (JSON error)
401 Wrong Signature Failed - Signature key error
404 Unregistered app key Failed - Unregistered app key
404 Unregistered job uuid Failed - Unregistered job uuid
500 Internal Server Error (or Some message) Failure - Server internal error

Request example

    curl --request POST \
    --url https://ats.withhive.com/api/translate/async \
    --header 'Content-Type: application/json' \
    --header 'Signature: pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c=' \
    --data '{
        "info":{
                "app_key":"815e3d8d6e7443ba"
        },
        "text":"# Markdown Cheat Sheet ......",
        "to":"ko,ja,zh-hant",
                "from":"en"
    }'
    import requests

    url = "https://ats.withhive.com/api/translate/async"

    payload = {
            "info": {"app_key": "815e3d8d6e7443ba"},
            "text": "# Markdown Cheat Sheet ......",
            "to": "ko,ja,zh-hant",
            "from": "en"
    }
    headers = {
            "Content-Type": "application/json",
            "Signature": "pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c="
    }

    response = requests.request("POST", url, json=payload, headers=headers)

    print(response.text)
    OkHttpClient client = new OkHttpClient();

    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, "{\n    \"info\":{\n        \"app_key\":\"815e3d8d6e7443ba\"\n    },\n\t\"text\":\"# Markdown Cheat Sheet 
    ......\",\n    \"to\":\"ko,ja,zh-hant\",\n\t\t\"from\":\"en\"\n}\n");
    Request request = new Request.Builder()
        .url("https://ats.withhive.com/api/translate/async")
        .post(body)
        .addHeader("Content-Type", "application/json")
        .addHeader("Signature", "pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c=")
        .build();

    Response response = client.newCall(request).execute();

Response example

{
    "result": {
        "code": 200,
        "msg": "Success"
    },
    "content": {
        "uuid": "d2a36ba1-1bb3-43aa-ac57-46576d27eb37",
        "resultUrl": "https://test-ats.withhive.com/api/translate/async/result/d2a36ba1-1bb3-43aa-ac57-46576d27eb37"
    }
 }

Asynchronous translation result check API

The asynchronous translation result check API returns the translation result for the asynchronous translation request. In other words, it is an API corresponding to the response among the asynchronous APIs that process requests and responses separately.

Request URL

LIVE URL https://ats.withhive.com/api/translate/async/result/{uuid}
HTTP Method GET

Request path

Field name Description Type Required or not Details Example
uuid Translation result ID, status response value for asynchronous translation request String Y Check from creation to ~Nday 5c8ded49-9ee2-412a-a0ab-a4018a0dc093

Request header

Field name Description Type Required or not Details Example
Signature Signature value for authentication String Y App key value encoded using HmacSHA256 using secret key pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c=

Response

Field name Description Type Details Example
result Result value array Object
result > code Result code Integer Response Code reference '200' in case of success
result > msg Result message String Response Code reference 'Success' in case of success
content Translation result Object
content Translation result Object
content > status Translation status value Object Translation status information
content > status > code Translation status code Integer 100 / 101 / 102 / 199
content > status > mag Translation status message String “completed(100)”/ “waiting(101)” / “processing(102)” / “failed(199)”
content > data Translation result value Object ※ If result>status>msg value is “waiting” / “processing” / “failed”, no field, only exists if it is “completed”
content > data > translateMsg Translation value array Array
content > data > translateMsg > translations Array of translation text Array Exposed as an array by language
content > data > translateMsg > translations > text Translation text String Json escape string Inquiries about the \"Registration\" process
content > data > translateMsg > translations > to Translation language country code String "en"

Response code

Code Text Note
200 "success" Success
400 <> is Missing or Incorrect request Failed - Request parameter missing or Failed - Unable to parse (JSON error)
401 Wrong Signature Failed - Signature key error
404 Unregistered app key Failed - Unregistered app key
404 Unregistered job uuid Failed - Unregistered job uuid
500 Internal Server Error (or Some message) Failed - Internal server error

Request example

    curl --request GET 
    --url https://test-ats.withhive.com/api/translate/asyncresult/3f8891e9-513a-4e91-b0b6-ac9aabbbf6d2 
    --header 'Content-Type: application/json' 
    --header 'Signature: pczeZ91NijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c='
import requests

url = "https://ats.withhive.com/api/translate/async/result/3f8891e9-513a-4e91-b0b6-ac9aabbbf6d2"

headers = {
        "Content-Type": "application/json",
        "Signature": "pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c="
}

response = requests.request("GET", url, headers=headers)

print(response.text)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://ats.withhive.com/api/translate/async/result/3f8891e9-513a-4e91-b0b6-ac9aabbbf6d2")
    .get()
    .addHeader("Content-Type", "application/json")
    .addHeader("Signature", "pczeZ91N/ijDBZ80ktNdTDPhnmEK98a3AIsTui46o9c=")
    .build();

Response response = client.newCall(request).execute();

Response example

{
    "result": {
            "code": 200,
            "msg": "Success"
    },
    "content": {
            "status": {
                    "code": 100,
                    "msg": "completed"
            },
            "data": {
                    "translateMsg": [
                            {
                                    "translations": [
                                            {
                                                    "text": "# Markdown 치트 시트\r\n\r\n......",
                                                    "to": "ko"
                                            },
                                            {
                                                    "text": "# Markdownチートシート\r\n\r\n......",
                                                    "to": "ja"
                                            },
                                            {
                                                    "text": "# Markdown 備忘單\r\n\r\n......",
                                                    "to": "zh-hant"
                                            }
                                    ]
                            }
                    ]
            }
    }
}