Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Problem getting Binance Balance #17

Closed
aertsdorien opened this issue Jan 23, 2018 · 4 comments
Closed

Problem getting Binance Balance #17

aertsdorien opened this issue Jan 23, 2018 · 4 comments

Comments

@aertsdorien
Copy link

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

@emmtte
Copy link
Owner

emmtte commented Jan 23, 2018

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

@aertsdorien
Copy link
Author

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?

@emmtte
Copy link
Owner

emmtte commented Jan 24, 2018

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

@aertsdorien
Copy link
Author

I got it to work, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants