Ambient client library for Go language
- https://ambidata.io (Ambient - IoTデーターの可視化サービス)
This library is base on Ambient Python client library
package main
import (
"log"
"github.com/sakurahilljp/ambient-go"
)
func main() {
client := ambient.NewClient(1234, "writeky")
dp := ambient.NewDataPoint()
dp["d1"] = ReadTemperature()
dp["d2"] = ReadPressure()
dp["d2"] = ReadHumidity()
err := client.Send(dp)
if err != nil {
log.Fatal(err)
}
}To install ambient-go in your $GOPATH:
$ go get -u github.com/sakurahilljp/ambient-goimport "github.com/sakurahilljp/ambient-go"GoDoc: https://godoc.org/github.com/sakurahilljp/ambient-go
Send a signle point with automatic timestamp
client := NewClient(1234, "writekey")
dp := NewDataPoint()
dp["d1"] = 19.2
dp["d2"] = 21.3
client.Send(dp)Send multiple points with explicit timestamp
client := NewClient(1234, "writekey")
t1 := time.Now()
dp1 := NewDataPoint(t1)
dp1["d1"] = 1.23
t2 := time.Now()
dp2 := NewDataPoint(t2)
dp2["d1"] = 2.34
c.Send(dp1, dp2)Specifies data points with count and skip
values, err := client.Read(Count(100))
values, err := client.Read(Count(100), Skip(100))Read data points at a specified date
values, err := client.Read(Date(time.Now())Read data points in a specified time ranage.
ent := time.Now()
start := end.Add(-time.Hour * 24)
values, err := client.Read(start, end)Get properties of a channel.
prop, err := client.GetProp()