title: Matlab API Binance
body: <p>I try to get account information from Binance, using Matlab,
  but I get 404 error (not found).</p>
  
  <p>The Binance API is explaned here
  <a href="https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md" rel="nofollow noreferrer">Binance Api</a></p>
  
  <p>I also found a post here, but did not help me to solve the problem</p>
  
  <p><a href="https://stackoverflow.com/questions/48158276/binance-cryptoexchange-api-account-401-response">Binance cryptoexchange API “/account” 401 response</a></p>
  
  <p>thanks for your help</p>
  
  <pre><code>function BinanceGetAccountInfo()
  
  [key,secret]=key_secret('binance');    
  timestamp=binanceServerTime;
  
  queryString =['timestamp=' timestamp]
  Signature = crypto(queryString, secret, 'HmacSHA256');
  Signature=string(Signature)
  
  url='https://api.binance.com/api/v3/';
  url_ext='account';
  url=[url url_ext '?' queryString '&amp;signature=' Signature]
  
  postparams=['X-MBX-APIKEY=' key]
  
  header=http_createHeader('Content-Type','application/x-www-form-urlencoded')
  
  
  [response,status] = urlread2(url,'POST',postparams,header);
  verifStatus=status.status
  
  end
  
  function signStr = crypto(str, key, algorithm)
  import java.net.*;
  import javax.crypto.*;
  import javax.crypto.spec.*;
  import org.apache.commons.codec.binary.*
  
  keyStr = java.lang.String(key);
  key = SecretKeySpec(keyStr.getBytes('UTF-8'), algorithm);
  mac = Mac.getInstance(algorithm);
  mac.init(key);
  toSignStr = java.lang.String(str);
  signStr = java.lang.String(Hex.encodeHex( mac.doFinal(  toSignStr.getBytes('UTF-8'))));
  end
  
  function serverTime=binanceServerTime(adTime)
  if nargin&lt;1
  adTime=0; %millisecondes
  end
  serverTime=urlread2('https://www.binance.com/api/v1/time');
  serverTime=JSON.parse(serverTime);
  serverTime=num2str(serverTime.serverTime+adTime);
  end
  </code></pre>