Skip to content

luno/luno-go

Repository files navigation

Quality Gate Status Coverage Bugs Security Rating Vulnerabilities Duplicated Lines (%) Go Report Card GoDoc

Luno Go SDK

This Go package provides a wrapper for the Luno API.

Documentation

Please visit godoc.org for the full package documentation.

Authentication

Please visit the Settings page to generate an API key.

Installation

go get github.com/luno/luno-go

Example usage

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

License

MIT