- Print
- PDF
VOD Station overview
- Print
- PDF
Overview
VOD Station is a service that lets you encode a number of video files saved in Object Storage in various video qualities, and stream them using the HLS/DASH protocol. You can control all features of VOD Station using HTTP API.
Common settings
VOD Station API URL
https://vodstation.apigw.ntruss.com/api/v2
Request headers
Header name | Description |
---|---|
x-ncp-region_code | NAVER Cloud Platform's region code (not included in the GET request) x-ncp_region_code:{Region Code} |
x-ncp-apigw-timestamp | It indicates the time elapsed in milliseconds since January 1, 1970 00:00:00 UTC and if the time difference compared to the API Gateway server is more than 5 minutes, then the request is considered invalid. x-ncp-apigw-timestamp:{Timestamp} |
x-ncp-iam-access-key | Access key ID issued from the NAVER Cloud Platform portalx-ncp-iam-access-key:{Sub Account Access Key} |
x-ncp-apigw-signature-v2 | Signature encrypted with the secret key mapped with the access key ID HMAC encryption algorithm is HMAC-SHA256 x-ncp-apigw-signature-v2:{API Gateway Signature} |
Content-Type | If the request body is included in the request, then request the content type as application/json.Content-Type: application/json |
Authentication header
An API Gateway authentication is required to use the VOD Station API. Refer to the NAVER Cloud Platform API for more information related to API Gateway authentication.
Creating AUTHPARAMS
- AUTHPARAMS request example
curl -i -X GET \
-H "x-ncp-region_code:KR" \
-H "x-ncp-apigw-timestamp:1505290625682" \
-H "x-ncp-iam-access-key:D78BB444D6D3C84CA38A" \
-H "x-ncp-apigw-signature-v2:WTPItrmMIfLUk/UyUIyoQbA/z5hq9o3G8eQMolUzTEo=" \
'https://vodstation.apigw.ntruss.com/api/v2/channels'
Create a signature (Add a new line with \n.)
Create a StringToSign appropriate for your request, encrypt it with your secret key and the HMACSHA256 algorithm, and encode it with Base64.
This value is used as
x-ncp-apigw-signature-v2
.Requests StringToSign GET /api/v2/channels?limit=10
x-ncp-apigw-timestamp={timestamp}
x-ncp-iam-access-key={accesskey}
x-ncp-apigw-signature-v2={signature}GET /api/v2/channels?limit=10
{timeStamp}
{accessKey}
Sample code
public String makeSignature() {
String space = " "; // Space
String newLine = "\n"; // New line
String method = "GET"; // HTTP method
String url = "/api/v2/channels?isPage=true"; // Entire url under "/" except for domain (query string included)
String accessKey = "{accessKey}"; // Access key id (from portal or Sub Account)
String secretKey = "{secretKey}"; // Secret key (from portal or Sub Account)
String timestamp = String.valueOf(System.currentTimeMillis()); // Current timestamp (epoch, millisecond)
String message = new StringBuilder()
.append(method)
.append(space)
.append(url)
.append(newLine)
.append(timestamp)
.append(newLine)
.append(accessKey)
.toString();
SecretKeySpec signingKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(signingKey);
byte[] rawHmac = mac.doFinal(message.getBytes("UTF-8"));
String encodeBase64String = Base64.encodeBase64String(rawHmac);
return encodeBase64String;
}
/*
https://code.google.com/archive/p/crypto-js/
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/crypto-js/CryptoJS%20v3.1.2.zip
*/
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
<script type="text/javascript" src="./CryptoJS/rollups/hmac-sha256.js"></script>
<script type="text/javascript" src="./CryptoJS/components/enc-base64.js"></script>
function makeSignature(secretKey, method, url, timestamp, accessKey) {
var space = " ";
var newLine = "\n";
var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, secretKey); // secret key
hmac.update(method); // HTTP method
hmac.update(space); // Space
hmac.update(url); // Entire url under "/" except for domain (query string included)
hmac.update(newLine); // New line
hmac.update(timestamp); // Current timestamp (epoch, millisecond)
hmac.update(newLine); // New line
hmac.update(accessKey); // access key (from portal or iam)
var hash = hmac.finalize();
return hash.toString(CryptoJS.enc.Base64);
}
import sys
import os
import hashlib
import hmac
import base64
import requests
import time
def make_signature():
timestamp = int(time.time() * 1000)
timestamp = str(timestamp) # Current timestamp (epoch, millisecond)
access_key = "{accessKey}" # Access key id (from portal or Sub Account)
secret_key = "{secretKey}" # Secret key (from portal or Sub Account)
secret_key = bytes(secret_key, 'UTF-8')
method = "GET" # HTTP method
uri = "/api/v2/channels?isPage=true" # Entire url under "/" except for domain (query string included)
message = method + " " + uri + "\n" + timestamp + "\n"
+ access_key
message = bytes(message, 'UTF-8')
signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
return signingKey
<?php
$access_key = "{accessKey}";
$secret_key = "{secretKey}";
$url = "/api/v2/channels";
$timestamp = getMillisecond();
$message = "GET";
$message .= " ";
$message .= $url;
$message .= "\n";
$message .= $timestamp;
$message .= "\n";
$message .= $access_key;
$signature = base64_encode(hash_hmac('sha256', $message, $secret_key, true));
$headers = array(
"Content-Type: application/json;",
"x-ncp-apigw-timestamp: ".$timestamp."",
"x-ncp-iam-access-key: ".$access_key."",
"x-ncp-apigw-signature-v2: ".$signature.""
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://vodstation.apigw.ntruss.com".$url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
function getMillisecond()
{
list($microtime, $timestamp) = explode(' ', microtime());
$time = $timestamp.substr($microtime, 2, 3);
return $time;
}
?>
function makeSignature() {
nl=$'\\n'
TIMESTAMP=$(echo $(($(date +%s%N)/1000000))) # Current timestamp (epoch, millisecond)
ACCESSKEY="{accessKey}" # Access key id (from portal or Sub Account)
SECRETKEY="{secretKey}" # Secret key (from portal or Sub Account)
METHOD="GET" # HTTP method
URI="/api/v2/channels?isPage=true" # Entire url under "/" except for domain (query string included)
SIG="$METHOD"' '"$URI"${nl}
SIG+="$TIMESTAMP"${nl}
SIG+="$ACCESSKEY"
SIGNATURE=$(echo -n -e "$SIG"|iconv -t utf8 |openssl dgst -sha256 -hmac $SECRETKEY -binary|openssl enc -base64)
}
VOD Station API request configuration
Header
x-ncp-region_code:{Region Code}
x-ncp-apigw-timestamp:{Timestamp}
x-ncp-iam-access-key:{Sub Account Access Key}
x-ncp-apigw-signature-v2:{API Gateway Signature}
Content-Type:application/json
Body
Json Object
URL
https://vodstation.apigw.ntruss.com/api/v2/{action}
VOD Station API request sample
curl -i -s -X POST \
-H "Content-Type:application/json" \
-H "x-ncp-region_code:KR" \
-H "x-ncp-apigw-timestamp:1521787414578" \
-H "x-ncp-iam-access-key:6uxz1nKkcYwUjWRG5Q1V7NsW0i5jErlu2NjBXXgy" \
-H "x-ncp-apigw-signature-v2:iJFK773KH0WwQ79PasqJ+ZGixtpDQ/abS57WGQdld2M=" \
"https://vodstation.apigw.ntruss.com/api/v2/channles"\
-d "{ \"cdnTypeList\": [ \"cdn+\" ], \"createCdn\": true, \"name\": \"api-guide\", \"protocolList\": [ \"HLS\", \"DASH\" ], \"segmentDuration\": 5, \"storageBucketName\": \"guide\"}"
VOD Station API Content-Type
application/json
is used for the Content-type of all data delivered through VOD Station API HTTP requests and response bodies.