slack-go /slack

Slack API in Go

★ 4,973⑂ 1,203👁 50⑃ 1,113● 574▤ 79
GoBSD-2-ClauseCreated 2015-01-24pkg.go.dev/github.com/slack-go/slack
Download: v0.36.0v0.36.0 ↓0.36.02026-11-14
+0
Daily
4,973
stars
1,203
forks
50
watchers
1,113
prs
574
issues
79
releases

README

Slack API in Go  
===============

You can chat with us on the slack-go, slack-go-ja Slack channel on the Gophers Slack.

!logo

This library supports most if not all of the api.slack.com REST
calls, as well as the Real-Time Messaging protocol over websocket, in
a fully managed way.

 Project Status
There is currently no major version released.
Therefore, minor version releases may include backward incompatible changes.

See Releases for more information about the changes.

 Go Versions supported

We support the same versions of Go as the officially supported Go versions (see Go
Release Policy).

 Installing

 go get

bash
go get -u github.com/slack-go/slack


 Example

 Getting all groups

golang
import (
    "fmt"

    "github.com/slack-go/slack"
)

func main() {
    api := slack.New("YOUR_TOKEN_HERE")
    // If you set debugging, it will log all requests to the console
    // Useful when encountering issues
    // slack.New("YOUR_TOKEN_HERE", slack.OptionDebug(true))
    groups, err := api.GetUserGroups(slack.GetUserGroupsOptionIncludeUsers(false))
    if err != nil {
        fmt.Printf("%s\n", err)
        return
    }
    for _, group := range groups {
        fmt.Printf("ID: %s, Name: %s\n", group.ID, group.Name)
    }
}


 Getting User Information

golang
import (
    "fmt"

    "github.com/slack-go/slack"
)

func main() {
    api := slack.New("YOUR_TOKEN_HERE")
    user, err := api.GetUserInfo("U023BECGF")
    if err != nil {
        fmt.Printf("%s\n", err)
        return
    }
    fmt.Printf("ID: %s, Fullname: %s, Email: %s\n", user.ID, user.Profile.RealName, user.Profile.Email)
}


 HTTP retries

Retries are off by default. Use OptionRetry(n) for 429-only retries, or OptionRetryConfig(cfg) for full control (connection, 429, opt-in 5xx). With a custom client, pass retry options after OptionHTTPClient. See package slack doc for handler details.

golang
api := slack.New("YOUR_TOKEN_HERE", slack.OptionRetry(3))


 Minimal Socket Mode usage:

See https://github.com/slack-go/slack/blob/master/examples/socketmode/socketmode.go


 Minimal RTM usage:

As mentioned in https://api.slack.com/rtm - for most applications, Socket Mode is a better way to communicate with Slack.

See https://github.com/slack-go/slack/blob/master/examples/websocket/websocket.go


 Minimal EventsAPI usage:

See https://github.com/slack-go/slack/blob/master/examples/eventsapi/events.go

 Socketmode Event Handler (Experimental)

When using socket mode, dealing with an event can be pretty lengthy as it requires you to route the event to the right place.

Instead, you can use SocketmodeHandler much like you use an HTTP handler to register which event you would like to listen to and what callback function will process that event when it occurs.

See ./examples/socketmode_handler/socketmode_handler.go
 Contributing

You are more than welcome to contribute to this project.  Fork and
make a Pull Request, or create an Issue if you see any problem.

Before making any Pull Request p

Discussions

Latest release

v0.36.0 v0.36.0 2026-11-14
Thanks again to Michal (@akfaew) for another round of fixes in this release.

 Breaking changes — read before upgrading

 [!WARNING]
 v0.36.0 includes breaking API, decoding, and serialization changes.

 Your code may fail to compile. Code that still compiles may decode or serialize
 differently. Events API URL-verification responses now use a different JSON key.

 Review every item below before upgrading, including RTM and Events API handlers,
 tests that build or compare event payloads, and code that decodes into reused values.

 1. RTM group_rename event types have changed

- slack.GroupRen

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON