Create Project

Create a New Project

To create a new project.

POST https://api.dyntube.com/v1/projects

The content type of the HTTP request should be application/json. Please have a look at the sample JSON body below.

NN8GgcLjTsbUg

Sample JSON Body

Here is a sample JSON request to create a project.

    {
        
        "name": "My Videos",
        "description": "This is a demo project",
        "region": "use-s", // you can change it for edge plans if needed 
        "planType": 1, // 1 for standard plans, 2 for edge plans 
        "options": {
                "convertToHls": true, // convert video to HLS format?
                "convertToMp4": false, // convert it to MP4?
                "useOriginalMp4": false, // Use original upload MP4 and don't transcode
                "hlsEncrypt": false, // encrypt this video
                "bitrate240p": 0, //Zero means use defaults.
                "bitrate360p": 0, 
                "bitrate540p": 0,
                "bitrate720p": 0,
                "bitrate1080p": 0,
                "bitrate1440p": 0,
                "bitrate2160p": 0,
                "saveOriginalVideos": false // Save original upload file as backup.
        }
    }

C#

using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace CreateProject
{
    class Program
    {
        static async Task Main(string[] args)
        {
            string url = "https://api.dyntube.com/v1/projects";
            string bearerToken = "your_bearer_token";

            var data = new
            {
                name = "Videos",
                description = "",
                region = "usw-s",
                planType = 1,
                options = new
                {
                    convertToHls = true,
                    convertToMp4 = false,
                    convertToOneMp4 = true,
                    useOriginalMp4 = false,
                    hlsEncrypt = false,
                    bitrate240p = 400,
                    bitrate360p = 1200,
                    bitrate540p = 1800,
                    bitrate720p = 3750,
                    bitrate1080p = 5625,
                    bitrate1440p = 0,
                    bitrate2160p = 0,
                    saveOriginalVideos = false
                },
                videoOptions = new
                {
                    autoplay = false,
                    playerSkin = "solid",
                    controlsColor = "",
                    primaryColor = "",
                    seekButtons = false,
                    volumeControl = true,
                    preload = "auto",
                    fullscreenControl = true,
                    controls = true,
                    captionsOn = false,
                    bigPlayControl = true,
                    defaultQuality = "",
                    qualityControl = true,
                    speedControl = true,
                    fastForward = true,
                    volume = 1.0,
                    loop = false,
                    muted = false,
                    landscapeFullscreen = false,
                    modal = false,
                    resumePlayback = false,
                    hideLogo = false,
                    cast = true,
                    extraSecurity = false,
                    stickyPlayer = false,
                    pauseOnScroll = false,
                    storeAuth = false,
                    contextMenu = false
                }
            };

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken);
                var content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
                var response = await httpClient.PostAsync(url, content);

                if (response.IsSuccessStatusCode)
                {
                    string responseContent = await response.Content.ReadAsStringAsync();
                    var responseObject = JsonSerializer.Deserialize<ProjectResponse>(responseContent);
                    Console.WriteLine($"Project created with ID: {responseObject.Id}");
                }
                else
                {
                    Console.WriteLine("Error creating project: " + response.ReasonPhrase);
                }
            }
        }
    }

    class ProjectResponse
    {
        public string Id { get; set; }
    }
}

Node.js

const axios = require('axios');

async function createProject() {
  const projectData = {
    name: 'My Videos',
    description: 'This is a demo project',
    region: 'use-s',
    planType: 1,
    options: {
      convertToHls: true,
      convertToMp4: false,
      useOriginalMp4: false,
      hlsEncrypt: false,
      bitrate240p: 0,
      bitrate360p: 0,
      bitrate540p: 0,
      bitrate720p: 0,
      bitrate1080p: 0,
      bitrate1440p: 0,
      bitrate2160p: 0,
      saveOriginalVideos: false
    }
  };

  const url = 'https://api.dyntube.com/v1/projects';
  const response = await axios.post(url, projectData, {
    headers: {
      Authorization: 'Bearer your_bearer_token_here'
    }
  });

  if (response.status === 200) {
    console.log(`Project created with ID: ${response.data.id}`);
    return response.data.id;
  } else {
    console.log('Project creation failed');
    return null;
  }
}

Python

import requests
import json

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

payload = json.dumps({
  "name": "My Videos",
  "description": "This is a demo project",
  "region": "use-s",
  "planType": 1,
  "options": {
    "convertToHls": True,
    "convertToMp4": False,
    "useOriginalMp4": False,
    "hlsEncrypt": False,
    "bitrate240p": 0,
    "bitrate360p": 0,
    "bitrate540p": 0,
    "bitrate720p": 0,
    "bitrate1080p": 0,
    "bitrate1440p": 0,
    "bitrate2160p": 0,
    "saveOriginalVideos": False
  }
})

headers = {
  'Authorization': 'Bearer your_bearer_token',
  'Content-Type': 'application/json'
}

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

print(response.text)

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "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 => "POST",
  CURLOPT_POSTFIELDS =>'{
      "name": "My Videos",
      "description": "This is a demo project",
      "region": "use-s",
      "planType": 1,
      "options": {
        "convertToHls": true,
        "convertToMp4": false,
        "useOriginalMp4": false,
        "hlsEncrypt": false,
        "bitrate240p": 0,
        "bitrate360p": 0,
        "bitrate540p": 0,
        "bitrate720p": 0,
        "bitrate1080p": 0,
        "bitrate1440p": 0,
        "bitrate2160p": 0,
        "saveOriginalVideos": false
      }
  }',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer your_bearer_token",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>

Last updated