2.06 KB

Go Twitter Tools

The Twitter Microblog Track runs a rather special Evaluation as a service model, which allows participants to connect to a server to perform queries using a thrift-based API. This package provides a set of Go bindings for performing queries to the service, in addition to a wrapper library which simplifies its use.


The library requires the thrift package from Apache, which can be installed using:

go get


Go get can handle installation for you.

go get


The library is modelled loosely on the official Microblog track client, which is written in Java. It’s very simple and implements 3 basic actions:

  1. Create a connection
  2. Perform a query and return results
  3. Close the connection.

All of these are demonstrated in the example below.

package main

import (

func main() {
    // Create a new client using the settings in conf.json
    client, err := twittertools.NewClientFromConf("conf.json")
    if err != nil {
    defer client.Close()

    // query the server for "glasgow", retreive the top 50 results
    // -1 signifies that there is no maximum tweet ID
    results, err := client.Search("Glasgow", 50, -1)
    if err != nil {

    // Iterate over the results, printing text from each tweet
    for k, result := range results {
        fmt.Println(k, result.Text)

The example uses a conf.json file (example below) to load the server details and your team details. If you’d rather hard-code the values, the twittertools.NewClientFromDetails(host, port, group, token) function allows you to create a new client and specify the details manually.

  "Host":  "",
  "Port":  9091,
  "Group": "UrTeamName",
  "Token": "de4db33f"