Lilt API binding for java
All URIs are relative to https://api.lilt.com
Method | HTTP request | Description |
---|---|---|
batchTranslateFile | POST /v2/translate/file | Translate a File |
downloadFile | GET /v2/translate/files | Download translated file |
monitorFileTranslation | GET /v2/translate/file | Monitor file translation |
translateSegmentPost | POST /v2/translate | Translate a segment |
List<TranslationInfo> batchTranslateFile(fileId, memoryId, configId, withTM)
Translate a File
Start machine translation of one or more Files that have previously been uploaded. The response will include an `id` parameter that can be used to monitor and download the translations in subsequent calls. Example CURL: ```bash curl -X POST 'https://api.lilt.com/v2/translate/file?key=API_KEY&fileId=583&memoryId=2495&configId=123&withTM=true' ```
// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.TranslateApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.lilt.com");
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: BasicAuth
HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
BasicAuth.setUsername("YOUR USERNAME");
BasicAuth.setPassword("YOUR PASSWORD");
TranslateApi apiInstance = new TranslateApi(defaultClient);
String fileId = "fileId_example"; // String | List of File ids to be translated, comma separated.
String memoryId = "memoryId_example"; // String | Id of Memory to use in translation.
BigDecimal configId = new BigDecimal(78); // BigDecimal | An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file.
Boolean withTM = true; // Boolean | An optional boolean parameter to toggle the use of Translation Memory in the translation of the file.
try {
List<TranslationInfo> result = apiInstance.batchTranslateFile(fileId, memoryId, configId, withTM);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TranslateApi#batchTranslateFile");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
fileId | String | List of File ids to be translated, comma separated. | |
memoryId | String | Id of Memory to use in translation. | |
configId | BigDecimal | An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file. | [optional] |
withTM | Boolean | An optional boolean parameter to toggle the use of Translation Memory in the translation of the file. | [optional] |
| Status code | Description | Response headers | |————-|————-|——————| 200 | Translation Info | - | 401 | Unauthorized | - | 0 | Unexpected error | - |
byte[] downloadFile(id)
Download translated file
Download a translated File. Example CURL: ```bash curl -X GET 'https://api.lilt.com/v2/translate/files?key=API_KEY&id=1' ```
// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.TranslateApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.lilt.com");
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: BasicAuth
HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
BasicAuth.setUsername("YOUR USERNAME");
BasicAuth.setPassword("YOUR PASSWORD");
TranslateApi apiInstance = new TranslateApi(defaultClient);
String id = "id_example"; // String | A translation id.
try {
byte[] result = apiInstance.downloadFile(id);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TranslateApi#downloadFile");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
id | String | A translation id. |
byte[]
| Status code | Description | Response headers | |————-|————-|——————| 200 | A file. | - | 401 | Unauthorized | - | 0 | Unexpected error | - |
List<TranslationInfo> monitorFileTranslation(translationIds, status, fromTime, toTime)
Monitor file translation
Get information about the one or more Files that are being translated with machine translation. Query filters are optional but at least one must be provided. Example CURL: ```bash curl -X GET 'https://api.lilt.com/v2/translate/file?key=API_KEY&translationIds=1,2&fromTime=1607966744&toTime=1707966744&status=InProgress' ```
// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.TranslateApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.lilt.com");
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: BasicAuth
HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
BasicAuth.setUsername("YOUR USERNAME");
BasicAuth.setPassword("YOUR PASSWORD");
TranslateApi apiInstance = new TranslateApi(defaultClient);
String translationIds = "translationIds_example"; // String | List of translation ids, comma separated
String status = "status_example"; // String | One of the translation statuses - `InProgress`, `Completed`, `Failed`, `ReadyForDownload`
BigDecimal fromTime = new BigDecimal(78); // BigDecimal | Results after this time (inclusive) will be returned, specified as seconds since the Unix epoch.
BigDecimal toTime = new BigDecimal(78); // BigDecimal | Results before this time (exclusive) will be returned, specified as seconds since the Unix epoch.
try {
List<TranslationInfo> result = apiInstance.monitorFileTranslation(translationIds, status, fromTime, toTime);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TranslateApi#monitorFileTranslation");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
translationIds | String | List of translation ids, comma separated | [optional] |
status | String | One of the translation statuses - `InProgress`, `Completed`, `Failed`, `ReadyForDownload` | [optional] |
fromTime | BigDecimal | Results after this time (inclusive) will be returned, specified as seconds since the Unix epoch. | [optional] |
toTime | BigDecimal | Results before this time (exclusive) will be returned, specified as seconds since the Unix epoch. | [optional] |
| Status code | Description | Response headers | |————-|————-|——————| 200 | Translation Info | - | 401 | Unauthorized | - | 0 | Unexpected error | - |
TranslationList translateSegmentPost(body)
Translate a segment
Translate a source string. Setting the `rich` parameter to `true` will change the response format to include additional information about each translation including a model score, word alignments, and formatting information. The rich format can be seen in the example response on this page. By default, this endpoint also returns translation memory (TM) fuzzy matches, along with associated scores. Fuzzy matches always appear ahead of machine translation output in the response. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys.
// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.TranslateApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.lilt.com");
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: BasicAuth
HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
BasicAuth.setUsername("YOUR USERNAME");
BasicAuth.setPassword("YOUR PASSWORD");
TranslateApi apiInstance = new TranslateApi(defaultClient);
TranslateSegmentBody body = new TranslateSegmentBody(); // TranslateSegmentBody |
try {
TranslationList result = apiInstance.translateSegmentPost(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TranslateApi#translateSegmentPost");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
body | TranslateSegmentBody | [optional] |
| Status code | Description | Response headers | |————-|————-|——————| 200 | A TranslationList object. | - | 401 | Unauthorized | - | 0 | Unexpected error | - |