API Access: Difference between revisions
No edit summary |
No edit summary |
||
Line 165: | Line 165: | ||
] | ] | ||
] | ] | ||
</code> | |||
== Document Processing API == | |||
HOST: http://prod.pangeamt.com:8080/PGFile/v1 | |||
''' File Uploading [/sendfile] ''' | |||
### Send a File [POST] | |||
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. | |||
+ Request | |||
=multipart/form-data;boundary=----WebKitFormBoundary8M3sSU13ul5lXSJm) | |||
<code> | |||
------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-- | |||
''' + Response 200 (application/json) ''' | |||
{ | |||
"fileId": "8d4e1c5be60d4e04850f55ec135f2554" | |||
} |
Revision as of 08:55, 7 February 2022
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) and
- http://prodb.pangeamt.com:8000/docs (anonymization)
- Pecat API (no online repo)
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.
As an example, the API definition for the translation of a single sentence would be:
POST to 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",
"engineid":"your_engine_id",
"text":[
"This is an example."
]
}
Answer Body:
[
[
{
"src": "This is an example.",
"tgt": "Esto es un ejemplo."
}
]
Both https and http endpoints are configurable in the Access Server.
Text Processing API
HOST: http://prod.pangeamt.com:8080/NexRelay/v1/
List Engines [/corp/engines]
- 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"
}
+ Response 200 (application/json)
{
"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 a number of words, processing works best if the segment is a sentence with whole semantic content.
- src and tgt are 2-letter language codes
- engine is the id (string) of the engine to be used
- glossary_id, optional, is the id (integer) of the glossary to be used
+ Request (application/json)
{
"src":"es",
"tgt":"en",
"apikey":"your-api-key-here",
"engine":"2",
"glossary_id": 1,
"text":[
"¿Cómo estás?",
"Mi perro es negro"
]
}
+ Response 200 (application/json)
[
[
{
"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. Send a file to the service for translation.
The process parameters have to be included
The success response is a json with file guid.
+ Request
=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--
+ Response 200 (application/json)
{
"fileId": "8d4e1c5be60d4e04850f55ec135f2554"
}