-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated the README to show a working example for the latest version (Closes #52) #53
Changes from 2 commits
2c5b792
f024279
8f05b1d
b7e8877
171ecf1
8650689
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,33 +9,66 @@ This Go package provides a wrapper for the [Luno API](https://www.luno.com/api). | |
Please visit [godoc.org](https://godoc.org/github.com/luno/luno-go) for the full | ||
package documentation. | ||
|
||
### Authentication | ||
|
||
Please visit the [Settings](https://www.luno.com/wallet/settings/api_keys) page | ||
to generate an API key. | ||
|
||
### Installation | ||
|
||
``` | ||
go get github.com/luno/luno-go | ||
``` | ||
|
||
### Authentication | ||
|
||
Please visit the [Settings](https://www.luno.com/wallet/settings/api_keys) page | ||
to generate an API key. | ||
|
||
### Example usage | ||
|
||
A full working example of this library in action. | ||
|
||
```go | ||
package main | ||
|
||
import luno "github.com/luno/luno-go" | ||
import ( | ||
"log" | ||
"context" | ||
"time" | ||
) | ||
|
||
lunoClient := luno.NewClient() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you're at it, would you mind putting this in a |
||
lunoClient.SetAuth("api_key_id", "api_key_secret") | ||
lunoClient.SetAuth("<API_KEY_ID>", "<API_KEY_SECRET>") | ||
|
||
req := luno.GetOrderBookRequest{Pair: "XBTZAR"} | ||
res, err := lunoClient.GetOrderBook(&req) | ||
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 `<API_KEY_ID>` and `<API_KEY_SECRET>` for your own Id and Secret. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nipick: lowercase id + secret |
||
|
||
It is also recommended to set these as environment variables rather than include them in plaintext. You can do this on `BASH` with: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest: We recommend using environment variables rather than including your credentials in plaintext. In bash you do so as follows: |
||
|
||
``` | ||
$ set LUNO_API_ID="<API_KEY_ID>" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set -> export There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this one was a brain fart on my end... |
||
$ set LUNO_API_SECRET="<API_KEY_SECRET>" | ||
``` | ||
|
||
And then access them in Go like so: | ||
|
||
```go | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: remove empty line |
||
import "os" | ||
|
||
var API_KEY_ID string = os.Getenv("LUNO_API_ID") | ||
var API_KEY_SECRET string = os.Getenv("LUNO_API_SECRET") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: remove empty line |
||
``` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: remove two empty lines |
||
|
||
### License | ||
|
||
[MIT](https://github.com/luno/luno-go/blob/master/LICENSE.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest combining the imports: