Developer API documentation

PHP example

$apiToken = 'YOUR_TOKEN';

$inputFile = fopen('./input.vtt', 'r');

$guzzle = new \GuzzleHttp\Client();

$headers = [
    'Accept' => 'application/json',
    'Authorization' => 'Bearer '.$apiToken,
];

$response = $guzzle->post('https://subtitletools.com/api/v1/convert-to-srt', [
    'http_errors' => false,
    'headers' => $headers,
    'multipart' => [
        [
            'name' => 'subtitle',
            'contents' => $inputFile,
        ],
    ],
]);

$json = json_decode($response->getBody()->getContents());

if ($response->getStatusCode() !== 200 || $json->errors) {
    $message = json_encode($json, JSON_PRETTY_PRINT);

    throw new RuntimeException($message);
}

$outputFilePath = './output.srt';

$guzzle->get($json->download_url, [
    'headers' => $headers,
    'sink' => $outputFilePath,
]);