Version: v0.2.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2014 License: MIT, Apache-2.0 Imports: 7 Imported by: 0



This project implements a Go client library for the Hipchat API.

Pull requests are welcome as the API is limited to only a few calls right now.

Star this or get at me on the Twitters if you end up using this since this is pretty early stage and I may make breaking changes to the API. – @andybons



go get github.com/andybons/hipchat

Example usage:

package main

import (

func main() {
	c := hipchat.Client{AuthToken: "<PUT YOUR AUTH TOKEN HERE>"}
	req := hipchat.MessageRequest{
		RoomId:        "Rat Man's Den",
		From:          "GLaDOS",
		Message:       "Bad news: Combustible lemons failed.",
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,

	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)



Package hipchat provides a client library for the Hipchat REST API.



View Source
const (
	ColorYellow = "yellow"
	ColorRed    = "red"
	ColorGreen  = "green"
	ColorPurple = "purple"
	ColorGray   = "gray"
	ColorRandom = "random"

	FormatText = "text"
	FormatHTML = "html"

	ResponseStatusSent = "sent"
View Source
const (
	ISO8601 = "2006-01-02T15:04:05-0700"


This section is empty.


This section is empty.


type Client

type Client struct {
	AuthToken string

func (*Client) PostMessage

func (c *Client) PostMessage(req MessageRequest) error

func (*Client) RoomHistory

func (c *Client) RoomHistory(id, date, tz string) ([]Message, error)

func (*Client) RoomList

func (c *Client) RoomList() ([]Room, error)

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Code    int
		Type    string
		Message string

type Message

type Message struct {
	// Date message was sent in ISO-8601 format in request timezone.
	ISODate string `json:"date"`

	// Name and user_id of sender. user_id will be "api" for API messages and "guest" for guest messages.
	From struct {
		Name   string
		UserId interface{} `json:"user_id"`

	// Message body.
	Message string

	// Name, size, and URL of uploaded file.
	File struct {
		Name string
		Size int
		URL  string

func (*Message) Time

func (m *Message) Time() (time.Time, error)

type MessageRequest

type MessageRequest struct {
	// Required. ID or name of the room.
	RoomId string

	// Required. Name the message will appear to be sent from. Must be less
	// than 15 characters long. May contain letters, numbers, -, _, and spaces.
	From string

	// Required. The message body. 10,000 characters max.
	Message string

	// Determines how the message is treated by our server and rendered
	// inside HipChat applications.
	// html - Message is rendered as HTML and receives no special treatment.
	// Must be valid HTML and entities must be escaped (e.g.: &amp; instead of &).
	// May contain basic tags: a, b, i, strong, em, br, img, pre, code.
	// Special HipChat features such as @mentions, emoticons, and image previews
	// are NOT supported when using this format.
	// text - Message is treated just like a message sent by a user. Can include
	// @mentions, emoticons, pastes, and auto-detected URLs (Twitter, YouTube, images, etc).
	// (default: html)
	MessageFormat string

	// Whether or not this message should trigger a notification for people
	// in the room (change the tab color, play a sound, etc). Each recipient's
	// notification preferences are taken into account. 0 = false, 1 = true.
	// (default: 0)
	Notify bool

	// Background color for message. One of "yellow", "red", "green",
	// "purple", "gray", or "random".
	// (default: yellow)
	Color string

type Room

type Room struct {
	// The ID of the room.
	Id int `json:"room_id"`

	// The name of the room.
	Name string

	// The current room topic.
	Topic string

	// Time of last activity (sent message) in the room in UNIX time (UTC).
	// May be 0 in rare cases when the time is unknown.
	LastActive int `json:"last_active"`

	// Time the room was created in UNIX time (UTC).
	Created int

	// Whether or not this room is archived.
	Archived bool `json:"is_archived"`

	// Whether or not this room is private.
	Private bool `json:"is_private"`

	// User ID of the room owner.
	OwnerUserId int `json:"owner_user_id"`

	// XMPP/Jabber ID of the room.
	XMPPJabberId string `json:"xmpp_jid"`


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL