Skip to content

Instantly share code, notes, and snippets.

@luizpaulogodoy
Created July 9, 2019 13:36
Show Gist options
  • Save luizpaulogodoy/4837dbe0757dd1ea626122b05f5322fa to your computer and use it in GitHub Desktop.
Save luizpaulogodoy/4837dbe0757dd1ea626122b05f5322fa to your computer and use it in GitHub Desktop.
package main
import (
"crypto/hmac"
"crypto/sha512"
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
)
func main() {
APIKey := ""
APISecret := ""
url := "https://exchange.bitrecife.com.br/api/v3/private/getbalances?apikey=" + APIKey + "&nonce=" + strconv.Itoa(int(time.Now().Unix()))
apisignhmac512 := hmac.New(sha512.New, []byte(APISecret))
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