Developer-friendly & type-safe Java SDK specifically designed to leverage the FastPix platform API.
The FastPix Java SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, and simulcasting.
-
- Upload Media: Upload media files seamlessly from URLs or devices
- Manage Media: Perform operations such as listing, fetching, updating, and deleting media assets
- Playback IDs: Generate and manage playback IDs for media access
-
- Create & Manage Live Streams: Create, list, update, and delete live streams effortlessly
- Control Stream Access: Generate playback IDs for live streams to control and manage access
- Simulcast to Multiple Platforms: Stream content to multiple platforms simultaneously
For detailed usage, refer to the FastPix API Reference.
- JDK 11 or later
- FastPix API credentials (Access Token and Secret Key)
To get started with the FastPix Java SDK, ensure you have the following:
-
The FastPix APIs are authenticated using an Access Token and a Secret Key. You must generate these credentials to use the SDK.
-
Follow the steps in the Authentication with Access Tokens guide to obtain your credentials.
JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'io.fastpix:sdk:0.1.0'
Maven:
<dependency>
<groupId>io.fastpix</groupId>
<artifactId>sdk</artifactId>
<version>0.1.0</version>
</dependency>
After cloning the git repository to your file system you can build the SDK artifact from source to the build
directory by running ./gradlew build
on *nix systems or gradlew.bat
on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signing
On Windows:
gradlew.bat publishToMavenLocal -Pskip.signing
You can set the security parameters through the security
builder method when initializing the SDK client instance. For example:
FastPixSDK sdk = FastPixSDK.builder()
.security(Security.builder()
.username("your-access-token-id")
.password("your-secret-key")
.build())
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()
.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
}
}
}
Available methods
- createMedia - Create media from URL
- directUploadVideoMedia - Upload media from device
- getAllStreams - Get all live streams
- getLiveStreamById - Get stream by ID
- deleteLiveStream - Delete a stream
- updateLiveStream - Update a stream
- listMedia - Get list of all media
- getMedia - Get a media by ID
- updatedMedia - Update a media by ID
- deleteMedia - Delete a media by ID
- retrieveMediaInputInfo - Get info of media inputs
- createPlaybackIdOfStream - Create a playbackId
- deletePlaybackIdOfStream - Delete a playbackId
- getLiveStreamPlaybackId - Get stream's playbackId
- createMediaPlaybackId - Create a playback ID
- deleteMediaPlaybackId - Delete a playback ID
- createSimulcastOfStream - Create a simulcast
- deleteSimulcastOfStream - Delete a simulcast
- getSpecificSimulcastOfStream - Get a specific simulcast of a stream
- updateSpecificSimulcastOfStream - Update a specific simulcast of a stream
- createNewStream - Create a new stream
All operations return a response object or raise an exception.
By default, an API error will throw a models/errors/APIException
exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the createNewStream
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
models/errors/UnauthorizedException | 401 | application/json |
models/errors/InvalidPermissionException | 403 | application/json |
models/errors/ValidationErrorResponse | 422 | application/json |
models/errors/APIException | 4XX, 5XX | */* |
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()
.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
}
}
}
The default server can be overridden globally using the .serverURL(String serverUrl)
builder method when initializing the SDK client instance. For example:
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
}
}
}
This SDK is currently in beta, and breaking changes may occur between versions even without a major version update. To avoid unexpected issues, we recommend pinning your dependency to a specific version. This ensures consistent behavior unless you intentionally update to a newer release.
For a complete understanding of each API's functionality, including request and response details, parameter descriptions, and additional examples, please refer to the FastPix API Reference.
The API reference provides comprehensive documentation for all available endpoints and features, ensuring developers can integrate and utilize FastPix APIs efficiently.