A Golang client library for the Sqwiggle API.
- Attachments
- Conversations
- Info
- Invites
- Messages
- Organizations
- Streams
- Users
go get github.com/hermanschaaf/sqwiggle
The following example lists the 50 most recent messages across all streams, and prints them out.
package main
import (
"fmt"
"github.com/hermanschaaf/sqwiggle"
)
// The following code instantiates a client, then calls the
// ListMessages method to return a slice of Messages. If no error occurred, it
// iterates through the messages and prints them out one by one.
func main() {
client := sqwiggle.NewClient("YOUR-API-KEY")
page, limit := 0, 50
msgs, err := client.ListMessages(page, limit)
if err != nil {
panic(err)
}
for _, m := range msgs {
fmt.Printf("%s: %s\n", m.Author.Name, m.Text)
}
}
When instantiating a new client, it is also possible to use your own HTTPClient:
client := Client{
APIKey: "YOUR-API-KEY",
RootURL: "https://api.sqwiggle.com/", // customize the URL
HTTPClient: &http.Client{}, // your own custom http.Client
}
This is useful in testing environments, for example (and is used in the tests for this package).
https://godoc.org/github.com/hermanschaaf/sqwiggle
There are plenty more usage examples in the docs and also in sqwiggle_test.go.
MIT License