Analytics
Get Video Analytics
API URL
Get paginated video analytics data.
POST https://stats.dyntube.com/v1/logs/data
Send the request body as application/json.
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | String | Bearer YOUR_API_KEY |
| Content-Type | String | application/json |
Request Body
| Name | Type | Description |
|---|---|---|
| from* | Date | Required start date. Example: 2021-08-01T00:00:00 |
| to* | Date | Required end date. Example: 2021-08-02T00:00:00 |
| page | Integer | Page number. Defaults to 1 |
| size | Integer | Page size. Defaults to 200 and is capped at 200 |
| videoKey | String | Optional video filter |
| projectKey | String | Optional project filter |
| channelKey | String | Optional channel filter |
| streamKey | String | Optional live stream filter |
200: OK
json
{
"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.
json
{
"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\#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
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}";
var payload = new
{
from,
to,
size,
page,
videoKey,
channelKey,
projectKey
};
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");
var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(url, content);
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
javascript
const axios = require('axios');
async function getAnalytics() {
const payload = {
from: '2020-08-01',
to: '2020-09-30',
size: 20,
page: 1,
videoKey: '',
channelKey: '',
projectKey: ''
};
const res = await axios.post('https://stats.dyntube.com/v1/logs/data', payload, {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
console.log(res.data);
}
getAnalytics().catch(err => {
console.error(err.response?.data || err.message);
});Python
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',
'Authorization': 'Bearer YOUR_API_KEY'
}
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
<?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',
'Authorization: Bearer YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} elseif ($statusCode >= 200 && $statusCode < 300) {
echo $response;
} else {
echo "Failed to get analytics. Status code: {$statusCode}\n";
echo $response;
}
curl_close($ch);Related Pages
- Use your user IDs in analytics to connect playback events to users in your own system.
- Get videos to find videoKey values for filtering analytics.
- Setting up webhooks for event-driven processing outside analytics queries.
Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.