curl (download translated file)
curl -s \
-H "Authorization: Bearer <token>" \
-H "Accept: application/octet-stream" \
https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/MT_GENERIC_PRETRANSLATE/{targetLang} \
--output translated.txtimport requests
url = "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}"
headers = {
"Accept": "<accept>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Accept: '<accept>', Authorization: 'Bearer <token>'}};
fetch('https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept: <accept>",
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "<accept>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}")
.header("Accept", "<accept>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = '<accept>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"--Boundary_1_1453803947_1691603987728\nContent-Type: application/octet-stream\nContent-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\nPřeložený text\n\n--Boundary_1_1453803947_1691603987728\nContent-Type: application/json\nContent-Disposition: form-data; name=\"metadata\"\n\n{\"sourceLang\":{\"code\":\"en\"},\"targetLangs\":[{\"code\":\"cs\"}],\"actionTypes\":[\"MT_GENERIC_PRETRANSLATE\"],\"callbackUrl\":\"https://your-server.com/send/data/here\"}\n--Boundary_1_1453803947_1691603987728--\n"File translations
Action result
Returns the result of a completed file translation action.
Set the Accept request header to control the response format:
Accept: application/octet-stream— returns the translated (or original) file as binary. Use this to download the translated file.Accept: application/json— returns quality estimation results as JSON. Only meaningful whenactionTypeisQUALITY_ESTIMATION.
To download a translated file, use actionType: MT_GENERIC_PRETRANSLATE with Accept: application/octet-stream. Omitting the Accept header or using a value other than application/octet-stream will not return the file binary.
GET
/
v1
/
fileTranslations
/
{uid}
/
{actionType}
/
{language}
curl (download translated file)
curl -s \
-H "Authorization: Bearer <token>" \
-H "Accept: application/octet-stream" \
https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/MT_GENERIC_PRETRANSLATE/{targetLang} \
--output translated.txtimport requests
url = "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}"
headers = {
"Accept": "<accept>",
"Authorization": "Bearer <token>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Accept: '<accept>', Authorization: 'Bearer <token>'}};
fetch('https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept: <accept>",
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "<accept>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}")
.header("Accept", "<accept>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu.phrase.com/smt/api/v1/fileTranslations/{uid}/{actionType}/{language}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = '<accept>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"--Boundary_1_1453803947_1691603987728\nContent-Type: application/octet-stream\nContent-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\nPřeložený text\n\n--Boundary_1_1453803947_1691603987728\nContent-Type: application/json\nContent-Disposition: form-data; name=\"metadata\"\n\n{\"sourceLang\":{\"code\":\"en\"},\"targetLangs\":[{\"code\":\"cs\"}],\"actionTypes\":[\"MT_GENERIC_PRETRANSLATE\"],\"callbackUrl\":\"https://your-server.com/send/data/here\"}\n--Boundary_1_1453803947_1691603987728--\n"Authorizations
Headers
Media type which caller expects as a response.
Path Parameters
UID of the operation. See File translations endpoint.
File associated with the specified action type will be returned, if the action was completed. Type of file processing action.
FILE_IMPORT— imports the source file into TMS storageCONVERTER_IMPORT— extracts translatable segments from the fileMT_GENERIC_PRETRANSLATE— machine-translates the extracted segments; required for file translationQUALITY_ESTIMATION— computes Phrase Quality Performance Score (QPS) for the MT output
Available options:
CONVERTER_IMPORT, FILE_IMPORT, MT_GENERIC_PRETRANSLATE, QUALITY_ESTIMATION Example:
"MT_GENERIC_PRETRANSLATE"
Requested language of the file. Please note different actions have different languages available.
Was this page helpful?