HappyHorse
Récupérer une vidéo HappyHorse
Récupérez une tâche vidéo HappyHorse par ID de tâche, y compris le statut, la progression, les horodatages et l’URL de la vidéo terminée.
GET
/
v1
/
videos
/
{task_id}
cURL
curl https://api.cometapi.com/v1/videos/<TASK_ID> \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
TASK_ID = "<TASK_ID>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
terminal_statuses = {"completed", "failed", "error"}
while True:
response = requests.get(
f"https://api.cometapi.com/v1/videos/{TASK_ID}",
headers=headers,
timeout=60,
)
response.raise_for_status()
task = response.json()
print(task["status"], task.get("progress"))
if task["status"] in terminal_statuses:
print(task.get("video_url"))
break
time.sleep(10)
const TASK_ID = "<TASK_ID>";
const terminalStatuses = new Set(["completed", "failed", "error"]);
while (true) {
const response = await fetch(
`https://api.cometapi.com/v1/videos/${TASK_ID}`,
{ headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` } },
);
const task = await response.json();
console.log(task.status, task.progress);
if (terminalStatuses.has(task.status)) {
console.log(task.video_url);
break;
}
await new Promise((resolve) => setTimeout(resolve, 10_000));
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/v1/videos/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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://api.cometapi.com/v1/videos/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
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://api.cometapi.com/v1/videos/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/v1/videos/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "task_example",
"model": "happyhorse-1.0",
"object": "video",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}Utilisez ce point de terminaison après avoir créé une tâche vidéo HappyHorse. Il renvoie l’état de la tâche et inclut
video_url une fois la tâche terminée.
Vérifiez ces champs
statusvous indique si la tâche estqueued,in_progress,completed,failedouerror.progressest un pourcentage approximatif d’achèvement.video_urlapparaît dans les réponses terminées.errorapparaît lorsqu’une tâche échoue.
Flux d’interrogation
1
Créer d’abord la tâche
Commencez par Create a HappyHorse video et stockez l’
id renvoyé.2
Interroger par ID de tâche
Envoyez l’ID de tâche à ce point de terminaison jusqu’à ce que
status atteigne completed, failed ou error.3
Télécharger le fichier MP4
Lorsque
status est completed, appelez Retrieve HappyHorse video content.Réponse
Current HappyHorse video task state.
Dernière modification le 23 juin 2026
⌘I
cURL
curl https://api.cometapi.com/v1/videos/<TASK_ID> \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
TASK_ID = "<TASK_ID>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
terminal_statuses = {"completed", "failed", "error"}
while True:
response = requests.get(
f"https://api.cometapi.com/v1/videos/{TASK_ID}",
headers=headers,
timeout=60,
)
response.raise_for_status()
task = response.json()
print(task["status"], task.get("progress"))
if task["status"] in terminal_statuses:
print(task.get("video_url"))
break
time.sleep(10)
const TASK_ID = "<TASK_ID>";
const terminalStatuses = new Set(["completed", "failed", "error"]);
while (true) {
const response = await fetch(
`https://api.cometapi.com/v1/videos/${TASK_ID}`,
{ headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` } },
);
const task = await response.json();
console.log(task.status, task.progress);
if (terminalStatuses.has(task.status)) {
console.log(task.video_url);
break;
}
await new Promise((resolve) => setTimeout(resolve, 10_000));
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/v1/videos/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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://api.cometapi.com/v1/videos/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
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://api.cometapi.com/v1/videos/{task_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/v1/videos/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "task_example",
"model": "happyhorse-1.0",
"object": "video",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}