Gists
By the Google’s update at June 19, 2018, finally, Utilities.computeDigest(), Utilities.computeHmacSha256Signature() and Utilities.computeHmacSignature() got to be able to use the byte arrays. By this, using only native Google Apps Script, the result can be retrieved without using jsSHA. So Cryptopia API can be created using only Google Apps Script. If this is useful for you, I'm glad.
Sample script : When you use this, at first, please input the requiring values.
Gists
This sample script is for using Zaif API by Google Apps Script.
The following go script is a sample at Zaif API.
package main
import (
"fmt"
"time"
"strconv"
"crypto/hmac"
"crypto/sha512"
"io/ioutil"
"net/http"
"encoding/hex"
"net/url"
"strings"
)
var key = "<your_key>"
var secret = "<your_secret>"
func main() {
uri := "https://api.zaif.jp/tapi"
values := url.Values{}
values.Add("method", "get_info")
values.Add("nonce", strconv.FormatInt(time.Now().Unix(), 10))
encodedParams := values.Encode()
req, _ := http.NewRequest("POST", uri, strings.NewReader(encodedParams))
hash := hmac.
Gists
This sample script is for using Bittrex API by Google Apps Script.
The following PHP script is a sample at bittrex.com.
$apikey='xxx';
$apisecret='xxx';
$nonce=time();
$uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce;
$sign=hash_hmac('sha512',$uri,$apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);
When this is converted to GAS, the script is as follows.
function main() {
var apikey = '#####'; // Please input your key.
var apisecret = '#####'; // Please input your secret.
Gists
This sample script is for using Binance API by Google Apps Script. This script encryptes “signature” like samples. In this script, “Example 1: As a query string” is used, and it retrieves “All orders (SIGNED)” by “GET”.
function main() {
var key = '#####'; // Please input your key.
var secret = '#####'; // Please input your secret.
var api = "/api/v3/allOrders"; // Please input API Endpoint you want.
Gists
This sample script is converted this sample script (javascript) to Google Apps Script. The point for converting is signature as shown in the following sample script.
At Bitfinex API, after "/api/" + apiPath + nonce + rawBody is encrypted using HMAC SHA-384, the data of byte array is converted to HEX. In Google Apps Script, there is no the method for this. The data which was encrypted by Utilities.