Skip to content
Go client library for the Geckoboard API.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
vendor
.travis.yml
LICENSE
README.md
client.go Add ErrExceededPushLimit Jan 2, 2018
client_test.go Fix delete test bug Jan 1, 2018
types.go

README.md

GeckoClient

Go/Golang client library for Geckoboard API (https://developer.geckoboard.com/api-reference/).

Install

go get github.com/influx6/geckoclient

Tests

To run tests you need to provided a test client API Authentication key as an environment variable GECKOBOARD_TEST_API_KEY.

GECKOBOARD_TEST_API_KEY=222efc82e7933138077b1c2554439e15 go test -v

Create new client

New Client verifies API Key to ensure user has valid API auth.

client, err := geckoclient.New("222efc82e7933138077b1c2554439e15")

Create Dataset

Create new dataset.

client.Create(context.Background(), "sales.gross", geckoclient.NewDataset{
	UniqueBy: []string{"date"},
	Fields: map[string]geckoclient.DataType{
		"name": geckoclient.StringType{
			Name: "transaction_target",
		},
		"amount": geckoclient.NumberType{
			Name: "transaction_amount",
		},
		"date": geckoclient.DateType{
			Name: "transaction_date",
		},
	},
})

UniqueBy is an optional array of one or more field names whose values will be unique across all your records.

Available field types:

  • DateType
  • DateTimeType
  • NumberType
  • PercentageType
  • StringType
  • MoneyType

Delete

Delete a dataset and all data therein.

client.Delete(context.Background(), "sales.gross")

Put

Replace all data in the dataset.

client.ReplaceData(context.Background(), "sales.gross", geckoclient.Dataset{
	Data: []map[string]interface{}{
		{
			"amount": 300,
			"name":   "Waxon Butter",
			"date":   now.Format(isoTime),
		},
		{
			"amount": 1300,
			"name":   "Shred Lack",
			"date":   now.Add(time.Hour * 30).Format(isoTime),
		},
		{
			"amount": 500,
			"name":   "Creg Washer",
			"date":   now.Add(time.Hour * 10).Format(isoTime),
		},
	},
})

Post

Append data to a dataset.

client.PushData(context.Background(), "sales.gross", geckoclient.Dataset{
	DeleteBy: []string{"name"},
	Data: []map[string]interface{}{
		{
			"amount": 300,
			"name":   "Waxon Butter",
			"date":   now.Format(isoTime),
		},
		{
			"amount": 1300,
			"name":   "Shred Lack",
			"date":   now.Add(time.Hour * 30).Format(isoTime),
		},
		{
			"amount": 500,
			"name":   "Creg Washer",
			"date":   now.Add(time.Hour * 10).Format(isoTime),
		},
	},
})

DeleteBy is an optional field by which to order the truncation of records once the maximum record count has been reached. By default the oldest records (by insertion time) will be removed.

Vendoring

Vendoring is done with Govendor.

Contributing

  1. Fork it ( https://github.com/influx6/geckoclient/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
You can’t perform that action at this time.