Skip to content

Ruby SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API.

License

Notifications You must be signed in to change notification settings

FastPix/fastpix-ruby

Repository files navigation

FastPix Ruby SDK

A robust, type-safe Ruby SDK designed for seamless integration with the FastPix API platform.

Introduction

The FastPix Ruby SDK simplifies integration with the FastPix platform. It provides a clean, typed interface for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, on‑demand content, playlists, video analytics, and signing keys for secure access and token management. It is intended for use with Ruby 3.2 and above.

Prerequisites

Environment and Version Support

Requirement Version Description
Ruby 3.2+ Core runtime environment
Bundler Latest Dependency management
Internet Required API communication and authentication

Pro Tip: We recommend using Ruby 3.2+ for optimal performance and the latest language features.

Getting Started with FastPix

To get started with the FastPix Ruby SDK, ensure you have the following:

  • The FastPix APIs are authenticated using a Username and a Password. You must generate these credentials to use the SDK.
  • Follow the steps in the Authentication with Basic Auth guide to obtain your credentials.

Environment Variables (Optional)

Configure your FastPix credentials using environment variables for enhanced security and convenience:

# Set your FastPix credentials
export FASTPIX_USERNAME="your-access-token"
export FASTPIX_PASSWORD="your-secret-key"

Security Note: Never commit your credentials to version control. Use environment variables or secure credential management systems.

Table of Contents

Setup

Installation

Install the FastPix Ruby SDK using Bundler. Add to your Gemfile:

gem 'fastpixapi'

Then run:

bundle install

Or install the gem directly:

gem install fastpixapi

Imports

Require the SDK and use the client namespace:

require 'json'
require 'fastpixapi'

Models = ::FastpixClient::Models

Initialization

Initialize the FastPix SDK with your credentials:

require 'fastpixapi'

Models = ::FastpixClient::Models
s = ::FastpixClient::Fastpixapi.new(
  security: Models::Components::Security.new(
    username: 'your-access-token',
    password: 'your-secret-key'
  )
)

Or using environment variables:

require 'fastpixapi'

Models = ::FastpixClient::Models
s = ::FastpixClient::Fastpixapi.new(
  security: Models::Components::Security.new(
    username: ENV['FASTPIX_USERNAME'],  # Your Access Token
    password: ENV['FASTPIX_PASSWORD']  # Your Secret Key
  )
)

Example Usage

require 'json'
require 'fastpixapi'

Models = ::FastpixClient::Models
s = ::FastpixClient::Fastpixapi.new(
  security: Models::Components::Security.new(
    username: 'your-access-token',
    password: 'your-secret-key'
  )
)

req = Models::Components::CreateMediaRequest.new(
  inputs: [
    Models::Components::PullVideoInput.new(
      type: 'video',
      url: 'https://static.fastpix.io/fp-sample-video.mp4',
    ),
  ],
  metadata: { 'key1' => 'value1' },
)

begin
  res = s.input_video.create_media(request: req)
  puts JSON.pretty_generate(JSON.parse(res.raw_response.body))
rescue FastpixClient::Models::Errors::APIError => e
  puts JSON.pretty_generate(JSON.parse(e.body))
rescue StandardError
  puts res.raw_response.body.to_s if defined?(res) && res&.raw_response
end

Available Resources and Operations

Comprehensive Ruby SDK for FastPix platform integration with full API coverage.

Media API

Upload, manage, and transform video content with comprehensive media management capabilities.

For detailed documentation, see FastPix Video on Demand Overview.

Input Video

Manage Videos

Playback

Playlist

Signing Keys

DRM Configurations

Live API

Stream, manage, and transform live video content with real-time broadcasting capabilities.

For detailed documentation, see FastPix Live Stream Overview.

Start Live Stream

Manage Live Stream

Live Playback

Simulcast Stream

Video Data API

Monitor video performance and quality with comprehensive analytics and real-time metrics.

For detailed documentation, see FastPix Video Data Overview.

Metrics

Views

Dimensions

Errors

Transformations

Transform and enhance your video content with AI and editing capabilities.

In-Video AI Features

Error Handling

FastpixClient::Models::Errors::APIError is the primary error class for HTTP error responses. It has the following properties:

Property Type Description
message String Error message
status_code Integer HTTP response status code (e.g. 404)
raw_response Faraday::Response Raw HTTP response
body String HTTP body. Can be empty if no body is returned.

Example

require 'json'
require 'fastpixapi'

Models = ::FastpixClient::Models
s = ::FastpixClient::Fastpixapi.new(
  security: Models::Components::Security.new(
    username: 'your-access-token',
    password: 'your-secret-key'
  )
)

begin
  req = Models::Components::CreateMediaRequest.new(
    inputs: [
      Models::Components::PullVideoInput.new(
        type: 'video',
        url: 'https://static.fastpix.io/fp-sample-video.mp4',
      ),
    ],
    metadata: { 'key1' => 'value1' },
  )
  res = s.input_video.create_media(request: req)
  puts JSON.pretty_generate(JSON.parse(res.raw_response.body))
rescue FastpixClient::Models::Errors::APIError => e
  puts e.message
  puts e.status_code
  puts e.body
rescue StandardError
  puts res.raw_response.body.to_s if defined?(res) && res&.raw_response
end

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url optional parameter when initializing the SDK client instance:

require 'json'
require 'fastpixapi'

Models = ::FastpixClient::Models
s = ::FastpixClient::Fastpixapi.new(
  server_url: 'https://api.fastpix.io/v1/',
  security: Models::Components::Security.new(
    username: 'your-access-token',
    password: 'your-secret-key'
  )
)

req = Models::Components::CreateMediaRequest.new(
  inputs: [
    Models::Components::PullVideoInput.new(
      type: 'video',
      url: 'https://static.fastpix.io/fp-sample-video.mp4',
    ),
  ],
  metadata: { 'key1' => 'value1' },
)

begin
  res = s.input_video.create_media(request: req)
  puts JSON.pretty_generate(JSON.parse(res.raw_response.body))
rescue FastpixClient::Models::Errors::APIError => e
  puts JSON.pretty_generate(JSON.parse(e.body))
rescue StandardError
  puts res.raw_response.body.to_s if defined?(res) && res&.raw_response
end

Development

This Ruby SDK is programmatically generated from our API specifications. Any manual modifications to internal files may be overwritten during subsequent generation cycles.

We value community contributions and feedback. Feel free to submit pull requests or open issues with your suggestions, and we'll do our best to include them in future releases.

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version so you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Detailed Usage

For comprehensive understanding of each API's functionality, including detailed request and response specifications, parameter descriptions, and additional examples, please refer to the FastPix API Reference.

The API reference offers complete documentation for all available endpoints and features, enabling developers to integrate and leverage FastPix APIs effectively.

About

Ruby SDK simplifies integration with the FastPix platform. This SDK is designed for secure and efficient communication with the FastPix API.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages