2

I would like to convert EUR to BTC via API call on Binance. The API key already created, but I don't know how to make an API call to do this. The official documentation doesn't have any example.

I would like to do this on Linux (with cURL).

Thanks!

Feriman
  • 503
  • 8
  • 17

1 Answers1

3

You can use the new order endpoint. Symbol is BTCEUR.

The documentation gives an example of signing the request using openssl and submitting it using curl.

[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • Thanks! It seems okay, but I'm confused with the "quantity" and the "price" parts. Do you have any idea what values are correct here? I would like to buy BTC for 50 EUR. – Feriman Jun 24 '21 at 06:22
  • 1
    Quantity is the amount of BTC (base asset) that you want to buy. If you want to specify the EUR amount (quote asset) that you want to spend, you can use the `quoteOrderQty` property instead... Price is the price for which you want to submit the `LIMIT` type order (e.g. 30,000 eur), it will execute when the market price reaches this defined price. If you want to buy BTC for whatever is the current price, use the `MARKET` type. – Petr Hejda Jun 24 '21 at 07:29