DynTube API
  • Welcome!
  • Key Concepts
  • Quick Start
  • Reference
    • Videos
      • Video Upload via File (Server Side)
      • Video Upload via URL (server side)
      • HTML-Form Client Side Video Uploads
      • Get Video Status
      • Get Videos
      • Get Video
      • Update Video
      • Delete Video
      • Download Original Video
      • Get Video for Mobile App/Custom Player
      • Update Video Image
      • Add Video Captions/Chapters/Subtitles
      • Delete Video Captions/Subtitles/Chapters
      • Create Expirable Links
      • Get Collected Emails
      • Setting Up Webhooks
      • Copy call-to-action (CTA) to Videos
      • Token Authentication
    • Projects
      • Create Project
      • Update a Project
      • Get Projects
      • Get a Project
      • Delete a Project
      • Set default CTA for Project
    • Live Streaming
      • Create a Live Stream
      • Update a Live Stream
      • Get Live Streams
      • Get a Live Stream
      • Count Live Streams
      • Live Streams Limit
      • Get Live Streaming Recording
      • Delete a Live Stream
      • Service and Regions for live streams
    • Channels
      • Get Channels
      • Get Channel
      • Delete Channel
    • Subscriptions
      • Create a Plan
      • Create a Member
      • Attach Plan To Member
      • Get Plans
      • Get Members
      • Get Member's Plans
      • Delete a Plan
    • Analytics
      • Use your User Ids in Analytics
      • Get Video Analytics
    • Javascript Events Methods
      • Plain Javascript Events & Methods
      • Control the Player using React
      • Control the Player in Vue.js
    • Developer Resources
      • How to embed DynTube player in Next.Js
      • How to embed the video player in React
      • How to play DynTube videos in React Native
      • ExoPlayer app to play HLS videos
      • How to embed videos & channels dynamically
      • How to Import Vimeo Videos into DynTube
Powered by GitBook
On this page
  • Get a List of Plans
  • Get a list of plans. You can filter or sort plans based on optional query string.
  • Sorting of results
  • Code Samples
  • C#
  • Node.js
  • Python
  • PHP
  1. Reference
  2. Subscriptions

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);

?>
PreviousAttach Plan To MemberNextGet Members

Last updated 6 months ago