Today we will review how to use bittrex public API to get the price, market data for use in your market maker-in-a-box or a secure trustless oracle for price feeds, like one in testing at Komodo.
There can be a lot of functions that can be achieved using the public API of bittrex. We can get the latest market prices, get market limits and even deposit or withdraw from our CEX accounts. To get custom and advanced market data it will require authenticated APIs with API keys, but for our uses today - no authentication is required.
https://api.bittrex.com/api/v1.1/public/getticker?market=BTC-ETH
This API endpoint URL returns the current market price for BTC and ETH pair returning a JSON data like this,
Response Example:
{ "success": true, "message": "", "result": { "Bid": 0.03296504, "Ask": 0.03297320, "Last": 0.03297320 }
We can get more and different price data for different markets by just simply editing the coin name 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.bittrex.com/api/v1.1/public/getticker?market=BTC-KMD
Response Example:
{ "success": true, "message": "", "result": { "Bid": 0.00021440, "Ask": 0.00021643, "Last": 0.00021584 }
BTC to LTC Endpoint: https://api.bittrex.com/api/v1.1/public/getticker?market=BTC-LTC
Response Example:
{ "success": true, "message": "", "result": { "Bid": 0.01543901, "Ask": 0.01548159, "Last": 0.01543864 }
BTC to BCH Endpoint: https://api.bittrex.com/api/v1.1/public/getticker?market=BTC-BCH
Response Example:
{ "success": true, "message": "", "result": { "Bid": 0.05671062, "Ask": 0.05671064, "Last": 0.05671064 }
This is how we can edit the URLs and get any price data from Bittrex we want.
How to use APIs:
For using simple REST API and getting JSON data we will use Insomnia. You can go through on our article on Insomnia.
This is the API reference documents to start with https://bittrex.github.io/api/v1-1
Using Isonomia we will establish a connection with the server and test if we can connect with bittrex API. To get the data displayed below the API endpoint is.
https://api.bittrex.com/api/v1.1/public
This API GETS a JSON result displayed below:
Response Example:
{ "success": true, "message": "", "result": { "Bid": 1.09400000, "Ask": 1.19900000, "Last": 1.14900000 }
This is JSON data is the API data. 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 endpoints are used with API key in headers or API endpoint which requires signup.