Skip to content

Instantly share code, notes, and snippets.

@luizpaulogodoy
Created May 8, 2019 14:01
Show Gist options
  • Save luizpaulogodoy/8981d19adae4b45a77f6932f878116db to your computer and use it in GitHub Desktop.
Save luizpaulogodoy/8981d19adae4b45a77f6932f878116db to your computer and use it in GitHub Desktop.
BitRecife Private Request example
package main
import (
"crypto/hmac"
"crypto/sha512"
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
)
func main() {
url := "https://exchange.bitrecife.com.br/api/v3/private/getbalances?" + "&apikey=API_KEY&nonce=" + strconv.Itoa(int(time.Now().Unix()))
apisignhmac512 := hmac.New(sha512.New, []byte("API_SECRET"))
apisignhmac512.Write([]byte(url))
apisign := hex.EncodeToString(apisignhmac512.Sum(nil))
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Println(err)
}
req.Header.Set("apisign", apisign)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Println(err)
}
defer resp.Body.Close()
response, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
}
fmt.Println(string(response))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment