External programs, legacy systems, programmers using console or API clients can access the full solution functionalities using the generic APIs.
Pangeanic’s API is a simple RESTFul implementation where typically the requests are sent as POSTs with a json encoded body. When handling files the content is sent or received in base-64 encoded form.
POST to endpoint: https://production_access_server_url:8080/NexRelay/v1/translate Headers: Content-Type : application/json
{
"src":"en",
"tgt":"es",
"apikey":"your_api_key",
"engine":"your_engine_id",
"text":["This is an example." ]
}
;[{ src: 'This is an example.', tgt: 'Esto es un ejemplo.' }]
Both https and http endpoints are configurable in the Access Server.
HOST: http://prod.pangeamt.com:8080/NexRelay/v1/
List All available engines [POST] This edpoint is required to list the list of IDs of the available engines fo your APIKey + Request (application/json)
{
"apikey": "your-apikey-here"
}
{
"engines": [
{
"id": 1,
"processid": 1,
"serviceid": 1,
"inserviceid": 0,
"src": "en",
"tgt": "es",
"descr":
"ENES_B_plain",
"domain": "",
"flavor": "",
"status": 0
},
{
"id": 2,
"processid": 1,
"serviceid": 2,
"inserviceid": 0,
"src": "es",
"tgt": "en",
"descr":
"ESEN_generic",
"domain": "",
"flavor": "",
"status": 0
}
]
}
Process a text segment [POST] A text segment is a number of words, processing works best if the segment is a sentence with whole semantic content.
{
"src":"es",
"tgt":"en",
"apikey":"your-api-key-here",
"engine":"2",
"glossary_id": 1,
"text": [ "¿Cómo estás?", "Mi perro es negro" ]
}
;[
[
{
src: '¿Cómo estás?',
tgt: 'How are you?',
},
],
[
{
src: 'Mi perro es negro',
tgt: 'My dog is black',
},
],
]
HOST: http://prod.pangeamt.com:8080/PGFile/v1
Main request. Send a file to the service for translation. The process parameters have to be included The success response is a json with file guid.
(multipart/form-data;boundary=----WebKitFormBoundary8M3sSU13ul5lXSJm)
------WebKitFormBoundary8M3sSU13ul5lXSJm
Content-Disposition: form-data;
name="json"
{
"title":"filename.docx",
"processname":"translation",
"engine":"123",
"src":"es",
"tgt": "en" ,
"apikey":"your-apikey-here",
"username": "testuser",
"notiflink": "testlink",
"processoption": "1"
}
------WebKitFormBoundary8M3sSU13ul5lXSJm
Content-Disposition: form-data;
name="file";
filename="filename.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
data ------WebKitFormBoundary8M3sSU13ul5lXSJm--
{
"fileId": "8d4e1c5be60d4e04850f55ec135f2554"
}
{
"error": true,
"error_message" : "the-error-message"
}
Use /checkfile to get the processing status of a file, this is a json post where body can have three forms:
https://server_address:server_port/PGFile/v1/checkfile?apikey=your_api_key
The returned answer is a json list containing one json object for every file. The important field returned for every file is the status, an integer with possible values:
;[
{
fileId: '1dc77dc5ba6d44828b860537dae07187',
translatedPath: None,
engineId: 58,
glossaryId: 0,
src: 'es',
tgt: 'en',
isZip: False,
ztot: 0,
zfinished: 0,
translatedName: None,
processName: 'translate',
processOptionId: 1,
link: '',
status: 10,
id: 16567,
fileName: 'test.txt',
},
]
This is a POST request that can be used to get info about a file that is being processed and download the processed file is process has finished.
WARNING this endpoint is NOT safe for very big files: the file is returned in base64 encoding and requires a lot of memory at server and client side.
When file is finished a 200 response is returned with the file. If file is in processs a 200 response is returned with the status data. Errors will generate a 401 response.
{
"apikey": "your-api-key-here",
"guid": "1dc77dc5ba6d44828b860537dae07187"
}
# response when file is not finished
{
"success": True,
"error": {},
"status": "10",
"data": {}
}
#response when file is finished
{
"success": True,
"error": {},
"status": "110",
"data": {
"guid": "d74b06fd52434ad2bfbe82ebbff96464",
"fileType": "txt",
"filename": "test.txt",
"file": "U2VlIHRoaW5ncyB0byBkbywgcmVzdGF1cmFudHMsIGFuZCBob3RlbHMNCg=="
}
}
{
"success": False,
"error": {
"statusCode": 401,
"code": 6,
"message": "Invalid GUID"
},
"data": {}
}
Simple get request to retrieve a file. The get parameters are:
The file GUID The file is returned as a stream (similar to a call to wget)