Installation

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 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, including scripting and AI-agent workflows. Install the CLI and the default Agent Skills:

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

Then ask your agent in plain English, for example:

/stream List feed groups in my app.

See the CLI docs and Agent Skills docs for more.

go get github.com/GetStream/getstream-go/v4@v4.0.6

Use the latest available SDK release when starting a new integration.
Check getstream-go releases and replace the version if a newer one is available.

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

The package is tested against these environments:

  • Go 1.19+
  • Go 1.20+
  • Go 1.21+

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 (30000ms).

package main

import (
    "context"
    "log"
    "time"

    "github.com/GetStream/getstream-go/v4"
)

func main() {
    apiKey := ""
    secret := ""

    client, err := getstream.NewClient(apiKey, secret)
    if err != nil {
        log.Fatal(err)
    }

    // optionally override the per-request timeout (default is 30s)
    client, err = getstream.NewClient(apiKey, secret, getstream.WithRequestTimeout(30*time.Second))
    if err != nil {
        log.Fatal(err)
    }

    // Get the feeds client
    feedsClient := client.Feeds()

    ctx := context.Background()

    // Your feeds operations here...
}

Connection pool and timeouts

The shared defaults and tuning options are documented on Connection pooling; this section covers the Go specifics.

By default the SDK uses an HTTP connection pool with keep-alive enabled. You can tune it with functional options:

OptionDefaultDescription
WithRequestTimeout (alias WithTimeout)30sPer-request timeout. Override per call with context.WithTimeout.
WithMaxConnsPerHost5Maximum concurrent connections per host.
WithIdleTimeout55sHow long idle connections stay in the pool.
WithConnectTimeout10sTCP + TLS handshake timeout.
client, err := getstream.NewClient(
    apiKey, secret,
    getstream.WithMaxConnsPerHost(10),
    getstream.WithIdleTimeout(55*time.Second),
    getstream.WithConnectTimeout(10*time.Second),
    getstream.WithRequestTimeout(30*time.Second),
)

You can also set the request timeout (in seconds) with the STREAM_HTTP_TIMEOUT environment variable.

To take full control of the HTTP stack, provide your own client with WithHTTPClient. When set, the pool options above are not applied:

client, err := getstream.NewClient(apiKey, secret, getstream.WithHTTPClient(myHTTPClient))