Ruby SDK

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

Add secure, scalable video to your Ruby project

The FastPix Ruby 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 Ruby server

Prerequisites

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

  • Ruby 2.7 or later: This SDK is compatible with Ruby 2.7 or higher
  • RubyGems and Bundler: Required for dependency management
  • IDE: RubyMine, VS Code with Ruby extensions, or any text editor of your choice
  • 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 Ruby and REST APIs: Familiarity with Ruby development and API integration concepts

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

Import the SDK

require 'json'
require 'fastpixapi'

Models = ::FastpixClient::Models

Example

Let's create a file named example.rb

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 and your-secret-key with the Access Token ID and Secret Key values from the .env file you downloaded.

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

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 Ruby script, use the following command. Make sure to replace example.rb with your actual file name if it's different:

ruby example.rb

NOTE

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


Full documentation

See the FastPix Ruby SDK for additional examples, API methods, and advanced usage.