API Directory › Integrate with PHP

Integrate BetterVideo with PHP

A working PHP example that submits a video for enhancement, polls the job to completion, and returns the time-limited download link — against the live BetterVideo API.

🔒 Footage deleted on your schedule — with a certificate to prove it

<?php
$API = "https://api.bettervideo.io/v1";
$KEY = "bv_live_your_key_here";

function bv($method, $url, $key, $body = null) {
    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_HTTPHEADER     => ["Authorization: Bearer $key", "Content-Type: application/json"],
        CURLOPT_RETURNTRANSFER => true,
    ]);
    if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    $out = curl_exec($ch);
    curl_close($ch);
    return json_decode($out, true);
}

// 1. Submit a video for enhancement
$job = bv("POST", "$API/jobs", $KEY, [
    "video_url"  => "https://example.com/clip.mp4",
    "resolution" => "1080p",
]);

// 2. Poll until the job is done
while (in_array($job["status"], ["queued", "running"])) {
    sleep(3);
    $job = bv("GET", "$API/jobs/{$job['id']}", $KEY);
}

// 3. Fetch the time-limited download link
if ($job["status"] === "done") {
    $result = bv("GET", "$API/jobs/{$job['id']}/result", $KEY);
    echo "Enhanced video: " . $result["download_url"] . "\n";
} else {
    echo "Job failed: " . $job["error"] . "\n";
}

Uses PHP's built-in cURL extension. Base URL https://api.bettervideo.io/v1 · auth Authorization: Bearer bv_live_…. Grab a free sandbox key from the developer console.

What the code does

  1. SubmitPOST /v1/jobs with a public video_url and a resolution (1080p or 4k).
  2. PollGET /v1/jobs/{id} until status is done (or error). Prefer a signed webhook_url in production instead of polling.
  3. DownloadGET /v1/jobs/{id}/result returns a time-limited download_url. DELETE /v1/jobs/{id} removes it on demand.
See how BetterVideo compares to other video APIs →

Start building in PHP

Free sandbox key, no card — build the whole integration before you spend anything.

Get your API key →