0.0
The project is in a healthy, maintained state
Ruby Client SDK Generated by Speakeasy
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

 Project Readme

plexruby

Summary

Plex-API: An Open API Spec for interacting with Plex.tv and Plex Media Server

Plex Media Server OpenAPI Specification

An Open Source OpenAPI Specification for Plex Media Server

Automation and SDKs provided by Speakeasy

Documentation

API Documentation

SDKs

The following SDKs are generated from the OpenAPI Specification. They are automatically generated and may not be fully tested. If you find any issues, please open an issue on the main specification Repository.

Language Repository Releases Other
Python GitHub PyPI -
JavaScript/TypeScript GitHub NPM \ JSR -
Go GitHub Releases GoDoc
Ruby GitHub Releases -
Swift GitHub Releases -
PHP GitHub Releases -
Java GitHub Releases -
C# GitHub Releases -

Table of Contents

  • plexruby
  • Plex Media Server OpenAPI Specification
    • Documentation
    • SDKs
    • SDK Installation
    • SDK Example Usage
    • Authentication
    • Available Resources and Operations
    • Error Handling
    • Server Selection
  • Development
    • Maturity
    • Contributions

SDK Installation

The SDK can be installed using RubyGems:

gem install plex_ruby_sdk

SDK Example Usage

Example

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      security: Models::Shared::Security.new(
        access_token: "<YOUR_API_KEY_HERE>",
      ),
    )

res = s.server.get_server_capabilities()

if ! res.object.nil?
  # handle response
end

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
access_token apiKey API key

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      security: Models::Shared::Security.new(
        access_token: "<YOUR_API_KEY_HERE>",
      ),
    )

res = s.server.get_server_capabilities()

if ! res.object.nil?
  # handle response
end

Available Resources and Operations

Available methods
  • get_users - Get list of all connected users

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.

By default an API error will raise a Errors::APIError, which has the following properties:

Property Type Description
message string The error message
status_code int The HTTP status code
raw_response Faraday::Response The raw HTTP response
body string The response content

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 get_server_capabilities method throws the following exceptions:

Error Type Status Code Content Type
Models::Errors::GetServerCapabilitiesBadRequest 400 application/json
Models::Errors::GetServerCapabilitiesUnauthorized 401 application/json
Errors::APIError 4XX, 5XX */*

Example

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      security: Models::Shared::Security.new(
        access_token: '<YOUR_API_KEY_HERE>',
      ),
    )

begin
    res = s.server.get_server_capabilities()

    if ! res.object.nil?
      # handle response
    end
rescue Models::Errors::GetServerCapabilitiesBadRequest => e
  # handle $e->$container data
  throw $e;
rescue Models::Errors::GetServerCapabilitiesUnauthorized => e
  # handle $e->$container data
  throw $e;
rescue Errors::APIError => e
  # handle default exception
  raise e
end

Server Selection

Server Variables

The default server {protocol}://{ip}:{port} contains variables and is set to https://10.10.10.47:32400 by default. To override default values, the following parameters are available when initializing the SDK client instance:

Variable Parameter Supported Values Default Description
protocol protocol (::PlexRubySDK::Models::ServerVariables::ServerProtocol) - "http"
- "https"
"https" The protocol to use for the server connection
ip ip (::String) ::String "10.10.10.47" The IP address or hostname of your Plex Server
port port (::String) ::String "32400" The port of your Plex Server

Example

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      protocol: "https",
      ip: "e0c3:bcc0:6bac:dccc:c4ec:34b1:ca98:4cb9",
      port: "40311",
      security: Models::Shared::Security.new(
        access_token: "<YOUR_API_KEY_HERE>",
      ),
    )

res = s.server.get_server_capabilities()

if ! res.object.nil?
  # handle response
end

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url (String) optional parameter when initializing the SDK client instance. For example:

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      server_url: "https://10.10.10.47:32400",
      security: Models::Shared::Security.new(
        access_token: "<YOUR_API_KEY_HERE>",
      ),
    )

res = s.server.get_server_capabilities()

if ! res.object.nil?
  # handle response
end

Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

require 'plex_ruby_sdk'

s = ::PlexRubySDK::PlexAPI.new(
      security: Models::Shared::Security.new(
        access_token: "<YOUR_API_KEY_HERE>",
      ),
    )

res = s.plex.get_companions_data(server_url: "https://plex.tv/api/v2")

if ! res.response_bodies.nil?
  # handle response
end

Development

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. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy