Get Videos

API endpoint to fetch videos

Our API to fetch videos is not optimized for real-time usage within a production environment.

To enhance the efficiency of your video retrieval process, we recommend that you fetch the video links using the API and store them in a database. By employing this method, you can seamlessly access your video links from the database and stream them as needed.

It is important to note that our video API is subject to a rate limit. Therefore, we strongly advise against using it for video retrieval immediately before playback within a production environment.

Get Video List

Get a list of videos. You can filter or sort videos based on optional query string.

GET https://api.dyntube.com/v1/videos

Query Parameters

Name
Type
Description

page

Integer

Page number

size

Integer

Page size

planType

Integer

Type of the plan

sort

String

Sort order of the results. See details below.

projectId

String

Id of the project

tags

String

filter videos by tag name.

region

String

filter videos by region code. e.g. 'usw-s'

{
    "pager": {
        "page": 1,
        "totalPages": 400,
        "totalResults": 400,
        "sort": "Created:-1"
    },
    "videos": [
        {
			"id": "fFL56RU6PjvJPeE",
			"duration": "00:02:30.1270000",
			"projectId": "unjVhFJ7vAhrYu9",
			"accountKey": "6aG9UBe5rGPzjbh",
			"region": "use-s",
			"captions": [],
			"key": "NULPJ7mWDuyj4w5",
			"channelKey": "f8RMr2q4h6yNpv9",
			"privateLink": "QBr6n8HN878t5sH",
			"hlsLink": "Sx5FTtWsUU8tmux",
			"planType": 1,
			"mp4Url": "",
			"mp4Urls": [],
			"formats": {
				"hls": true,
				"mp4": false
			},
			"hlsUrl": "https://api.dyntube.com/v1/apps/hls/FhyinduNY4Kr9Q.m3u8",
			"hlsUrlWeb": "https://api.dyntube.com/v1/live/videos/EruJdgOPsbUg.m3u8",
			"title": "My Video",
			"description": "",
			"options": {
				"autoplay": false,
				"playerColor": "rgba(255, 65, 113, 0.83)",
				"playerSkin": "solid",
				"controlsColor": "#FFFFFF",
				"seekButtons": false,
				"volumeControl": true,
				"preload": "auto",
				"fullscreenControl": true,
				"controls": true,
				"stickyControls": false,
				"defaultQuality": "",
				"qualityControl": true,
				"speedControl": true,
				"fastForward": true,
				"bigPlayControl": true,
				"playControl": true,
				"volume": 1.0,
				"loop": false,
				"muted": false,
				"modal": false
			},
			"tags": [],
			"version": 1,
			"status": 3,
			"created": "2016-08-27T12:37:24.4970796+00:00"
		}
    ]
}

Sorting of results

The sorting order of the videos would be a query sort with a value. the format of the value would be field:1 for ascending order and field:-1 for descending order.

#Here are examples to sort the videos by "Created" date.

#Sort by date created descending:
https://api.dyntube.com/v1/videos?sort=Created:-1

#Sort by date created ascending:
https://api.dyntube.com/v1/videos?sort=Created:1

C# Sample

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;

namespace VideoList
{
    class Program
    {
        private static readonly HttpClient client = new HttpClient();

        static async Task Main(string[] args)
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "your_bearer_token");

            var response = await client.GetAsync("https://api.dyntube.com/v1/videos");

            if (response.IsSuccessStatusCode)
            {
                var responseContent = await response.Content.ReadAsStringAsync();
                var videosResponse = JsonSerializer.Deserialize<VideosResponse>(responseContent);
                foreach (var video in videosResponse.Videos)
                {
                    Console.WriteLine("Id: " + video.Id);
                    Console.WriteLine("Title: " + video.Title);
                    Console.WriteLine("hlsUrl: " + video.HlsUrl);
                    Console.WriteLine("hlsUrlWeb: " + video.HlsUrlWeb);
                    Console.WriteLine("mp4Url: " + video.Mp4Url);
                }
            }
        }
    }

    class VideosResponse
    {
        public Video[] Videos { get; set; }
        public Pager Pager { get; set; }

    }

    class Video
    {
        public string Id { get; set; }
        public string Title { get; set; }
        public string HlsUrl { get; set; }
        public string HlsUrlWeb { get; set; }
        public string Mp4Url { get; set; }
    }
    class Pager
    {
        public int page { get; set; }
        public int totalPages { get; set; }
        public int totalResults { get; set; }
        public string sort { get; set; }
    }

}

Node.js Sample

const axios = require('axios');

async function video_list(bearer_token) {
    try {
        const response = await axios.get("https://api.dyntube.com/v1/videos", {
            headers: {
                Authorization: `Bearer ${bearer_token}`
            }
        });

        const videosResponse = response.data;
        for (const video of videosResponse.videos) {
            console.log("Id: " + video.id);
            console.log("Title: " + video.title);
            console.log("hlsUrl: " + video.hlsUrl);
            console.log("hlsUrlWeb: " + video.hlsUrlWeb);
            console.log("mp4Url: " + video.mp4Url);
        }
        console.log("Page: " + videosResponse.pager.page);
        console.log("Total Pages: " + videosResponse.pager.totalPages);
        console.log("Total Results: " + videosResponse.pager.totalResults);
        console.log("Sort: " + videosResponse.pager.sort);
    } catch (error) {
        console.error(error);
    }
}

video_list('your_bearer_token');

Python

import requests
import json

bearer_token = "your_bearer_token"
url = "https://api.dyntube.com/v1/videos"

headers = {
    "Authorization": f"Bearer {bearer_token}"
}

response = requests.get(url, headers=headers)

if response.status_code == 200:
    videos_response = json.loads(response.text)
    for video in videos_response.videos:
        print("Id:", video.id)
        print("Title:", video.title)
        print("hlsUrl:", video.hlsUrl)
        print("hlsUrlWeb:", video.hlsUrlWeb)
        print("mp4Url:", video.mp4Url)
    print("Page:", videos_response.pager.page)
    print("Total Pages:", videos_response.pager.totalPages)
    print("Total Results:", videos_response.pager.totalResults)
    print("Sort:", videos_response.pager.sort)
else:
    print("Error getting videos. Status code:", response.status_code)y

PHP

<?php
$bearer_token = 'your_bearer_token';
$url = 'https://api.dyntube.com/v1/videos';

$headers = array(
    'Authorization: Bearer ' . $bearer_token
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

if (!$response) {
    echo 'Error getting videos: ' . curl_error($ch);
} else {
    $videos_response = json_decode($response);
    foreach ($videos_response->videos as $video) {
        echo "Id: " . $video->id . "\n";
        echo "Title: " . $video->title . "\n";
        echo "hlsUrl: " . $video->hlsUrl . "\n";
        echo "hlsUrlWeb: " . $video->hlsUrlWeb . "\n";
        echo "mp4Url: " . $video->mp4Url . "\n";
    }
    echo "Page: " . $videos_response->pager->page . "\n";
    echo "Total Pages: " . $videos_response->pager->totalPages . "\n";
    echo "Total Results: " . $videos_response->pager->totalResults . "\n";
    echo "Sort: " . $videos_response->pager->sort . "\n";
}

curl_close($ch);
?>

A video status 3 means that the video is published. See more details here.

Last updated