# Installation

>
> **Note:** This SDK is the server half of your integration. Your users read and write feeds from your app with a client SDK, and anything that needs a connected user or a live WebSocket belongs there: the state layer, device push registration, and client-side error handling. See the [client-side overview](https://getstream.io/activity-feeds/docs/ruby/client-side/) for what lives there. Token signing stays on this side, because it needs your API secret.
>

## Stream CLI and Agent Skills

Manage Stream from your terminal with the [Stream CLI](https://getstream.io/cli/docs/), including scripting and AI-agent workflows. Install the CLI and the default [Agent Skills](https://getstream.io/agent-skills/docs/):

```bash
curl -fsSL https://getstream.io/cli.sh | bash
getstream skills
```

Then ask your agent in plain English, for example:

```text
/stream List feed groups in my app.
```

See the [CLI docs](https://getstream.io/cli/docs/) and [Agent Skills docs](https://getstream.io/agent-skills/docs/) for more.

```bash
gem install getstream-ruby
```

GitHub repository: [https://github.com/GetStream/getstream-ruby](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](https://getstream.io/signin/?product=feeds).

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

```ruby
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:

```bash
STREAM_API_KEY=your_api_key
STREAM_API_SECRET=your_api_secret
```

Then initialize the client:

```ruby
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

```ruby
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 shared defaults and tuning options are documented on [Connection pooling](https://getstream.io/docs/platform/connection-pooling/); this section covers the Ruby specifics.

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

| Option                              | Default | Description                              |
| ----------------------------------- | ------- | ---------------------------------------- |
| `request_timeout` (alias `timeout`) | `30`    | Per-request timeout in seconds.          |
| `max_conns_per_host`                | `100`   | Maximum concurrent connections per host. |
| `idle_timeout`                      | `55`    | Idle connection lifetime in seconds.     |
| `connect_timeout`                   | `10`    | TCP + TLS handshake timeout in seconds.  |

```ruby
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.

---

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/ruby/installation/](https://getstream.io/activity-feeds/docs/ruby/installation/).