Skip to content

treelab/stream-chat-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Official Go SDK for Stream Chat

build godoc

Official Go API client for Stream Chat, a service for building chat applications.
Explore the docs »

Report Bug · Request Feature

📝 About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access chat API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).

⚙️ Installation

go get github.com/GetStream/stream-chat-go/v6

✨ Getting started

package main

import (
	"os"

	stream "github.com/GetStream/stream-chat-go/v6"
)

var APIKey = os.Getenv("STREAM_KEY")
var APISecret = os.Getenv("STREAM_SECRET")
var userID = "" // your server user id

func main() {
	// Initialize client
	client, err := stream.NewClient(APIKey, APISecret)
	
	// Or with a specific timeout
	client, err := stream.NewClient(APIKey, APISecret, WithTimeout(3 * time.Second))

	// Or using only environmental variables: (required) STREAM_KEY, (required) STREAM_SECRET,
	// (optional) STREAM_CHAT_TIMEOUT
	client, err := stream.NewClientFromEnvVars()

	// handle error

	// use client methods

	// create channel with users
	users := []string{"id1", "id2", "id3"}
	channel, err := client.CreateChannelWithMembers(ctx, "messaging", "channel-id", userID, users...)

	// use channel methods
	msg, err := channel.SendMessage(ctx, &stream.Message{Text: "hello"}, userID)
}

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Head over to CONTRIBUTING.md for some development tips.

🧑‍💻 We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.