Get Video Analytics

API URL

Please note that the API URL for video uploads is stats.dyntube.com and not api.dyntube.com.

To get the analytics data

POST https://stats.dyntube.com/v1/logs/data

The content type of the HTTP request should be application/json.

Request Body

Name
Type
Description

to

Date

Format: 2021-08-02T00:00:00

page

Integer

Page number

from*

Date

Format: 2021-08-01T00:00:00

size

Integer

Page size

{
    "pager": {
        "page": 1,
        "size": 12,
        "hits": 12,
        "total": 1300,
        "pages": 109
    },
    "views": [
        {
            "id": "NZDSFhZ2",
            "videoKey": "NN8GgcLjTsbUg",
            "accountKey": "8t9ym1JSJuCZg",
            "projectKey": "5lCohVbzSymGw",
            "channelKey": "tEOqkbUhB6NOw",
            "channelViewId": "NggYmvRvw",
            "clientUserId": "abc123",
            "planType": 1,
            "viewerId": "kQdFThzl6e0",
            "viewId": "8LsRTyu2S",
            "date": "2020-08-01T12:42:14.08+00:00",
            "region": "use-s",
            "started": true,
            "ended": false,
            "muted": false,
            "duration": 150,
            "watchTime": 0,
            "browser": {
                "family": "Firefox",
                "major": 82,
                "minor": 0
            },
            "device": {
                "family": "Other",
                "brand": "",
                "model": "",
                "type": "Desktop"
            },
            "os": {
                "family": "Windows",
                "major": 10,
                "processor": "x64"
            },
            "geo": {
                "ip": "121.121.60.0",
                "city": "Kuala Lumpur",
                "country": "MY",
                "region": "Kuala Lumpur",
                "continent": "AS"
            },
            "embed": {
                "url": "https://www.dyntube.com/",
                "domain": "www.dyntube.com",
                "type": 1
            },
            "userKey": ""
        }
		
    ]
}

Sample Response

The clientUserId field in the response is the user id that is set by your system if this option is available in your plan.

{
    "pager": {
        "page": 1,
        "size": 2,
        "hits": 2,
        "total": 2772,
        "pages": 1386
    },
    "views": [
        {
            "id": "qgoJ4",
            "videoKey": "SSq2AQZWw",
            "accountKey": "8t901SJuCZg",
            "projectKey": "5lCohjimGw",
            "channelKey": "4mSULApQ",
            "channelViewId": "fbOooa",
            "clientUserId": "abc123",
            "planType": 1,
            "viewerId": "8Vc0uC",
            "viewId": "ST-J4B",
            "date": "2022-06-01T03:40:50.291+00:00",
            "region": "use-s",
            "started": true,
            "ended": false,
            "muted": false,
            "duration": 51,
            "watchTime": 10,
            "browser": {
                "family": "Chrome",
                "major": 102,
                "minor": 0
            },
            "device": {
                "family": "Other",
                "brand": "",
                "model": "",
                "type": "Desktop"
            },
            "os": {
                "family": "Windows",
                "major": 10,
                "processor": "x64"
            },
            "geo": {
                "ip": "140.213.211.0",
                "city": "Bekasi",
                "country": "ID",
                "region": "West Java",
                "continent": "AS"
            },
            "embed": {
                "url": "https://encrypted.dyntube.io/",
                "domain": "encrypted.dyntube.io",
                "type": 1
            }
        },
        {
            "id": "am4k",
            "videoKey": "Sh41Cg",
            "accountKey": "8t901CZg",
            "projectKey": "1WfhqKLQ",
            "channelKey": "RaFQ3sg",
            "channelViewId": "rdBM",
            "clientUserId": "abc123",
            "planType": 1,
            "viewerId": "WvHF1",
            "viewId": "8GVokX",
            "date": "2022-06-01T02:28:00.56+00:00",
            "region": "usw-s",
            "started": true,
            "ended": true,
            "muted": false,
            "duration": 90,
            "watchTime": 60,
            "browser": {
                "family": "Chrome",
                "major": 101,
                "minor": 0
            },
            "device": {
                "family": "Other",
                "brand": "",
                "model": "",
                "type": "Desktop"
            },
            "os": {
                "family": "Windows",
                "major": 10,
                "processor": "x64"
            },
            "geo": {
                "ip": "190.117.63.0",
                "city": "Chiclayo",
                "country": "PE",
                "region": "Lambayeque",
                "continent": "SA"
            },
            "embed": {
                "url": "https://play.dyntube.io/videos/6OkgQ",
                "domain": "play.dyntube.io",
                "type": 1
            },
            "userKey": ""
        }
    ]
}

Code Samples

C#

using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string from = "2020-08-01";
        string to = "2020-09-30";
        int size = 20;
        int page = 1;
        string videoKey = "";
        string channelKey = "";
        string projectKey = "";

        string url = $"https://stats.dyntube.com/v1/logs/data?from={from}&to={to}&size={size}&page={page}";

        if (!string.IsNullOrEmpty(videoKey))
            url += $"&videoKey={videoKey}";

        if (!string.IsNullOrEmpty(channelKey))
            url += $"&channelKey={channelKey}";

        if (!string.IsNullOrEmpty(projectKey))
            url += $"&projectKey={projectKey}";

        using (var httpClient = new HttpClient())
        {
            var response = await httpClient.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                string json = await response.Content.ReadAsStringAsync();
                Console.WriteLine(json);
            }
            else
            {
                Console.WriteLine($"Failed to get analytics. Status code: {response.StatusCode}");
            }
        }
    }
}

Node.js

const https = require('https');

const options = {
  hostname: 'stats.dyntube.com',
  path: '/v1/logs/data',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, res => {
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', d => {
    process.stdout.write(d);
  });
});

req.on('error', error => {
  console.error(error);
});

const requestBody = JSON.stringify({
  "from":"2020-08-01",
  "to":"2020-09-30",
  "size":20,
  "page":1,
  "videoKey":"",
  "channelKey":"",
  "projectKey":""
});

req.write(requestBody);
req.end();
ja

Python

import requests
import json

url = 'https://stats.dyntube.com/v1/logs/data'
payload = {
    'from': '2022-01-01',
    'to': '2022-12-31',
    'size': 20,
    'page': 1,
    'videoKey': '',
    'channelKey': '',
    'projectKey': '',
}
headers = {
    'Content-Type': 'application/json'
}
response = requests.post(url, data=json.dumps(payload), headers=headers)

if response.status_code == 200:
    data = response.json()
    # do something with the data
else:
    print(f"Failed to get analytics data. Status code: {response.status_code}")

PHP

<?php

$url = "https://stats.dyntube.com/v1/logs/data";

$params = [
    'from' => '2020-08-01',
    'to' => '2020-09-30',
    'size' => 20,
    'page' => 1,
    'videoKey' => '', //optional
    'channelKey' => '', //optional
    'projectKey' => '', //optional
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);

Last updated