Get Videos using DynTube API

This article explains how you can get a list of your videos using DynTube API.

The first step is to make sure that you use Bearer authentication in your API request as explained here.

Videos can be listed simply by making a HTTP GET request to following URL if you are using version 1 of API.


https://api.dyntube.com/v1/videos

If you are using our Edge plans, you must specify the "planType" in your URL.

    
        https://api.dyntube.com/v1/videos?planType=2
    

If you want to change the page number or page size, use the following query string parameters.


https://api.dyntube.com/v1/videos?page=1&size=10

If you want to change the sorting of your results. It can be done by specifying the "sort" parameter in URL.The value of "sort" should be "field:order". Use "1" for ascending order and "-1" for descending order.


Sort by title ascending:
https://api.dyntube.com/v1/videos?sort=Title:1

Sort by title descending:
https://api.dyntube.com/v1/videos?sort=Title:-1




Sort by date created descending:
https://api.dyntube.com/v1/videos?sort=Created:-1

Sort by date created ascending:
https://api.dyntube.com/v1/videos?sort=Created:1

If you are subscribed for both kind of plans you can filter by planType. The value should be "1" for standard plans and "2" for edge plans.


Standard Plans:
https://api.dyntube.com/v1/videos?planType=1

Edge Plans:
https://api.dyntube.com/v1/videos?planType=2

If you want to filter the results based on different fields, it's possible to filter results on projectId and tags.


filter using projectId:
https://api.dyntube.com/v1/videos?projectId=g56hjgh4dasxxop


filter using tags:
https://api.dyntube.com/v1/videos?tags=foo,bar
#Here we are filtering results using two tags "foo" & "bar". Even if on of the tag is present in a video, it will be included.


Here are some code examples

Remember to replace {{token}} with actual value.

cURL


        curl --location --request GET 'https://api.dyntube.com/v1/videos' \
        --header 'Authorization: Bearer {{token}}'

    
C# - using RestSharp Library

        var client = new RestClient("https://api.dyntube.com/v1/videos");
        client.Timeout = -1;
        var request = new RestRequest(Method.GET);
        request.AddHeader("Authorization", "Bearer {{token}}");
        IRestResponse response = client.Execute(request);
        Console.WriteLine(response.Content);


    
NodeJs - using Axios


        var axios = require('axios');

        var config = {
        method: 'get',
        url: 'https://api.dyntube.com/v1/videos',
        headers: {
        'Authorization': 'Bearer {{token}}'
        }
        };

        axios(config)
        .then(function (response) {
        console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
        console.log(error);
        });



    
PHP - HTTP_Request2



        setUrl('https://api.dyntube.com/v1/videos');
        $request->setMethod(HTTP_Request2::METHOD_GET);
        $request->setConfig(array(
        'follow_redirects' => TRUE
        ));
        $request->setHeader(array(
        'Authorization' => 'Bearer {{token}}'
        ));
        try {
        $response = $request->send();
        if ($response->getStatus() == 200) {
        echo $response->getBody();
        }
        else {
        echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
        $response->getReasonPhrase();
        }
        }
        catch(HTTP_Request2_Exception $e) {
        echo 'Error: ' . $e->getMessage();
        }

    
PHP - cURL


         'https://api.dyntube.com/v1/videos',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_HTTPHEADER => array(
        'Authorization: Bearer {{token}}'
        ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        echo $response;



    
Python - Requests


        import requests

        url = "https://api.dyntube.com/v1/videos"

        payload={}
        headers = {
        'Authorization': 'Bearer {{token}}'
        }

        response = requests.request("GET", url, headers=headers, data=payload)

        print(response.text)




    
Ruby - Net::HTTP


        require "uri"
        require "net/http"

        url = URI("https://api.dyntube.com/v1/videos")

        https = Net::HTTP.new(url.host, url.port)
        https.use_ssl = true

        request = Net::HTTP::Get.new(url)
        request["Authorization"] = "Bearer {{token}}"

        response = https.request(request)
        puts response.read_body



    
Java - Unirest


        Unirest.setTimeouts(0, 0);
        HttpResponse
            response = Unirest.get("https://api.dyntube.com/v1/videos")
            .header("Authorization", "Bearer {{token}}")
            .asString();



    
Dart - http


        var headers = {
        'Authorization': 'Bearer {{token}}'
        };
        var request = http.Request('GET', Uri.parse('https://api.dyntube.com/v1/videos'));

        request.headers.addAll(headers);

        http.StreamedResponse response = await request.send();

        if (response.statusCode == 200) {
        print(await response.stream.bytesToString());
        }
        else {
        print(response.reasonPhrase);
        }