API Directory › Integrate with Java
Integrate BetterVideo with Java
A working Java 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
import java.net.URI;
import java.net.http.*;
public class BetterVideo {
static final String API = "https://api.bettervideo.io/v1";
static final String KEY = "bv_live_your_key_here";
static final HttpClient client = HttpClient.newHttpClient();
static String send(String method, String path, String body) throws Exception {
HttpRequest.Builder b = HttpRequest.newBuilder()
.uri(URI.create(API + path))
.header("Authorization", "Bearer " + KEY)
.header("Content-Type", "application/json");
b = (body == null) ? b.GET() : b.POST(HttpRequest.BodyPublishers.ofString(body));
return client.send(b.build(), HttpResponse.BodyHandlers.ofString()).body();
}
public static void main(String[] args) throws Exception {
// 1. Submit a video for enhancement
String job = send("POST", "/jobs",
"{\"video_url\":\"https://example.com/clip.mp4\",\"resolution\":\"1080p\"}");
String id = job.split("\"id\":\"")[1].split("\"")[0];
// 2. Poll until the job is done
String status;
do {
Thread.sleep(3000);
job = send("GET", "/jobs/" + id, null);
status = job.split("\"status\":\"")[1].split("\"")[0];
} while (status.equals("queued") || status.equals("running"));
// 3. Fetch the time-limited download link
if (status.equals("done")) {
System.out.println(send("GET", "/jobs/" + id + "/result", null));
}
}
}Java 11+ (java.net.http). Use a JSON library (Jackson/Gson) in production; kept minimal here. 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
- Submit —
POST /v1/jobswith a publicvideo_urland aresolution(1080por4k). - Poll —
GET /v1/jobs/{id}untilstatusisdone(orerror). Prefer a signedwebhook_urlin production instead of polling. - Download —
GET /v1/jobs/{id}/resultreturns a time-limiteddownload_url.DELETE /v1/jobs/{id}removes it on demand.
Start building in Java
Free sandbox key, no card — build the whole integration before you spend anything.
Get your API key →