Guide
Documents
Translation
This example shows how to translate a document.
Deprecated: This route is deprecated, and will be removed in future releases.
If you want to translate documents, use the Batch Translation route
The TextReveal® HTTP API exposes an
endpoint named documents/translate
that translates a document’s text and/or title into the desired language.
Parameters
name | type | description |
---|---|---|
document_id | string | The document id, it can be found in TextReveal® Dashboards.
|
fields | List[string] | Fields to translate.
|
language | string | The language in which you want the document to be translated.
|
extracted | date | Extraction date of the document. Using ISO 8601 format. If absent the most recent document will be used. |
Usage
Request body
BODY
{
"document_id": "c34ac671a1b0b80078f9acd7e80217e28e8c554e14e1de707fb4370e52299add",
"extracted": "2022-12-30T22:59:57.502Z",
"fields": [
"title",
"text"
],
"language": "french"
}
Response
RESPONSE
{
"partial": false,
"title": "title of the document translated in french",
"text": "text of the document translated in french"
}
The access to premium document's text is forbidden event after translating it, but users still can access to the title of these documents.
Request body with premium document
BODY
{
"document_id": "1454343030016",
"extracted": "2022-12-31T23:59:47.000Z",
"fields": [
"title",
"text"
],
"language": "french"
}
Response
RESPONSE
{
"statusCode": 200,
"message": "Forbidden – Access to the data is denied",
"title": "title of the document translated in french",
"id": "1454343030016",
"error": "The download of licensed text is not allowed."
}
Error handling
We raise error an error in the following cases:
- The user’s company is out of quota:
- Each company can translate up to 10.000 documents. This quota is defined in the company license.
- We return a 403 error with all information in headers in this case.
- The document is not found or his language is not supported:
- This document is still counted in the quota.
Partial translation
When a document's text or title reaches a length of 10,000 bytes, only the first 10,000 bytes are translated.
- This limit is lowered depending on the content of the document, to avoid sentence breaks.
- If a sentence reaches the 10,000 bytes limit, it is ignored.
- If there is no sentence with less than 10.000 bytes, an error is thrown.
When a partial translation is done, the returned document will contain "partial": true