Get Video

API endpoint to fetch a single video

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 a Single Video

This endpoint will return a single video with the provided video Id.

GET https://api.dyntube.com/v1/videos/{id}

Path Parameters

Name
Type
Description

id*

String

Video Id. This is NOT the same as channelKey that is provided in the embed code. This is normally provided in the video list through API or through the dashboard.

{
    "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"
}

C# Sample

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

namespace SingleVideo
{
    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 videoId = "your_video_id";
            var response = await client.GetAsync($"https://api.dyntube.com/v1/videos/{videoId}");

            if (response.IsSuccessStatusCode)
            {
                var responseContent = await response.Content.ReadAsStringAsync();
                var video = JsonSerializer.Deserialize<Video>(responseContent);

                Console.WriteLine("Id: " + video.Id);
                Console.WriteLine("Title: " + video.Title);
                Console.WriteLine("Description: " + video.Description);
                Console.WriteLine("hlsUrl: " + video.HlsUrl);
                Console.WriteLine("hlsUrlWeb: " + video.HlsUrlWeb);
                Console.WriteLine("mp4Url: " + video.Mp4Url);
            }
            else
            {
                Console.WriteLine("Error getting video. Status code: " + response.StatusCode);
            }
        }
    }

    class Video
    {
        public string Id { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string HlsUrl { get; set; }
        public string HlsUrlWeb { get; set; }
        public string Mp4Url { get; set; }
    }
}

Node.js

const axios = require('axios');

const videoId = 'your_video_id';
const bearerToken = 'your_bearer_token';

async function getVideo() {
  try {
    const response = await axios.get(`https://api.dyntube.com/v1/videos/${videoId}`, {
      headers: {
        Authorization: `Bearer ${bearerToken}`
      }
    });
    const video = response.data;
    console.log('Id:', video.id);
    console.log('Title:', video.title);
    console.log('Description:', video.description);
    console.log('hlsUrl:', video.hlsUrl);
    console.log('hlsUrlWeb:', video.hlsUrlWeb);
    console.log('mp4Url:', video.mp4Url);
  } catch (error) {
    console.error(error);
  }
}

getVideo();

Python

import requests

video_id = 'your_video_id'
bearer_token = 'your_bearer_token'
url = f'https://api.dyntube.com/v1/videos/{video_id}'

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

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

if response.status_code == 200:
    video = response.json()
    print('Id:', video['id'])
    print('Title:', video['title'])
    print('Description:', video['description'])
    print('hlsUrl:', video['hlsUrl'])
    print('hlsUrlWeb:', video['hlsUrlWeb'])
    print('mp4Url:', video['mp4Url'])
else:
    print('Error getting video. Status code:', response.status_code)

PHP

<?php
$video_id = 'your_video_id';
$bearer_token = 'your_bearer_token';
$url = "https://api.dyntube.com/v1/videos/{$video_id}";

$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 video: ' . curl_error($ch);
} else {
    $video = json_decode($response, true);
    echo "Id: " . $video['id'] . "\n";
    echo "Title: " . $video['title'] . "\n";
    echo "Description: " . $video['description'] . "\n";
    echo "hlsUrl: " . $video['hlsUrl'] . "\n";
    echo "hlsUrlWeb: " . $video['hlsUrlWeb'] . "\n";
    echo "mp4Url: " . $video['mp4Url'] . "\n";
}

curl_close($ch);
?>

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

Last updated