Generate embedding for video
curl --request POST \
--url https://api.trytldw.ai/v1/media/embed \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"media_list": [
{
"url": "<string>",
"external_id": "video_12345",
"title": "My Video",
"metadata": {
"location": {
"lat": 1,
"lon": 2
},
"owner_id": "user_123"
}
}
]
}
'import requests
url = "https://api.trytldw.ai/v1/media/embed"
payload = { "media_list": [
{
"url": "<string>",
"external_id": "video_12345",
"title": "My Video",
"metadata": {
"location": {
"lat": 1,
"lon": 2
},
"owner_id": "user_123"
}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
media_list: [
{
url: '<string>',
external_id: 'video_12345',
title: 'My Video',
metadata: {location: {lat: 1, lon: 2}, owner_id: 'user_123'}
}
]
})
};
fetch('https://api.trytldw.ai/v1/media/embed', 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.trytldw.ai/v1/media/embed",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'media_list' => [
[
'url' => '<string>',
'external_id' => 'video_12345',
'title' => 'My Video',
'metadata' => [
'location' => [
'lat' => 1,
'lon' => 2
],
'owner_id' => 'user_123'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trytldw.ai/v1/media/embed"
payload := strings.NewReader("{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trytldw.ai/v1/media/embed")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trytldw.ai/v1/media/embed")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"media_list": [
{
"id": "<string>",
"external_id": "video_12345"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Index or Embed Videos
Generate embedding for video
Generates embeddings for video in the same latent space as text, so that it is possible to perform text-to-video searches by embedding the text and comparing it to the video embeddings. Embedding results can be retrieved from get media endpoint The videos url must be http(s) url to raw video files (e.g. mp4, mov, avi); Youtube web pages or cloud storage services URIs would not work.
POST
/
media
/
embed
Generate embedding for video
curl --request POST \
--url https://api.trytldw.ai/v1/media/embed \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"media_list": [
{
"url": "<string>",
"external_id": "video_12345",
"title": "My Video",
"metadata": {
"location": {
"lat": 1,
"lon": 2
},
"owner_id": "user_123"
}
}
]
}
'import requests
url = "https://api.trytldw.ai/v1/media/embed"
payload = { "media_list": [
{
"url": "<string>",
"external_id": "video_12345",
"title": "My Video",
"metadata": {
"location": {
"lat": 1,
"lon": 2
},
"owner_id": "user_123"
}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
media_list: [
{
url: '<string>',
external_id: 'video_12345',
title: 'My Video',
metadata: {location: {lat: 1, lon: 2}, owner_id: 'user_123'}
}
]
})
};
fetch('https://api.trytldw.ai/v1/media/embed', 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.trytldw.ai/v1/media/embed",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'media_list' => [
[
'url' => '<string>',
'external_id' => 'video_12345',
'title' => 'My Video',
'metadata' => [
'location' => [
'lat' => 1,
'lon' => 2
],
'owner_id' => 'user_123'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trytldw.ai/v1/media/embed"
payload := strings.NewReader("{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trytldw.ai/v1/media/embed")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trytldw.ai/v1/media/embed")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"media_list\": [\n {\n \"url\": \"<string>\",\n \"external_id\": \"video_12345\",\n \"title\": \"My Video\",\n \"metadata\": {\n \"location\": {\n \"lat\": 1,\n \"lon\": 2\n },\n \"owner_id\": \"user_123\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"media_list": [
{
"id": "<string>",
"external_id": "video_12345"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
List of videos to add. Maximum 10 media can be added per request
Show child attributes
Show child attributes
Examples:
{ "external_id": "video_1", "title": "My Video1", "url": "https//example.com/video1.mp4" }
{ "external_id": "video_2", "title": "My Video2", "url": "https//example.com/video2.mp4" }
Response
Successful Response
Show child attributes
Show child attributes
Was this page helpful?
⌘I