{"id":26384,"date":"2023-03-07T12:35:45","date_gmt":"2023-03-07T12:35:45","guid":{"rendered":"http:\/\/localhost\/helpold\/?p=26384"},"modified":"2025-01-02T14:20:54","modified_gmt":"2025-01-02T10:50:54","slug":"video-api","status":"publish","type":"post","link":"https:\/\/www.arvancloud.ir\/help\/en\/video-api\/","title":{"rendered":"Using ArvanCloud Video Platform API"},"content":{"rendered":"<p>You can use two methods to work with the ArvanCloud video platform: the ArvanCloud User Panel or the ArvanCloud API. Although the first method is more suited for end users, the features and accessibility of the ArvanCloud Video Hosting API offer a powerful tool for developers.<\/p>\n<p>Throughout this technical guide, we will introduce you to the ArvanCloud video platform API and show you how to work with it. For more information about this tool, you can also refer to the ArvanCloud Video Hosting Platform API documentation.<\/p>\n<h2>Getting started with the API<\/h2>\n<p>To work with the ArvanCloud API, you are going to need an API key. You can easily get it via the ArvanCloud user panel. You may refer to the API key creation guide for instructions on creating an API key.<\/p>\n<p>Upon creating the API key, you can use the Postman or Insomnia tools to test the ArvanCloud Video API. To do so, and once you get one of these two tools, you first need to import the Postman collection file into one of these two installed programs and after that enter the API key you received from the ArvanCloud user panel in the Edit Collection section, Variables tab.<\/p>\n<p>The selected subdomain must be created using the post request to make the video hosting service available. Use the following command to do this.<\/p>\n<pre dir=\"ltr\"><code>POST \/domain\r\nParameters\r\nSubdomain required<\/code><\/pre>\n<p>The important thing is that this request can be performed only once, and you cannot change the selected domain.<\/p>\n<h2>View the Domain<\/h2>\n<p>If you want to view the assigned domain, you can use the following method.<\/p>\n<pre dir=\"ltr\"><code>GET \/domain<\/code><\/pre>\n<h2>Manage Channels<\/h2>\n<p>Before uploading audio and video files to ArvanCloud&#8217;s video hosting servers, you will have to create at least one channel. Any files that are used in ArvanCloud&#8217;s video platform, such as video files, audio files, watermarks and profiles, are stored in a channel.<\/p>\n<h3>Create a Channel<\/h3>\n<p>The following command can create a channel using the ArvanCloud API.<\/p>\n<pre dir=\"ltr\"><code>POST \/channels\r\nParameters\r\nTitle (string) required\r\nDescription (string) \r\nSecure_link_enabled (boolean)\r\nSecure_link_enabled (string) required if \u201csecure_link_enabled\u201d is true<\/code><\/pre>\n<h3>Show All Channels<\/h3>\n<p>Using the API of ArvanCloud&#8217;s video hosting service, you can view the list of channels available in your user account. To do this, you can use the below method.<\/p>\n<pre dir=\"ltr\"><code>GET \/channels<\/code><\/pre>\n<h3>Update a Channel<\/h3>\n<p>If you want to update a channel like when you create it, you have to send the body part and specify the channel ID in the URL as well.<\/p>\n<pre dir=\"ltr\"><code>PATCH \/channels\/{channel_id}<\/code><\/pre>\n<h3>View a Particular Channel<\/h3>\n<p>This route will allow you to view information about a particular channel.<\/p>\n<pre dir=\"ltr\"><code>GET \/channels\/{channel_id}<\/code><\/pre>\n<h3>Delete a Channel<\/h3>\n<p>You can completely delete a channel using the following method.<\/p>\n<pre dir=\"ltr\"><code>DELETE \/channels\/{channel_id}<\/code><\/pre>\n<p>Keep in mind that any files stored in it, including all audio files, video files, watermarks, and created profiles, will be deleted after deleting a channel.<\/p>\n<h2>File Upload<\/h2>\n<p>The TUS protocol is one of the most important concepts you must be aware of before uploading the file. Using this open-source protocol, you can upload in a resumable way. You can find more detailed information about this protocol and how to work with it in the Guide to Resumable Uploading of Files with the TUS Protocol.<\/p>\n<p>An empty storage must be created based on the size of the file displayed in the View File Information section before you start sending the file to the server. Suppose there is an mp4 file named video.mp4 with a size of 6.8 MB (or 6777592 bytes), first of all the file size will be copied from the Properties section.<\/p>\n<pre dir=\"ltr\"><code>POST \/channels\/{channel_id}\/files\r\nHeaders\r\ntus-resumable: 1.0.0\r\nupload_length: 6777592\r\nupload-metadata: filename dmlkZW8ubXA0,filetype dmlkZW8vbXA0<\/code><\/pre>\n<p>Next, the ID of the created location will be copied from the Response Header field and the file will be sent to the server through the PATH request (the file ID and channel will be inserted into the URL).<\/p>\n<pre dir=\"ltr\"><code>POST \/channels\/{channel_id}\/videos\r\nParameters\r\nTitle (string) required\r\nDescription (string)\r\nVideo_url (should be a valid URL. Otherwise, this will be corrupted)\r\nFile_id (should be string and it will be required whenever video_url is not available) required\r\nConvert_mode (could be auto or manual or profile)\r\nProfile_id (required if convert mode has set to profile)\r\nParallel_convert (boolean) required\r\nThumbnail_time (numeric) required\r\nConvert_info (must be an array and this will be required if convert mode has set to manual)\r\n[\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201caudio_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cvideo_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cresolution\u201d: \u201cstring\u201d,\r\n\u00a0\u00a0\u00a0 }\r\n]\r\n\r\nWatermark_id Watermark_area (should be one of: center, fix_top_left, fix_top_right, fix_top_center, fix_bottom_left, fix_bottom_right, fix_bottom_center, animate_left_to_right, animate_top_to_bottom)<\/code><\/pre>\n<p>When the audio or video file is available with a URL, the URL of the file could be entered directly in video_url \/ audio_url with no need to follow the previous steps. In addition, when the bitrate and resolution values are fixed, it is better to use the profile so that when converting the file, only the profile_id is needed.<\/p>\n<p>To add an image to the video, you must create a watermark first and enter its ID when sending the file. For simultaneous converting of files, parallel_convert value must be set to true. Under normal mode, all files are queued and converted one by one. By selecting parallel_convert, you can convert up to 3 files at the same time, but note that there will be a charge for converting each file simultaneously.<\/p>\n<h2>Conversion Status<\/h2>\n<p>Once the file has been submitted for conversion, there are steps you must take to make the file available. First of all, you should use GET Request to determine the status of the file. The status value in the response will indicate the current status.<\/p>\n<pre><code>GET\/videos\/{video_id}<\/code><\/pre>\n<p>All of the videos in a channel can be viewed using the following route.<\/p>\n<pre dir=\"ltr\"><code>GET\/channels\/{channel_id}\/videos<\/code><\/pre>\n<p>You can also update the title and description with the following route.<\/p>\n<pre dir=\"ltr\"><code>PATCH\/videos\/{video_id}\r\nParameters\r\nTitle (string) required\r\nDescription (string)<\/code><\/pre>\n<h2>Subtitles<\/h2>\n<p>You can upload multiple subtitles for a video. Adding subtitles has to be done with a POST request. At the moment, only SRT and VTT formats are allowed as subtitle files.<\/p>\n<pre dir=\"ltr\"><code>POST \/videos\/{video_id}\/subtitles\r\nParameters\r\nsubtitle (file) required\r\nlang (string) required<\/code><\/pre>\n<h3>View All Subtitles of a Video<\/h3>\n<p>View the Subtitles of a Specific Video<\/p>\n<pre dir=\"ltr\"><code>GET\/videos\/{video_id}\/subtitles<\/code><\/pre>\n<h3>Delete Subtitles<\/h3>\n<pre dir=\"ltr\"><code>DELETE\/subtitles\/{subtitle_id}<\/code><\/pre>\n<h2>Adding Watermark<\/h2>\n<p>In each channel, you can store different images separately to be used as a watermark during the video file conversion. To choose the watermark, you need to simply select the image ID you want to use.<\/p>\n<pre dir=\"ltr\"><code>POST \/channels\/{channel_id}\/watermarks\r\nParameters\r\ntitle (string) required\r\ndescription (string)\r\nwatermark (file) required\r\n<\/code><\/pre>\n<h3>Update Watermark<\/h3>\n<p>You can easily update the watermark using the ID of each watermark.<\/p>\n<pre dir=\"ltr\"><code>POST \/ watermarks \/{ watermark _id}\r\nParameters\r\ntitle (string) required\r\ndescription (string)<\/code><\/pre>\n<h3>View All Watermarks of a Channel<\/h3>\n<pre dir=\"ltr\"><code>GET\/channels\/{channel_id}\/watermarks<\/code><\/pre>\n<h3>View a Watermark<\/h3>\n<pre dir=\"ltr\"><code>GET\/watermarks\/{watermark_id}<\/code><\/pre>\n<h2>Managing Profiles<\/h2>\n<p>In order to avoid manually entering file conversion settings whenever you convert a video or audio file, you can create a profile which, when selected, performs file conversion according to the profile settings. One channel can have several profiles.<\/p>\n<pre dir=\"ltr\"><code>POST \/channels\/{channel_id}\/profiles\r\nParameters\r\nTitle (string) required\r\nDescription (string) \r\n\u00a0convert_mode (\"auto\", \u201cmanual\u201d) required\r\nthumbnail_time (number)\r\nwatermark_id (string)\r\nWatermark_area (should be one of: center, fix_top_left, fix_top_right, fix_top_center, fix_bottom_left, fix_bottom_right, fix_bottom_center, animate_left_to_right, animate_top_to_bottom)\r\nConvert_info (must be an array and this will be required if convert mode has set to manual)\r\n[\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201caudio_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cvideo_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cresolution\u201d: \u201cstring\u201d,\r\n\u00a0\u00a0\u00a0 }\r\n]<\/code><\/pre>\n<h3>Update Profile<\/h3>\n<pre dir=\"ltr\"><code>PATCH \/profiles\/{profile_id}\r\nParameters\r\nTitle (string) required\r\nDescription (string) \r\n\u00a0convert_mode (\"auto\", \u201cmanual\u201d) required\r\nthumbnail_time (number)\r\nwatermark_id (string)\r\nWatermark_area (should be one of: center, fix_top_left, fix_top_right, fix_top_center, fix_bottom_left, fix_bottom_right, fix_bottom_center, animate_left_to_right, animate_top_to_bottom)\r\nConvert_info (must be an array and this will be required if convert mode has set to manual)\r\n[\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201caudio_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cvideo_bitrate\u201d: 0,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u201cresolution\u201d: \u201cstring\u201d,\r\n\u00a0\u00a0\u00a0 }\r\n]<\/code><\/pre>\n<h3>View All Profiles of a Channel<\/h3>\n<pre dir=\"ltr\"><code>GET\/channels\/{channel_id}\/profiles<\/code><\/pre>\n<h3>View a Profile<\/h3>\n<pre dir=\"ltr\"><code>GET\/profiles\/{profile_id}<\/code><\/pre>\n<h3>Delete a Profile<\/h3>\n<pre dir=\"ltr\"><code>DELETE\/profiles\/{profile_id}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can use two methods to work with the ArvanCloud video platform: the ArvanCloud User Panel or the ArvanCloud API. Although the first method is more suited for end users, the features and accessibility of the ArvanCloud Video Hosting API offer a powerful tool for developers. Throughout this technical guide, we will introduce you to [&hellip;]<\/p>\n","protected":false},"author":79,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"r1_post_views_count":"1871","feedback_yes":"0","feedback_no":"0","ads_id_sidebar":"","ads_id_content":"","footnotes":""},"categories":[277,243],"tags":[],"class_list":["post-26384","post","type-post","status-publish","format-standard","hentry","category-video-hosting","category-video-platform"],"lang":"en","translations":{"en":26384},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts\/26384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/users\/79"}],"replies":[{"embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/comments?post=26384"}],"version-history":[{"count":5,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts\/26384\/revisions"}],"predecessor-version":[{"id":28292,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/posts\/26384\/revisions\/28292"}],"wp:attachment":[{"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/media?parent=26384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/categories?post=26384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.arvancloud.ir\/help\/wp-json\/wp\/v2\/tags?post=26384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}