emmtte / list

Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem getting Binance Balance

aertsdorien opened this issue · comments

Hi, thanks for your code. I am however having problems getting my balance data from Binance. When running the code I get a 403 error code (see full response below, I modified the signature for security reasons)

Any thoughts? Thanks!

Request failed for https://www.binance.com/api/v3/account?timestamp=1516737311860&signature=xxxxxxxxxxxxxxx returned code 403. Truncated server response:

<title>403 Forbidden</title>

403 Forbidden

Hi,
Please check in your Binance API
For IP Access Restriction, you need to check the box Unrestricted (Less Secure)
Because the IP comes from google
I need to update the readme about that

Hi,
IP access restriction was ok. It seems like the 403 error only occurs when I'm running the script in debugging mode. However, I'm still not getting results. :-/

I think there's a problem with the JSON.parse function.
When I just return the response as text, I'm getting a long string in my Google Sheet

var url = "https://api.binance.com/api/v3/account?" + string + "&signature=" + sKey;
var response = UrlFetchApp.fetch(url, params);
var data = response.getContentText();
return data

However as soon as I add the JSON.parse function, it returns an empty cell in my Google Sheet

var url = "https://api.binance.com/api/v3/account?" + string + "&signature=" + sKey;
var response = UrlFetchApp.fetch(url, params);
var data = JSON.parse(response.getContentText());
return data

Any thoughts?

Strange, normally it should work
You need to use "Balance" function in "main.js" to see your balance in "Market" sheet
if you use var data = response.getContentText(); it's return the complete message
if you use var data = JSON.parse(response.getContentText()); it's return a json string

I got it to work, thanks!