Export Transcription
π€ Export Transcription Content
The Transkriptor Export API allows you to retrieve transcription results with customizable options. Choose from different formats and control metadata settings to tailor your exports for your specific needs.
- π TXT: Basic text format for easy editing.
- π₯π¬ SRT: Subtitles with timestamps for video use.
- π PDF: Platform-independent formatted document.
- π DOCX: Editable Microsoft Word document.
Parameter Guidelines
- 'order_id': The specific order number of the transcription request.
- 'export_type': Format for the transcript export, such as pdf, srt, txt, or docx.
- 'include_speaker_names': Boolean ('True'/'False') to include speaker labels.
- 'include_timestamps': Boolean ('True'/'False') to add timestamps to text segments.
- 'merge_same_speaker_segments': Boolean ('True'/'False') to combine segments from the same speaker.
- 'is_single_paragraph': Boolean ('True'/'False') to output as a single paragraph.
- 'paragraph_size': Paragraph length control, options include 1, 2, 4, or 8 sentences.
These options allow you to customize transcription exports, making them suitable for a variety of applications and workflows.
import requests
import json
# Replace with your API key
api_key = "your_api_key"
# Replace with order ID
order_id = "your_order_id"
# Define the API endpoint
api_url = f"https://api.tor.app/developer/files/{order_id}/content/export"
# Set up the payload with parameters
payload = {
"export_type": "pdf",
"include_speaker_names": True,
"include_timestamps": True,
"merge_same_speaker_segments": False,
"is_single_paragraph": False,
"paragraph_size": 1,
}
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
"Accept": "application/json",
}
# Make the POST request
response = requests.post(api_url, json=payload, headers=headers)
# Check if the response status code indicates success
if response.status_code == 200:
# Parse the JSON response body
response_data = response.json()
# Extract the pre-signed URL
presigned_url = response_data.get("presigned_url")
print("Pre-Signed URL:", presigned_url)
# Extract and print the content
content = response_data.get("content")
print("Content:", content)
elif response.status_code == 202:
print("Transcription is still processing. Please try again later.")
else:
print("Failed to get a valid response:", response.status_code)
print("Response Body:", response.text)
const axios = require('axios');
const apiKey = 'your_api_key';
const orderId = 'your_order_id';
const apiUrl = `https://api.tor.app/developer/files/${orderId}/content/export`;
const payload = {
export_type: "pdf",
include_speaker_names: true,
include_timestamps: true,
merge_same_speaker_segments: false,
is_single_paragraph: false,
paragraph_size: 1
};
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
axios.post(apiUrl, payload, { headers })
.then(response => {
if (response.status === 200) {
console.log("Pre-Signed URL:", response.data.presigned_url);
console.log("Content:", response.data.content);
} else if (response.status === 202) {
console.log("Transcription is still processing. Please try again later.");
}
})
.catch(error => {
console.error("Failed to get a valid response:", error.response ? error.response.status : error.message);
console.error("Response Body:", error.response ? error.response.data : null);
});
import okhttp3.*;
import org.json.JSONObject;
public class ExportFileContent {
private static final String API_KEY = "your_api_key";
private static final String ORDER_ID = "your_order_id";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String apiUrl = "https://api.tor.app/developer/files/" + ORDER_ID + "/content/export";
JSONObject payload = new JSONObject();
payload.put("export_type", "pdf");
payload.put("include_speaker_names", true);
payload.put("include_timestamps", true);
payload.put("merge_same_speaker_segments", false);
payload.put("is_single_paragraph", false);
payload.put("paragraph_size", 1);
RequestBody body = RequestBody.create(payload.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(apiUrl)
.post(body)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject responseData = new JSONObject(response.body().string());
Syst
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
private static readonly string orderId = "your_order_id";
public static async Task Main()
{
var client = new HttpClient();
var apiUrl = $"https://api.tor.app/developer/files/{orderId}/content/export";
var payload = new
{
export_type = "pdf",
include_speaker_names = true,
include_timestamps = true,
merge_same_speaker_segments = false,
is_single_paragraph = false,
paragraph_size = 1
};
var jsonPayload = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.PostAsync(apiUrl, jsonPayload);
if (response.IsSuccessStatusCode)
{
var responseData = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<JsonDocument>(responseData);
Console.WriteLine("Pre-Signed URL: " + data.RootElement.GetProperty("presigned_url"));
Console.WriteLine("Content: " + data.RootElement.GetProperty("content"));
}
else if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
{
Console.WriteLine("Transcription is still processing. Please try again later.");
}
else
{
Console.WriteLine("Failed to get a valid response: " + response.StatusCode);
Console.WriteLine("Response Body: " + await response.Content.ReadAsStringAsync());
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const (
apiKey = "your_api_key"
orderId = "your_order_id"
)
func main() {
apiUrl := fmt.Sprintf("https://api.tor.app/developer/files/%s/content/export", orderId)
payload := map[string]interface{}{
"export_type": "pdf",
"include_speaker_names": true,
"include_timestamps": true,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", apiUrl, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println("Pre-Signed URL:", result["presigned_url"])
fmt.Println("Content:", result["content"])
} else if resp.StatusCode == http.StatusAccepted {
fmt.Println("Transcription is still processing. Please try again later.")
} else {
fmt.Printf("Request failed with status: %d\n", resp.StatusCode)
}
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
order_id = "your_order_id"
url = URI("https://api.tor.app/developer/files/#{order_id}/content/export")
payload = {
export_type: "pdf",
include_speaker_names: true,
include_timestamps: true,
merge_same_speaker_segments: false,
is_single_paragraph: false,
paragraph_size: 1,
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = payload.to_json
response = http.request(request)
if response.code.to_i == 200
response_data = JSON.parse(response.body)
puts "Pre-Signed URL: #{response_data['presigned_url']}"
puts "Content: #{response_data['content']}"
elsif response.code.to_i == 202
puts "Transcription is still processing. Please try again later."
else
puts "Failed to get a valid response: #{response.code}"
puts "Response Body: #{response.body}"
end
<?php
$apiKey = "your_api_key";
$orderId = "your_order_id";
$url = "https://api.tor.app/developer/files/$orderId/content/export";
$payload = [
"export_type" => "pdf",
"include_speaker_names" => true,
"include_timestamps" => true,
"merge_same_speaker_segments" => false,
"is_single_paragraph" => false,
"paragraph_size" => 1,
];
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
$responseData = json_decode($response, true);
echo "Pre-Signed URL: " . $responseData['presigned_url'] . "\n";
echo "Content: " . $responseData['content'] . "\n";
} elseif ($httpCode == 202) {
echo "Transcription is still processing. Please try again later.\n";
} else {
echo "Failed to get a valid response: $httpCode\n";
echo "Response Body: $response\n";
}
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val orderId = "your_order_id"
val apiUrl = "https://api.tor.app/developer/files/$orderId/content/export"
val payload = JSONObject()
payload.put("export_type", "pdf")
payload.put("include_speaker_names", true)
payload.put("include_timestamps", true)
payload.put("merge_same_speaker_segments", false)
payload.put("is_single_paragraph", false)
payload.put("paragraph_size", 1)
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(apiUrl)
.post(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
if (response.isSuccessful) {
val responseData = JSONObject(response.body()?.string())
println("Pre-Signed URL: ${responseData.getString("presigned_url")}")
println("Content: ${responseData.getString("content")}")
} else if (response.code() == 202) {
println("Transcription is still processing. Please try again later.")
} else {
println("Failed to get a valid response: ${response.code()}")
println("Response Body: ${response.body()?.string()}")
}
}
}
import Foundation
let apiKey = "your_api_key"
let orderId = "your_order_id"
let apiUrl = URL(string: "https://api.tor.app/developer/files/\(orderId)/content/export")!
var request = URLRequest(url: apiUrl)
request.httpMethod = "POST"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"export_type": "pdf",
"include_speaker_names": true,
"include_timestamps": true,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
let responseData = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
print("Pre-Signed URL:", responseData?["presigned_url"] ?? "N/A")
print("Content:", responseData?["content"] ?? "N/A")
} else if httpResponse.statusCode == 202 {
print("Transcription is still processing. Please try again later.")
} else {
print("Failed to get a valid response: \(httpResponse.statusCode)")
print("Response Body:", String(data: data, encoding: .utf8) ?? "N/A")
}
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
const orderId = 'your_order_id';
final url = Uri.parse('https://api.tor.app/developer/files/$orderId/content/export');
final payload = jsonEncode({
"export_type": "pdf",
"include_speaker_names": true,
"include_timestamps": true,
"merge_same_speaker_segments": false,
"is_single_paragraph": false,
"paragraph_size": 1,
});
final request = await HttpClient().postUrl(url)
..headers.set('Content-Type', 'application/json')
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
final responseData = jsonDecode(responseBody);
print("Pre-Signed URL: ${responseData['presigned_url']}");
print("Content: ${responseData['content']}");
} else if (response.statusCode == 202) {
print("Transcription is still processing. Please try again later.");
} else {
print("Failed to get a valid response: ${response.statusCode}");
final responseBody = await response.transform(utf8.decoder).join();
print("Response Body: $responseBody");
}
}
Responses
200 OK
{
"statusCode": 200,
"body": {
"presignedUrl": "https://example.com/path/to/resource?signed",
"content": "Extracted text content from the requested file."
}
}
400 Bad Request
{
"statusCode": 400,
"body": "Error: Missing data in event. No 'body' or 'queryStringParameters' provided."
}
{
"statusCode": 400,
"body": "Missing required parameter: orderId."
}
{
"statusCode": 400,
"body": "Invalid exportType. Must be one of: txt, srt, pdf, docx."
}
404 Not Found
{
"statusCode": 404,
"body": "Order with orderId {order_id} not found."
}
500 Internal Server Error
{
"statusCode": 500,
"body": "Internal server error."
}
Updated 10 days ago