External programs, legacy systems, programmers using console or API clients can access the full solution functionalities using the generic APIs.
The updated description of APIs can be found at the following repositories:
- https://corporateapi2.docs.apiary.io/# (text processing)
- https://pgfile.docs.apiary.io/# (document processing)
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.
Example: Translate a single sentence
POST endpoint:
https://production_access_server_url:8080/NexRelay/v1/translate
Headers:
Content-Type: application/json
Request Body:
{
"src": "en",
"tgt": "es",
"apikey": "your_api_key",
"engine": "your_engine_id",
"text": [
"This is an example."
]
}
Response Body:
[
[
{
"src": "This is an example.",
"tgt": "Esto es un ejemplo."
}
]
]
Both https and http endpoints are configurable in the Access Server.
Text Translation API
HOST:
http://prod.pangeamt.com:8080/NexRelay/v1/
Request:
{
"apikey": "your-apikey-here"
}
Response:
{
"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 text [/translate]
Process a text segment [POST]
A text segment is usually a sentence with full semantic content.
src
andtgt
are 2-letter language codesengine
is the ID (string) of the enginelossary_id
is optional (integer)
Request:
{
"src": "es",
"tgt": "en",
"apikey": "your-api-key-here",
"engine": "2",
"glossary_id": 1,
"text": [
"¿Cómo estás?",
"Mi perro es negro"
]
}
Response:
[
[
{
"src": "¿Cómo estás?",
"tgt": "How are you?"
}
],
[
{
"src": "Mi perro es negro",
"tgt": "My dog is black"
}
]
]
Document Processing API
HOST:
http://prod.pangeamt.com:8080/PGFile/v1
File Uploading [/sendfile]
Send a File [POST]
Main request to send a file for translation. The response returns a GUID for the file.
Multipart/form-data request:
------WebKitFormBoundary...
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"
}
------WebKitFormBoundary...
Content-Disposition: form-data; name="file"; filename="filename.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
[data]
------WebKitFormBoundary...--
Response 200:
{
"fileId": "8d4e1c5be60d4e04850f55ec135f2554"
}
Response 500:
{
"error": true,
"error_message": "the-error-message"
}
Checking file status [/checkfile?apikey&fileid]
Use /checkfile
to check the status of files. Supports:
Request with only
apikey
to get status of all filesRequest with
guid
to get status of a specific file
GET Examples:
https://server_address:server_port/PGFile/v1/checkfile?apikey=your_api_key
https://server_address:server_port/PGFile/v1/checkfile?apikey=your_api_key&guid=your_guid
Possible status values:
- 10: Queued
- 6 or 7: Analyzing
- 20, 30, 40: Processing
- 100: Processed, ready for download
- 110 or 120: Downloaded
- -10 or -20: Error
Response:
[
{
"fileId": "1dc77dc5ba6d44828b860537dae07187",
"translatedPath": null,
"engineId": 58,
"glossaryId": 0,
"src": "es",
"tgt": "en",
"isZip": false,
"ztot": 0,
"zfinished": 0,
"translatedName": null,
"processName": "translate",
"processOptionId": 1,
"link": "",
"status": 10,
"id": 16567,
"fileName": "test.txt"
}
]
Retrieving and downloading file [/retrievefile]
POST request
Used to get info about a file and download it when ready.
Note: Not recommended for very large files (base64-encoded).
Request:
{
"apikey": "your-api-key-here",
"guid": "1dc77dc5ba6d44828b860537dae07187"
}
Response if file not finished:
{
"success": true,
"error": {},
"status": "10",
"data": {}
}
Response if file finished:
{
"success": true,
"error": {},
"status": "110",
"data": {
"guid": "d74b06fd52434ad2bfbe82ebbff96464",
"fileType": "txt",
"filename": "test.txt",
"file": "U2VlIHRoaW5ncyB0byBkbywgcmVzdGF1cmFudHMsIGFuZCBob3RlbHMNCg=="
}
}
Response 401 (Error):
{
"success": false,
"error": {
"statusCode": 401,
"code": 6,
"message": "Invalid GUID"
},
"data": {}
}
Downloading file [/download?apikey&fileid]
Simple GET request to retrieve a file.
Parameters:
- apikey
fileid
(file GUID)
The file is returned as a stream (e.g., for wget
-like download).
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article