0

I would like to import Binance.com account data via API. This is the API URL, which asks for API-key, when opened in browser: https://fapi.binance.com/fapi/v2/balance

This is the code that I try using in Excel's Power Query:

let
      apiUrl = "https://fapi.binance.com/fapi/v2/balance",
      options = [Headers =[#"X-MBX-APIKEY"="MpfS23B8GjxXq9MEvKUR819QsMsYB3xuhByglOGaV7WUgldD7wVFQOYAhmQYbXDD"]],
      result = Web.Contents(apiUrl , options),
     #"Expanded Column1" = Web.Page(result)
in
     #"Expanded Column1"

APIKEY is bogus in this example.

I am getting the following error when using this code:

DataSource.Error: The remote server return an HTTP status code '400' when trying to access 'https://fapi.binance.com/fapi/v2/balance'.
Details:
DataSourceKind=Web
DataSourcePath=https://fapi.binance.com/fapi/v2/balance
Url=https://fapi.binance.com/fapi/v2/balance

Binance provides both API-Key and secret. I have them, but I don't seem to find how to use them. Maybe API-key should be some sort of encrypted with secret key for it to work? I don't know how to do that either :(

I have tried this with the following API URLs, it doesn't work, the error is the same:

Binance docs seem to be too complicated for this Power Query task.

Any idea what needs to be done to get that working so I could finally get my Binance account data imported into Excel?

CamSpy
  • 401
  • 2
  • 15
  • 26
  • `HTTP 400` means you're sending a bad request. If you link the docs to the specific endpoint you want I can give help. Otherwise [here's a template](https://gist.github.com/ninmonkey/4f919ae9dadf1a7bcf926e26a1d8c2c4#file-using-web-apis-in-powerquery-pq) -- You should be using `options[RelativePath]` and `options[Query]` for web requests, especially dynamic ones. [Web.Contents](https://learn.microsoft.com/en-us/powerquery-m/web-contents#__toc360793395) – ninMonkey Jan 21 '21 at 20:19

0 Answers0