Skip to content
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

Merged
merged 6 commits into from
Jul 13, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest combining the imports:

import (
 "log"
 "context"
 "time"

 "github.com/luno/luno-go"
)

"log"
"context"
"time"
)

lunoClient := luno.NewClient()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, would you mind putting this in a func main() { } ?

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The 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:
Copy link
Collaborator

Choose a reason for hiding this comment

The 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>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -> export

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: remove empty line

```

Copy link
Collaborator

Choose a reason for hiding this comment

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