Use the official Mux SDK for Ruby to call the Mux API from your server. The SDK handles authentication and wraps each API endpoint in native Ruby code.
The Mux SDK for Ruby wraps the Mux REST API in native Ruby code. Use this SDK when you write your server application in Ruby. You can create assets, manage live streams, and query Mux Data without manual HTTP requests.
Add mux_ruby to your project's Gemfile.
gem 'mux_ruby'To start, you'll need a Mux access token. Once you've got that, you're off to the races!
require 'mux_ruby'
# Auth Setup
openapi = MuxRuby.configure do |config|
config.username = ENV['MUX_TOKEN_ID']
config.password = ENV['MUX_TOKEN_SECRET']
end
# API Client Init
assets_api = MuxRuby::AssetsApi.new
# List Assets
puts "Listing Assets in account:\n\n"
assets = assets_api.list_assets()
assets.data.each do | asset |
puts "Asset ID: #{asset.id}"
puts "Status: #{asset.status}"
puts "Duration: #{asset.duration.to_s}\n\n"
endCheck out the Mux Ruby SDK docs for more information.