Comments (7)
Poloniex and Kucoin are blank because I have still some problems with the code.
Need to work on it
from cryptocurrency-portfolio.
Well, here's the code I use for Polo and it works fine.
// THIS IS THE PART THAT SHOWS YOU HOW TO DO PRIVATE CALLS with the POST METHOD and your Poloniex secret key
function getPoloBalances(key, secret){
var api_key = key;
var api_secret = secret;
// First you create a nonce, which is an incremental random number, to do so, we can use the current date time summed with a number
var nonce = 9465426902234426 + new Date().getTime();
// First choose a command from here https://poloniex.com/support/api/ seeing if it require specific options
// Then, we set the variable 'p' as a string which combine the command & any related parameter (if any) & the nonce.
// in this case we specified the account=all parameter for the command=returnCompleteBalances as it gives us also loans and on orders balances
var p = "command=returnCompleteBalances&account=all&nonce="+nonce;
// Then, we sign this variable 'p' with our secret key (taken from the API of Poloniex) to obtain a new string 'signature'
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_512, p, api_secret);
// Then, we convert the resulting string: from an array of byte (which is a standard output) to HEX
signature = signature.map(function(byte) {
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
}).join('')
// Then we create the variable 'headers' and we specify in the object "Key" the API key associated with the secret key (always taken from the API of Poloniex), and we pass the 'signature' output string to the object "Sign"
var headers = {
"Key" : api_key,
"Sign" : signature
};
// then we define 'options' as POST method, specifying the headers and the payload
var options = {
"method" : "POST",
"headers": headers,
"payload": p
};
// Then we fetch the url passing the 'options' which make us call the command and sign it
var url = "https://poloniex.com/tradingApi";
var response2 = UrlFetchApp.fetch(url, options);
// Then we parse the fetched url in the var 'json2'
var json2 = JSON.parse(response2.getContentText());
from cryptocurrency-portfolio.
@ManuCart I am working on a similar project but with a focus on getting the order history maybe we help each other a bit. I am not a very experienced developer but I am trying to adapt this rest client for Google Apps: https://github.com/Satoshinaire/kucoin-api
from cryptocurrency-portfolio.
@jceelen Good to see that, I was first focused too with order history but it was to complex for me because we need to work with ledger, BNB fees, ETH market... Too much solution to implement but have no much time. Good luck!
from cryptocurrency-portfolio.
@Popcaughan thanks for the code added Poloniex
Need to work on Kucoin
from cryptocurrency-portfolio.
Hi, below is what I've got for kucoin. Any chance you could take a look at Bitstamp? At the moment my Google Sheet connects to a VPS running node.js code to download stamp balances, but I'd love to do it directly.
Please note that Bitstamp requires API key, secret and customer number to create your signature.
Anyway, here's the kucoin code:
function kucoin(){
var host = 'https://api.kucoin.com';
var endpoint ='/v1/account/balance';
var nonce = '' + Date.parse(new Date());
var strForSign = endpoint + '/' + nonce + '/';
var signatureStr = Utilities.base64Encode(strForSign, Utilities.Charset.UTF_8);
var digest = Utilities.computeHmacSha256Signature(signatureStr, priv_key, Utilities.Charset.UTF_8);
// https://pthree.org/2016/02/26/digest-algorithms-in-google-spreadsheets/
var hexstr = '';
for (i = 0; i < digest.length; i++) {
var val = (digest[i]+256) % 256;
hexstr += ('0'+val.toString(16)).slice(-2);
}
var url = host + endpoint;
var options = {
'headers' : {
'KC-API-KEY': pub_key,
'KC-API-NONCE': nonce,
'KC-API-SIGNATURE': hexstr
}
}
var jsondata = UrlFetchApp.fetch(url, options);
var data = JSON.parse(jsondata.getContentText());
// {msg=Operation succeeded., code=OK, data=[{coinType=KCS, balance=0, freezeBalanceStr=0.0, balanceStr=0.0, freezeBalance=0}, {coinType=XRB, balance=0, freezeBalanceStr=0.0, balanceStr=0.0, freezeBalance=0},
for(var x in data.data){
var balance = parseFloat(data.data[x].balance);
if (balance > 0) {
var asset = data.data[x].coinType
array.push({'currency': asset, 'balance': balance, 'market': "Kucoin"});
}
}
}
from cryptocurrency-portfolio.
Hi @Popcaughan
Thank you for your help for Poloniex and Kucoin.
I try to find something for Bitstamp.
I will work on it.
I close this issue, feel free to open an other about bitstamp
from cryptocurrency-portfolio.
Related Issues (20)
- USD balance and bitfinex/Kraken HOT 1
- Request Bitmex HOT 2
- HitBTC request HOT 2
- Binance error -1022 HOT 2
- Kucoin API update HOT 4
- Binance API isn't pulling all rates HOT 8
- function coinmarketcap() Error 429 "Too many requests" HOT 3
- Missing File | Page 404 HOT 2
- ReferenceError: jsSHA is not defined HOT 1
- Error 403 binance API HOT 6
- Coinmarketcap API change of endpoint URI + API Key HOT 2
- NUM! everywhere. [HELP] HOT 1
- BITFINEX "apikey: invalid"
- The number of rows in the range must be at least 1
- coinMarketCap api error HOT 4
- Binance Error 401 - fapi request HOT 2
- https://api.binance.com returned code 400. "msg":"Signature for this request is not valid."
- Kucoin API request fail (code 401) HOT 3
- Google Sheets no longer has Tools / Script editor function
- API Bitvavo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptocurrency-portfolio.