Written by KomoDeFi Editorial Team on May 27, 2019

How to Get Price Data from Binance

Today we will review how to use Binance public API to get the price, market data for use in your marketmaker-in-a-box or a secure trustless oracle for price feeds, like one in testing at Komodo. Binance is currently the largest cryptocurrency CEX (Centralized Exchange) in the world. This means you can get pricing data of every popular cryptocurrency in the world.

Getting Prices with APIs

There can be a lot of functions that can be achieved using the public API of Binance. We can get the latest market prices, get market limits and even deposit or withdraw from our CEX accounts to use in your marketmaker software. To get custom and advanced market data it will require authenticated APIs with API keys.

https://api.binance.com/api/v3/ticker/price?symbol=ETHBTC

This API endpoint URL returns the current market price for BTC and ETH pair returning a JSON data like this,

Response Example:

{
  "symbol": "ETHBTC",
  "price": "0.02999500"
}

Getting More Prices:

We can get more and different price data for different markets by just simply editing the coin pairs which is called a parameter in the API endpoint. We will get BTC/KMD, BTC/LTC, BTC/BCH like this.

BTC to KMD Endpoint: https://api.binance.com/api/v3/ticker/price?symbol=KMDBTC

Response Example:

{
  "symbol": "KMDBTC",
  "price": "0.00019140"
}

BTC to LTC Endpoint: https://api.binance.com/api/v3/ticker/price?symbol=LTCBTC

Response Example:

{
  "symbol": "LTCBTC",
  "price": "0.01352400"
}

BTC to DASH Endpoint: https://api.binance.com/api/v3/ticker/price?symbol=DASHBTC

Response Example:

{
  "symbol": "DASHBTC",
  "price": "0.02074400"
}

The pricing API used or ticker information is public and does not require secure API key or signup. This data can be used anywhere in your bots, software, websites because this data is real-time and dynamic which you can feed to your programs. More advanced API data can be retrieved which uses API key in headers or API endpoint, the signup process is required.  You can find the API’s Documentation on https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

Back to Top
Experience Web3
© 2024 komodefi.com