Get Projects using DynTube API

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

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

Projects 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/projects

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


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

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


https://api.dyntube.com/v1/projects?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 name ascending:
https://api.dyntube.com/v1/projects?sort=Name:1

Sort by name descending:
https://api.dyntube.com/v1/projects?sort=Name:-1

If you want to sort by date, you can use "Created" field.


Project creation Date descending:
https://api.dyntube.com/v1/projects?Created=-1

Project creation Date ascending:
https://api.dyntube.com/v1/projects?Created=1

Filtering of results is possible by "region".
Example: Filter using use-s (US EAST) region code:


https://api.dyntube.com/v1/projects?region=use-s

More region codes can be found here https://www.dyntube.com/developers/list-of-region-codes-plan-types

Here are some code examples

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

cURL


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

    
C# - using RestSharp Library

        var client = new RestClient("https://api.dyntube.com/v1/projects");
        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/projects',
        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/projects');
        $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/projects',
        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/projects"

        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/projects")

        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/projects")
    .header("Authorization", "Bearer {{token}}")
    .asString();




Dart - http


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

        request.headers.addAll(headers);

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

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