Installation

gem install getstream-ruby

GitHub repository: https://github.com/GetStream/getstream-ruby. Feel free to submit bug reports and feature requests.

The package is tested against these environments:

  • Ruby 3.0+
  • Ruby 3.1+
  • Ruby 3.2+
  • Ruby 3.3+

Note: Ruby 3.0 or higher is required.

To create a client, you'll need your API key and secret. Both of them can be found in your Stream Dashboard.

You can optionally configure request timeouts and the HTTP connection pool. The default request timeout is 30 seconds.

require 'getstream_ruby'

# Create client using manual configuration
client = GetStreamRuby.manual(
  api_key: 'your_api_key',
  api_secret: 'your_api_secret'
)

# Get the feeds client
feeds_client = client.feeds

# Your feeds operations here...

Alternative initialization methods

Using .env file

Create a .env file in your project root:

STREAM_API_KEY=your_api_key
STREAM_API_SECRET=your_api_secret

Then initialize the client:

require 'getstream_ruby'

# Initialize client from .env file
client = GetStreamRuby.env
# or
client = GetStreamRuby.client  # defaults to .env

# Get the feeds client
feeds_client = client.feeds

Using environment variables

require 'getstream_ruby'

# Set environment variables (or export them in your shell)
ENV['STREAM_API_KEY'] = 'your_api_key'
ENV['STREAM_API_SECRET'] = 'your_api_secret'

# Initialize client from environment variables
client = GetStreamRuby.env_vars

# Get the feeds client
feeds_client = client.feeds

Connection pool and timeouts

The SDK uses Faraday with a persistent (keep-alive) connection pool. Tune it when creating the client:

OptionDefaultDescription
request_timeout (alias timeout)30Per-request timeout in seconds.
max_conns_per_host5Maximum concurrent connections per host.
idle_timeout55Idle connection lifetime in seconds.
connect_timeout10TCP + TLS handshake timeout in seconds.
client = GetStreamRuby.manual(
  api_key: 'your_api_key',
  api_secret: 'your_api_secret',
  max_conns_per_host: 10,
  idle_timeout: 55,
  connect_timeout: 10,
  request_timeout: 30
)

When you initialize from the environment (GetStreamRuby.env or GetStreamRuby.env_vars), the same knobs can be set with STREAM_REQUEST_TIMEOUT (or STREAM_TIMEOUT), STREAM_MAX_CONNS_PER_HOST, STREAM_IDLE_TIMEOUT, and STREAM_CONNECT_TIMEOUT.

To take full control of the HTTP stack, pass a pre-built Faraday::Connection with http_client:. When set, the pool options above are not applied.