Skip to content

sakurahilljp/ambient-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ambient-Go

Ambient client library for Go language

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)
  }
}

Installation

To install ambient-go in your $GOPATH:

$ go get  -u github.com/sakurahilljp/ambient-go
import "github.com/sakurahilljp/ambient-go"

API

GoDoc: https://godoc.org/github.com/sakurahilljp/ambient-go

Send

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)

Read

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)

GetProp

Get properties of a channel.

prop, err := client.GetProp()

About

Ambient client library for Go language (golang)

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages