FastPix Java SDK

Learn how the FastPix Java SDK enables video uploads, live streaming, and playback management in Java applications.

Add secure, scalable video to your Java project

The FastPix Java SDK gives you everything you need to manage video from your backend. Upload files from a public URL, attach metadata, and retrieve playback links, all without building encoding pipelines or managing storage. With this SDK, you can:

  • Upload and organize video assets
  • Define access control and metadata
  • Generate HLS playback URLs
  • Streamline video delivery from your Java server

Find more in the SDK reference

To explore more examples, API methods, and advanced usage, see the FastPix Java SDK on GitHub.


Prerequisites

Before you start using the SDK, make sure you have the following:

  • JDK 11 or later: This SDK is compatible with Java 11 or higher
  • Maven or Gradle: Required for dependency management
  • IDE: IntelliJ IDEA, Eclipse, or VS Code with Java extensions
  • FastPix API credentials: You’ll need an Access Token and a Secret Key. You can generate these credentials by following the steps in the authentication guide
  • Basic understanding of Java and REST APIs: Familiarity with Java development and API integration concepts

Installation

Install the SDK using your preferred build tool:

Using Maven

Add this to your pom.xml file:

1<dependency>
2 <groupId>io.fastpix</groupId>
3 <artifactId>sdk</artifactId>
4 <version>0.1.0</version>
5</dependency>

Using Gradle

Add this to your build.gradle file:

implementation 'io.fastpix:sdk:0.1.0'

Using Gradle (Kotlin DSL)

Add this to your build.gradle.kts file:

1implementation("io.fastpix:sdk:0.1.0")

Import the SDK

1import io.fastpix.sdk.FastPixSDK;
2import io.fastpix.sdk.models.components.*;
3import io.fastpix.sdk.models.errors.*;
4import io.fastpix.sdk.models.operations.*;
5import java.util.Optional;
6import java.util.List;

Example

Let’s create a file named Main.java

This example shows how to upload a video from a public URL with metadata and public access:

NOTE
In the following example, replace your-access-token-id and your-secret-key with the Access Token ID and Secret Key values from the .env file you downloaded.

1// Package declaration - adjust to match your project's directory structure
2package hello.world;
3
4// Import required classes from the FastPix SDK
5import java.lang.Exception;
6import java.util.List;
7import java.util.Map;
8import com.fasterxml.jackson.databind.SerializationFeature;
9import io.fastpix.sdk.FastPixSDK;
10import io.fastpix.sdk.models.components.*;
11import io.fastpix.sdk.models.operations.CreateMediaResponse;
12import io.fastpix.sdk.utils.JSON;
13
14public class Application {
15
16 public static void main(String[] args) throws Exception {
17
18 FastPixSDK sdk = FastPixSDK.builder()
19 .security(Security.builder()
20 .username("your-access-token")
21 .password("your-secret-key")
22 .build())
23 .build();
24
25 CreateMediaRequest req = CreateMediaRequest.builder()
26 .inputs(List.of(
27 Input.of(PullVideoInput.builder()
28 .url("https://static.fastpix.com/fp-sample-video.mp4")
29 .build())))
30 .metadata(Map.ofEntries(
31 Map.entry("key1", "value1")))
32 .build();
33
34 CreateMediaResponse res = sdk.inputVideos().create()
35 .request(req)
36 .call();
37
38 if (res.createMediaSuccessResponse().isPresent()) {
39 var mapper = JSON.getMapper();
40 mapper.enable(SerializationFeature.INDENT_OUTPUT);
41 System.out.println(mapper.writeValueAsString(res.createMediaSuccessResponse().get()));
42 }
43 }
44}

After the video is processed, you can use the media ID to fetch playback info, monitor status, or transform content through the API.


Run the example

To execute the Java application, compile and run it using the following commands. Make sure to replace Main.java with your actual file name if it’s different:

1javac Main.java
2java Main

NOTE
Some methods might throw errors when you are on a trial plan.


Release notes

For a complete history of releases, improvements, and fixes, see the FastPix Java SDK CHANGELOG on GitHub.