Get Plans
Get a List of Plans
Get a list of plans. You can filter or sort plans based on optional query string.
GET
https://api.dyntube.com/v1/plans
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.
{
"pager": {
"page": 1,
"totalPages": 7,
"totalResults": 7,
"sort": "Created:-1"
},
"plans": [
{
"id": "wj5XnB5Bg",
"name": "Monthly Plan",
"description": "",
"type": 1,
"storePlanType": 1,
"frequency": {
"interval": 0,
"count": 0
},
"status": 1,
"channelKeys": [
"r3KYBVcLEw"
],
"videoKeys": [],
"created": "2020-05-19T10:06:13.3099083+00:00",
"updated": "2020-05-19T10:06:13.3099082+00:00"
}
]
}
{
// Response
}
{
// Response
}
Sorting of results
The sorting order of the results would be a query parameter 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 by "Created" date.
#Sort by date created descending:
https://api.dyntube.com/v1/plans?sort=Created:-1
#Sort by date created ascending:
https://api.dyntube.com/v1/plans?sort=Created:1
Code Samples
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.dyntube.com/v1/plans?sort=Created:-1";
using (var httpClient = new HttpClient())
{
var response = await httpClient.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<PlanResponse>(json);
// Access the list of plans
var plans = result.Plans;
// Process the list of plans as needed
foreach (var plan in plans)
{
Console.WriteLine($"Plan ID: {plan.Id}, Name: {plan.Name}");
}
}
else
{
Console.WriteLine($"Failed to get plans. Status code: {response.StatusCode}");
}
}
}
}
// Define the class to hold the plan response
public class PlanResponse
{
public Pager Pager { get; set; }
public Plan[] Plans { get; set; }
}
// Define the classes to hold the plan data
public class Pager
{
public int Page { get; set; }
public int TotalPages { get; set; }
public int TotalResults { get; set; }
public string Sort { get; set; }
}
public class Plan
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Type { get; set; }
public int StorePlanType { get; set; }
public Frequency Frequency { get; set; }
public int Status { get; set; }
public string[] ChannelKeys { get; set; }
public string[] VideoKeys { get; set; }
public DateTime Created { get; set; }
public DateTime Updated { get; set; }
}
public class Frequency
{
public int Interval { get; set; }
public int Count { get; set; }
}
Node.js
const axios = require('axios');
const url = 'https://api.dyntube.com/v1/plans?sort=Created:-1';
axios.get(url)
.then(response => {
const plans = response.data.plans;
console.log(plans);
})
.catch(error => {
console.error(eja
Python
import requests
url = "https://api.dyntube.com/v1/plans?sort=Created:-1"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print(data)
else:
print("Failed to get plans. Status code:", response.status_code)
PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.dyntube.com/v1/plans?sort=Created:-1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>
Last updated