Get Metadata Task
curl --request GET \
--url https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}import requests
url = "https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
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.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"task_id": "task_abc123xyz",
"status": "completed",
"progress": 100,
"created_at": "2023-11-07T05:31:56Z",
"completed_at": "2023-11-07T05:31:56Z",
"result": {
"events": [
{}
],
"metadata_url": "<string>",
"video_duration_sec": 123,
"events_detected": 123,
"processing_stats": {
"frames_processed": 123,
"processing_time_sec": 123,
"fps": 123
}
},
"error": {
"code": "PROCESSING_FAILED",
"message": "Failed to process video: invalid format"
}
}{
"detail": "<string>"
}{
"detail": "<string>"
}Metadata Extraction
Get Metadata Task
Poll metadata extraction task status and retrieve results
GET
/
api
/
v1
/
sports
/
extract-metadata
/
{task_id}
Get Metadata Task
curl --request GET \
--url https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}import requests
url = "https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}"
req, _ := http.NewRequest("GET", url, nil)
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.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usenarrative.ai/api/v1/sports/extract-metadata/{task_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"task_id": "task_abc123xyz",
"status": "completed",
"progress": 100,
"created_at": "2023-11-07T05:31:56Z",
"completed_at": "2023-11-07T05:31:56Z",
"result": {
"events": [
{}
],
"metadata_url": "<string>",
"video_duration_sec": 123,
"events_detected": 123,
"processing_stats": {
"frames_processed": 123,
"processing_time_sec": 123,
"fps": 123
}
},
"error": {
"code": "PROCESSING_FAILED",
"message": "Failed to process video: invalid format"
}
}{
"detail": "<string>"
}{
"detail": "<string>"
}GET /api/v1/sports/extract-metadata/
Poll the status of a metadata extraction task and retrieve results when complete.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| task_id | string | Yes | The task ID returned from the create request |
Response
| Field | Description |
|---|---|
| task_id | Task identifier |
| status | Current status: pending, processing, completed, failed |
| progress | Progress percentage (0-100) |
| created_at | When the task was created |
| completed_at | When the task completed (if finished) |
| result | Extracted metadata (when status=completed) |
| error | Error details (when status=failed) |
Example Request
curl https://api.usenarrative.ai/api/v1/sports/extract-metadata/task_abc123xyz
Example Response (Processing)
{
"task_id": "task_abc123xyz",
"status": "processing",
"progress": 45,
"created_at": "2024-01-15T10:30:00Z",
"completed_at": null,
"result": null,
"error": null
}
Example Response (Completed)
{
"task_id": "task_abc123xyz",
"status": "completed",
"progress": 100,
"created_at": "2024-01-15T10:30:00Z",
"completed_at": "2024-01-15T10:35:00Z",
"result": {
"events": [
{
"event_type": "play_start",
"timestamp_sec": 125.5,
"game_clock": "12:35",
"home_score": 7,
"away_score": 3
},
{
"event_type": "score_change",
"timestamp_sec": 892.4,
"game_clock": "8:15",
"home_score": 14,
"away_score": 3
}
],
"metadata_url": "https://cdn.usenarrative.ai/metadata/events_abc123.json",
"video_duration_sec": 7200,
"events_detected": 142,
"processing_stats": {
"frames_processed": 108000,
"processing_time_sec": 245.5,
"fps": 30.0
}
},
"error": null
}
Example Response (Failed)
{
"task_id": "task_abc123xyz",
"status": "failed",
"progress": 23,
"created_at": "2024-01-15T10:30:00Z",
"completed_at": "2024-01-15T10:31:00Z",
"result": null,
"error": {
"code": "PROCESSING_FAILED",
"message": "Failed to process video: invalid format"
}
}
Polling Strategy
Recommended polling intervals:- First minute: every 5 seconds
- After 1 minute: every 15 seconds
- After 5 minutes: every 30 seconds
Using Results with Highlights
The extracted metadata can be passed to the Generate Highlights endpoint for enhanced accuracy:# Download metadata
curl -o metadata.json "https://cdn.usenarrative.ai/metadata/events_abc123.json"
# Use with highlights generation
curl -X POST https://api.usenarrative.ai/api/v1/sports/highlights \
-F "video=@game.mp4" \
-F "metadata=@metadata.json"
Path Parameters
The task ID returned from the create request
Response
Task status retrieved
Task identifier
Example:
"task_abc123xyz"
Current task status
Available options:
pending, processing, completed, failed Example:
"completed"
Progress percentage (0-100)
Required range:
0 <= x <= 100Example:
100
When the task was created
When the task completed (if finished)
Show child attributes
Show child attributes
Show child attributes
Show child attributes

