ELIA - Automatic Machine Translation API

Methods

translate_string [POST]

This method allows authenticated users to translate plain text. Only POST method is allowed.

Request example
{ 
	"api_id" : "<YOUR_API_ID>",
	"api_key" : "<YOUR_API_KEY>",
	"translation_engine" : "nmt" | "apertium" | "apertiumc",
	"translation_model" : "general" | "admin" (default "general"),
	"language_pair" : "es-eu" | "eu-es",
	"content_type" : "txt" | "html" | "xml",
	"text" : "<ORIGINAL_TEXT>",
	"glossaries" : "<GLOSSARY_IDS_COMMA_SEPARATED>"
}
Response example
{ 
	"original_text" : "<ORIGINAL_TEXT>",
	"translated_text" : "<TRANSLATED_TEXT>",
	"glossary_active_words" : "<GLOSSARY_ACT_WORDS>",
	"source_sentences" : "<LIST_OF_SOURCE_SENTS>",
	"translated_sentences" : "<LIST_OF_TRANSLATED_SENTS>",
	"words" : "<WORDS>", #Translated words,
	"execution_time": "73.4", # Execution time in seconds
}
translate_file [POST]

This method allows authenticated users to translate files. Only POST method is allowed. It is an asynchronous method. On successful response, it returns a task_id identifier which allows to check current traslation process status.

Request example
{ 
	"api_id" : "<YOUR_API_ID>",
	"api_key" : "<YOUR_API_KEY>",
	"translation_engine" : "nmt" | "apertium" | "apertiumc",
	"translation_model" : "general" | "admin" (default "general"),
	"language_pair" : "es-eu" | "eu-es",
	"content_type" : "txt" | "docx" | "xlsx" | "pptx" | "odt" | "ods" | "odp" | "html" | "xml" | "xliff" | "txlf",
	"file" : "<POSTED_FILE>",
	"file_md5" : "<POSTED_FILE_MD5_CHECKSUM>",
	"url" : url | null, # If url base should be set in html files,
	"glossaries" : "<GLOSSARY_IDS_COMMA_SEPARATED>"
}
Response example
{ 
	"task_id" : "<TASK_ID>", # Asynchronous task id
}
file [POST]

This method allows authenticated users to check for a particular document translation status. task_id is returned by the translate_file method. Only POST method is allowed.

Request example
{ 
	"api_id" : "<YOUR_API_ID>",
	"api_key" : <YOUR_API_KEY>",
	"task_id" : "<TASK_ID>", # Asynchronous task id
}
Response example Task is running
{
    "finished": False,
    "error": False,
    "percentage": "75",
    "message": "Running translation", # Just an example
}
Task finished without errors. Translation successful
{
	"finished": True,
	"error": False,
	"original_file": "<POSTED_FILE_URL>",
	"trasnlated_file": "<TRANSLATED_FILE_URL>",
	"words": "<WORDS>", #Translated words
	"execution_time": "73.4", # Execution time in seconds
}
Task finished with errors. Unsuccessful translation
{
	"finished": True,
	"error": True,
	"message": "There was an error", # Just an example
}
language_pairs [POST]

This method allows authenticated users to view the allowed language pairs and translation engines. Only POST method is allowed.

Request example
{
        "api_id" : "<YOUR_API_ID>",
        "api_key" : "<YOUR_API_KEY>"
        "translation_model" : undefined | "general" | "admin" (default undefined)
}
Response example
[
    {
        "src": "es",
        "tgt": "eu",
        "engine": "nmt",
        "type": "general"
    },
    {
        "src": "eu",
        "tgt": "es",
        "engine": "nmt",
        "type": "general"
    }			    
]
language_detection [POST]

This method allows authenticated users to detect the language of the text. Only POST method is allowed.

Request example
{
        "api_id" : "<YOUR_API_ID>",
	"api_key" : "<YOUR_API_KEY>",
	"text" : "Esto es una prueba"		   
}
Response example
{
    "text": "esto es una prueba",
    "lang": "es",
    "score": -72.19694900512695
}
glossaries [POST]

This method allows authenticated users to view their current glossaries' id, name and whether they are active or not.

Request example
        			
{
	"api_id" : "<YOUR_API_ID>",
	"api_key" : "<YOUR_API_KEY>"	
}
        			
        		
Response example
        			
glossaries : [
	{
		"id" : "<GLOSSARY_ID>",
		"name" : "<GLOSSARY_NAME>",
		"active" : "False"	
	},
	{
	
		"id" : "<GLOSSARY_ID>",
		"name" : "<GLOSSARY_NAME>",
		"active" : "False"	
	}		
]
			
        		
languages [POST]

This method allows authenticated users to view their available languages and its localizations

Request example
        			
{
	"api_id" : "<YOUR_API_ID>",
	"api_key" : "<YOUR_API_KEY>"	
}
        			
        		
Response example
        			

{
	"languages": [
		{
			"code": es,
			"tts": true,
			"translations": {
				"es": "Castellano",
    	        		"eu": "Gaztelania",
    	        		"en": "Spanish",
    	        		"fr": "Espagnol"
    	        	}
		},
		{
			"code": eu,
			"tts": true,
			"translations": {
				"es": "Euskera",
    	        		"eu": "Euskara",
    	        		"en": "Basque",
    	        		"fr": "Basque"
    	        	}
		},
		...
	]
}