Skip to content

Latest commit

 

History

History
85 lines (68 loc) · 2.49 KB

README.md

File metadata and controls

85 lines (68 loc) · 2.49 KB

VALR

Unofficial Go Client for VALR

This is currently a work-in-progress and not fully tested.

Build Status Go Report Card GoDoc License

Installation

To install valr, use go get:

go get github.com/nickcorin/valr

Import the valr package into your code:

package main

import "github.com/nickcorin/valr"

func main() {
	client := valr.DefaultClient
}

Usage

Using the DefaultClient.

// The default (public) client can access all public endpoints without
// providing authentication.
ctx := context.Background()
book, err := valr.DefaultClient.OrderBook(ctx, "BTCZAR")
if err != nil {
  log.Fatal(err)
}

Accessing authenticated endpoints.

// To access authentiated endpoints, you need to construct a (private)
// client.
client := valr.NewClient("my-api-key", "my-api-secret")

ctx := context.Background()
orderID, err := client.LimitOrder(ctx, valr.LimitOrderRequest{
  CustomerOrderID:  "1234",
  Pair:             "BTCZAR",
  PostOnly:         true,
  Price:            "200000",
  Quantity:         "0.100000",
  Side:             "SELL",
})
if err != nil {
  log.Fatal(err)
}

Public vs Private clients.

// Public clients are only able to access public endpoints.
public := valr.NewPublicClient()

// A normal (or private) client is able to access all endpoints.
private := valr.NewClient("my-api-key", "my-api-secret")

// You can convert a public client to a private client if ou want to.
private = valr.ToPrivateClient(public, "my-api-key", "my-api-secret")

// ...or vice versa.
public = valr.ToPublicClient(private)

Contributing

Please feel free to submit issues, fork the repositoy and send pull requests!

License

This project is licensed under the terms of the MIT license.