This Go package provides a wrapper for the Luno API.
Please visit godoc.org for the full package documentation.
Please visit the Settings page to generate an API key.
go get github.com/luno/luno-go
A full working example of this library in action.
package main
import (
"log"
"context"
"time"
"github.com/luno/luno-go"
)
func main() {
lunoClient := luno.NewClient()
lunoClient.SetAuth("<id>", "<secret>")
req := luno.GetOrderBookRequest{Pair: "XBTZAR"}
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(10*time.Second))
defer cancel()
res, err := lunoClient.GetOrderBook(ctx, &req)
if err != nil {
log.Fatal(err)
}
log.Println(res)
}
Remember to substitute <id>
and <secret>
for your own Id and Secret.
We recommend using environment variables rather than including your credentials in plaintext. In Bash you do so as follows:
export LUNO_API_ID="<id>"
export LUNO_API_SECRET="<secret>"
And then access them in Go like so:
import "os"
var API_KEY_ID string = os.Getenv("LUNO_API_ID")
var API_KEY_SECRET string = os.Getenv("LUNO_API_SECRET")