Skip to content

Developer-friendly & type-safe Java SDK specifically designed to leverage the FastPix platform API.

Notifications You must be signed in to change notification settings

FastPix/fastpix-java

Repository files navigation

FastPix Java SDK

Developer-friendly & type-safe Java SDK specifically designed to leverage the FastPix platform API.

Introduction

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.

Key Features

  • Media API

    • 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
  • Live API

    • 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.

Prerequisites:

  • JDK 11 or later
  • FastPix API credentials (Access Token and Secret Key)

Getting started with FastPix:

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.

Table of Contents

SDK Installation

Getting started

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>

How to build

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

Initialization

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())

SDK Example Usage

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()
                .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 Resources and Operations

Available methods

Error Handling

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 */*

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()
                .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
        }
    }
}

Server Selection

Override Server URL Per-Client

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
        }
    }
}

Development

Maturity

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.

Detailed Usage

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.

About

Developer-friendly & type-safe Java SDK specifically designed to leverage the FastPix platform API.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages