# Getting Started

## Setup

The official Go SDK for Stream covers Chat, Video, Moderation, and Feeds.

|             |                                                                                                            |
| ----------- | ---------------------------------------------------------------------------------------------------------- |
| GitHub      | [github.com/GetStream/getstream-go](https://github.com/GetStream/getstream-go)                             |
| Go Packages | [pkg.go.dev/github.com/GetStream/getstream-go/v4](https://pkg.go.dev/github.com/GetStream/getstream-go/v4) |

Install the SDK:

```go
go get github.com/GetStream/getstream-go/v4
```

Initialize the client with your API key and secret (available on the [Dashboard](https://dashboard.getstream.io/)):

```go
import "github.com/GetStream/getstream-go/v4"

client, err := getstream.NewClient("your-api-key", "your-api-secret")
if err != nil {
    panic(err)
}
```

You can also load credentials from environment variables (`STREAM_API_KEY`, `STREAM_API_SECRET`):

```go
client, err := getstream.NewClientFromEnvVars()
```

## Server-side Token

Your backend generates a user token that the client SDKs use to authenticate. A typical place to issue this token is during login or registration.

```go
token, err := client.CreateToken("user-id")
if err != nil {
    panic(err)
}
// return the token to the client app
```

Tokens with an expiry:

```go
token, err := client.CreateToken("user-id",
    getstream.WithExpiration(24 * time.Hour))
```

## Making Your First API Call

Create a user, open a channel, and send a message:

```go
// Upsert a user
client.UpdateUsers(ctx, &getstream.UpdateUsersRequest{
    Users: map[string]getstream.UserRequest{
        "john": {ID: "john", Name: getstream.PtrTo("John")},
    },
})

// Create or join a channel
channel := client.Chat().Channel("messaging", "hello-world")
channel.GetOrCreate(ctx, &getstream.GetOrCreateChannelRequest{
    Data: &getstream.ChannelInput{
        CreatedByID: getstream.PtrTo("john"),
    },
})

// Send a message
channel.SendMessage(ctx, &getstream.SendMessageRequest{
    Message: getstream.MessageRequest{
        Text:   getstream.PtrTo("Hello, Stream!"),
        UserID: getstream.PtrTo("john"),
    },
})
```


---

This page was last updated at 2026-05-19T19:59:06.978Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/go-golang/](https://getstream.io/chat/docs/go-golang/).