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
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:
<dependency>
<groupId>io.fastpix</groupId>
<artifactId>sdk</artifactId>
<version>0.1.0</version>
</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:
implementation("io.fastpix:sdk:0.1.0")Import the SDK
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.*;
import io.fastpix.sdk.models.errors.*;
import io.fastpix.sdk.models.operations.*;
import java.util.Optional;
import 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, replaceyour-access-token-idandyour-secret-keywith the Access Token ID and Secret Key values from the.envfile you downloaded.
package hello.world;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.*;
import io.fastpix.sdk.models.errors.*;
import io.fastpix.sdk.models.operations.CreateNewStreamResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws UnauthorizedException, InvalidPermissionException, ValidationErrorResponse, Exception {
FastPixSDK sdk = FastPixSDK.builder()
.serverURL("https://v1.fastpix.io/live")
.security(Security.builder()
.username("your-access-token-id")
.password("your-secret-key")
.build())
.build();
CreateLiveStreamRequest req = CreateLiveStreamRequest.builder()
.playbackSettings(PlaybackSettings.builder()
.build())
.inputMediaSettings(InputMediaSettings.builder()
.build())
.build();
CreateNewStreamResponse res = sdk.startLiveStream().createNewStream()
.request(req)
.call();
if (res.liveStreamResponseDTO().isPresent()) {
// handle response
}
}
}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:
javac Main.java
java MainNOTE
Some methods might throw errors when you are on a trial plan.
Full documentation
See the FastPix Java SDK for additional examples, API methods, and advanced usage.
Updated 8 days ago