Skip to main content
POST
/
media
/
Index videos in a collection
curl --request POST \
  --url https://api.trytldw.ai/v1/media/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "collection_id": "<string>",
  "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/"

payload = {
"collection_id": "<string>",
"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({
collection_id: '<string>',
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/', 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/",
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([
'collection_id' => '<string>',
'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/"

payload := strings.NewReader("{\n \"collection_id\": \"<string>\",\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/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collection_id\": \"<string>\",\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/")

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 \"collection_id\": \"<string>\",\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": "<string>"
}
{
"detail": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
collection_id
string
required

The ID of the collection to add the video to

Example:

"c1a2b3c4-1a2b-3c4d-5e6f-7g8h9i0j1k2l"

media_list
NewMediaItem · object[]
required

List of videos to add. Maximum 10 media can be added per request

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

media_list
MediaStub · object[]
required