Unofficial Go Client for VALR
This is currently a work-in-progress and not fully tested.
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
}
// 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)
}
// 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 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)
Please feel free to submit issues, fork the repositoy and send pull requests!
This project is licensed under the terms of the MIT license.