Slack API in Go
Go
Permalink
Failed to load latest commit information.
examples Fix nil pointer dereference in websocket.go example Jun 23, 2016
.gitignore Cleanup .gitignore in prep for pull request Oct 6, 2016
.travis.yml Add more versions to travis Mar 5, 2016
LICENSE Implement most of the API and a couple of tests Jan 24, 2015
README.md fix godoc badge. png to svg. Sep 10, 2015
TODO.txt Removed Slack prefix from some structs Aug 16, 2015
admin.go adding function that invites a user to a team, not just a specific ch… Oct 29, 2015
attachments.go Merge pull request #105 from AlphaB/fix-action-confirm Oct 30, 2016
backoff.go Implemented Disconnect and improved error handling/stability. Aug 16, 2015
bots.go Add support for the bots.info API. Oct 9, 2016
bots_test.go Add support for the bots.info API. Oct 9, 2016
channels.go Add missing Unreads parameter Mar 5, 2016
chat.go Posting message as user shouldn't unfurls links by default Mar 17, 2016
comment.go 🎨 Hygiene, Mostly Related To ID Jul 22, 2015
conversation.go Remove num_members as it's not exposed anymore Oct 30, 2016
conversation_test.go Add Tests, Clean Up Embedded Types, Unexport Them Aug 4, 2015
dnd.go Add dnd Mar 5, 2016
dnd_test.go Add dnd Mar 5, 2016
emoji.go Major changes: Slack => Client, SlackWS => RTM. All events are now po… Aug 16, 2015
emoji_test.go Implement most of the API and a couple of tests Jan 24, 2015
files.go Added Channel to GetFilesParameters Apr 16, 2016
groups.go Add missing Unreads parameter Mar 5, 2016
history.go Add missing Unreads parameter Mar 5, 2016
im.go Add missing Unreads parameter Mar 5, 2016
info.go Add support for the bots.info API. Oct 9, 2016
item.go Pulling changes from joefitzgerald Jul 26, 2015
item_test.go 👕 Fix Lint and Vet Errors Jul 22, 2015
messageID.go Simplified ManageConnection to remove unneeded concurrency. Aug 16, 2015
messages.go Parse reactions in messages. Mar 30, 2016
messages_test.go Add More Tests For Message Subtypes Jul 22, 2015
misc.go check the HTTP status code and content type headers Oct 29, 2016
misc_test.go parseResponse -> "post".. it doesn't just parse.. it actually dial ou… Aug 16, 2015
oauth.go Support full OAauth response (for adding hooks and bot users via OAuth) Jan 13, 2016
pagination.go Add comments (still no nearly enough) Jan 27, 2015
pins.go Add stars.add and stars.remove Oct 9, 2015
pins_test.go Parse reactions in messages. Mar 30, 2016
reactions.go Parse reactions in messages. Mar 30, 2016
reactions_test.go Parse reactions in messages. Mar 30, 2016
rtm.go Fix golint issues Aug 23, 2015
search.go Major changes: Slack => Client, SlackWS => RTM. All events are now po… Aug 16, 2015
slack.go Fix debugging and logging Jun 29, 2016
slack_test.go Implement most of the API and a couple of tests Jan 24, 2015
stars.go Add stars.add and stars.remove Oct 9, 2015
stars_test.go Parse reactions in messages. Mar 30, 2016
team.go Fixed a bad comment Oct 6, 2016
team_test.go Finished implementation of Team Access Logs api Oct 6, 2016
users.go adds users.identity api call and tests Oct 18, 2016
users_test.go removing redundant error definition Oct 18, 2016
websocket.go Let slack use an external logger May 27, 2016
websocket_channels.go Remove JSONTimeString Jan 30, 2016
websocket_dm.go 🔤 Document Websocket Files Aug 3, 2015
websocket_dnd.go Add dnd Mar 5, 2016
websocket_files.go Remove JSONTimeString Jan 30, 2016
websocket_groups.go Fixed unmarshalling for channel rename event. Aug 16, 2015
websocket_internals.go Fix golint issues Aug 23, 2015
websocket_managed_conn.go Receiving should not have deadline Sep 29, 2016
websocket_misc.go Fixing merge conflict Mar 5, 2016
websocket_pins.go Remove JSONTimeString Jan 30, 2016
websocket_proxy.go Implement HTTP_PROXY support, for slick. Aug 20, 2015
websocket_reactions.go Add ItemUser to reactions event Mar 5, 2016
websocket_stars.go Remove JSONTimeString Jan 30, 2016
websocket_teams.go Merge pull request #54 from dvdplm/fix/user-is-pointer-in-teamjoinevent Mar 5, 2016
websocket_utils.go Remove JSONTimeString Jan 30, 2016

README.md

Slack API in Go GoDoc Build Status

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.

Note: If you just updated from master and it broke your implementation, please check 0.0.1

Installing

go get

$ go get github.com/nlopes/slack

Example

Getting all groups

import (
    "fmt"

    "github.com/nlopes/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
    // api.SetDebug(true)
    groups, err := api.GetGroups(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

import (
    "fmt"

    "github.com/nlopes/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)
}

Minimal RTM usage:

See https://github.com/nlopes/slack/blob/master/examples/websocket/websocket.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.

License

BSD 2 Clause license