Skip to content

Latest commit

 

History

History
219 lines (150 loc) · 9.46 KB

VideosApi.md

File metadata and controls

219 lines (150 loc) · 9.46 KB

VideosApi

All URIs are relative to https://ws.api.video

Method HTTP request Description
upload POST /videos/{videoId}/source Upload a video
uploadWithUploadToken POST /upload Upload with an delegated upload token

upload

Video upload(videoId, file) ApiResponse

Upload a video

To upload a video to the videoId you created. You can only upload your video to the videoId once.

We offer 2 types of upload:

  • Regular upload

  • Progressive upload

The latter allows you to split a video source into X chunks and send those chunks independently (concurrently or sequentially). The 2 main goals for our users are to

  • allow the upload of video sources > 200 MiB (200 MiB = the max. allowed file size for regular upload)

  • allow to send a video source "progressively", i.e., before before knowing the total size of the video.

Once all chunks have been sent, they are reaggregated to one source file. The video source is considered as "completely sent" when the "last" chunk is sent (i.e., the chunk that "completes" the upload).

Example

// Import classes:
import video.api.uploader.api.ApiException;
import video.api.uploader.api.models.*;
import video.api.uploader.VideosApi;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    VideosApi apiInstance = new videos("YOUR_API_KEY");
    // if you rather like to use the sandbox environment:
    // VideosApi apiInstance = new videos("YOUR_SANDBOX_API_KEY", Environment.SANDBOX);
    
    String videoId = "vi4k0jvEUuaTdRAEjQ4Jfrgz"; // Enter the videoId you want to use to upload your video.
    File file = new File("/path/to/file"); // The path to the video you would like to upload. The path must be local. If you want to use a video from an online source, you must use the \\\"/videos\\\" endpoint and add the \\\"source\\\" parameter when you create a new video.

    try {
      Video result = apiInstance.upload(videoId, file);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling VideosApi#upload");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getMessage());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
videoId String Enter the videoId you want to use to upload your video.
file File The path to the video you would like to upload. The path must be local. If you want to use a video from an online source, you must use the \"/videos\" endpoint and add the \"source\" parameter when you create a new video.

Upload chunks

Large files are broken into chunks for upload. You can control the size of the chunks using the setUploadChunkSize() of method of ApiVideoClient before uploading:

apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
apiVideoClient.videos().upload(videoId, file);

Progressive uploads

Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially. The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.

String videoId = "vi4k0jvEUuaTdRAEjQ4Jfrgz"; // Enter the videoId you want to use to upload your video.;

UploadProgressiveSession session = apiVideoClient.createUploadProgressiveSession(videoId)

session.uploadPart(new File("sample.mp4.part1"));
session.uploadPart(new File("sample.mp4.part2"));
// ...
Video result = session.uploadLastPart(new File("sample.mp4.partn"));

Return type

Video

Authorization

API key

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 Created * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
400 Bad Request * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
404 Not Found * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
429 Too Many Requests * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.

uploadWithUploadToken

Video uploadWithUploadToken(token, file) ApiResponse

Upload with an delegated upload token

This method allows you to send a video using an upload token. Upload tokens are especially useful when the upload is done from the client side. If you want to upload a video from your server-side application, you'd better use the standard upload method.

Example

// Import classes:
import video.api.uploader.api.ApiException;
import video.api.uploader.api.models.*;
import video.api.uploader.VideosApi;
import java.util.*;

public class Example {
  public static void main(String[] args) {
    VideosApi apiInstance = videos();
    // if you rather like to use the sandbox environment:
    //  VideosApi apiInstance = new videos(Environment.SANDBOX);
    
    String token = "to1tcmSFHeYY5KzyhOqVKMKb"; // The unique identifier for the token you want to use to upload a video.
    File file = new File("/path/to/file"); // The path to the video you want to upload.

    try {
      Video result = apiInstance.uploadWithUploadToken(token, file);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling VideosApi#uploadWithUploadToken");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getMessage());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
token String The unique identifier for the token you want to use to upload a video.
file File The path to the video you want to upload.

Upload chunks

Large files are broken into chunks for upload. You can control the size of the chunks using the setUploadChunkSize() of method of ApiVideoClient before uploading:

apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
apiVideoClient.videos().uploadWithUploadToken(token, file);

Progressive uploads

Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially. The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.

String token = "to1tcmSFHeYY5KzyhOqVKMKb"; // The unique identifier for the token you want to use to upload a video.;

UploadWithUploadTokenProgressiveSession session = apiVideoClient.createUploadWithUploadTokenProgressiveSession(token)

session.uploadPart(new File("sample.mp4.part1"));
session.uploadPart(new File("sample.mp4.part2"));
// ...
Video result = session.uploadLastPart(new File("sample.mp4.partn"));

Return type

Video

Authorization

No authorization required

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 Created * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
400 Bad Request * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
429 Too Many Requests * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.