The Komodo rebrand took place in July 2019 with the release of 1000 pages of documentation and other project milestones, including a DIY spin up a blockchain composer in 5 minutes.  Among the 1000 pages of documentation is the API for the upcoming marketmaker v2 software capable of doing cross chain atomic swaps.  For developers, this means an easy to access atomic swap API for integration into any application.

The most exciting application currently in beta is from the Komodo team, a mobile atomic swap multi coin wallet called AtomicDEX.

Trading Strategies

The workflow for marketmakers into this atomic swap trading network would be to follow existing strategies of:

CEX To DEX

The ability to use centralized exchanges with this DEX to refuel the atomic swap API of their orderbooks already exists in the form of perl scripts - which only means that other developments using this API are possible in other languages.

We have taken the Atomic DEX documentation relevant parts and republished the marketmaker's API for easy reference.

Beta Development

The HyperDEX desktop app is already exploring ways of integrating this new marketmaker feature for users wishing to participate in the market with this easy to use atomic swap API.

custom marketmaker url

(A market maker or liquidity provider is a company or an individual that quotes both a buy and a sell price)

Getting Started with API tools:

When working with CEX and DEX data we will most likely interact with REST APIs. To GET simple REST API response data in JSON format we will use a simple tool called “Insomnia”. This is a free tool that is used to Debug REST (Representational State Transfer) APIs.

https://insomnia.rest/

 

Why Insomnia?

Because it is free and really easy to use tool. We can get all the details on every response. Advanced features allow us to view status code, body, headers, cookies, etc. Custom headers and queries, API authentication is an easy approach. The intuitive UI lets us GET JSON data by simply entering URLs, which then returns data in JSON format.

 

API Endpoint: https://jsonplaceholder.typicode.com/todos/1
Response Example:
{

 "userId": 1,

 "id": 1,

 "title": "delectus aut autem",

 "completed": false

}

 

The API endpoint is the URL for GET data. I am writing GET in the capital because there is GET, POST, PUT, PATCH, OPTIONS, DELETE, HEAD are methods associated when working with REST APIs. An endpoint can be edited to get more specific data. These alterations are called parameters at the end of the URL after a question mark.

 

API Endpoint with Parameter: https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnTicker?request=[NamePairs=BTC_LTC]

 

Response Example:
{

 "Error": null,

 "Tickers": [

   {

     "PairId": 3,

     "PairName": "BTC_LTC",

     "Last": 0.015164000000000,

     "LowPrice": 0.015154000000000,

     "HighPrice": 0.015682000000000,

     "PercentChange": -2.4384,

     "BaseVolume": 0.79338914208023000000000,

     "QuoteVolume": 51.49890682,

     "VolumeInBtc": 0.79338914208023000000000,

     "VolumeInUsd": 4140.1636078974496700000000000

   }

 ]

}

This API endpoint specifically returns BTC/LTC pair data as URL parameters have restricted it to do so. Data can be displayed in browser but Insomnia is faster and more formal. It provides us a wide range of options to make it easier to work with APIs. To know more about REST APIs and JSON please read the following article.

https://raygun.com/blog/soap-vs-rest-vs-json/

Advanced Usage (Headers, Queries)

When we work with public API endpoints it is just a matter of send and go, but if we work with secure APIs that use authentication via API keys there are a few steps associated with Insomnia. Using authenticated APIs is really easy with insomnia. Most APIs provide API keys within the URL. In some cases, we have to manually enter the URL in headers or a query string parameter name. Doing this in insomnia is really easy we will go through coinmarketcap API as an example for this.

 

Authenticating API with Headers



Authenticating API with Body

Authenticating APIs with headers is the most preferred method. While authentication using query is also convenient.

Today we will learn how to use coinlayer’s public API to get historical pricing data of any date. The data is real time and dynamic you can change dates or can get data of as much as coins as you want.

Getting Historical Pricing Data

As you can see above I got this data from coinlayer.com which is an amazing API provider for Price Indexing, conversion, Historical data. There can be a lot of functions that can be achieved using public API of coinlayer. Some advanced functionalities might require authenticated API keys and paid memberships.

Response Example:

{

"success":true,

"terms":"https:\/\/coinlayer.com\/terms",

"privacy":"https:\/\/coinlayer.com\/privacy"

,"timestamp":1553990360,

"target":"USD",

"Historical":true,

"Date":"2019-03-30",

"rates":{"ETH":142.746323,"KMD":1.101378}

}

http://api.coinlayer.com/api/2019-03-30?access_key=007866dcbd35cf6d14951e425a61c422&symbols=ETH,KMD

As you can see this API endpoint will return me the JSON file for historical data according to the date I entered 30th March 2019. The date and the coins are my parameters, which is dynamic and can be changed for different results.

Response Example:

{

"success":true,

"terms":"https:\/\/coinlayer.com\/terms",

"privacy":"https:\/\/coinlayer.com\/privacy"

,"timestamp":1553990360,

"target":"USD",

"Historical":true,

"Date":"2019-03-30",

"rates":{"ETH":142.746323,"KMD":1.101378}

}

The data in JSON format I can furthermore edit the parameters change the date and can even add more coins, here is another example,

http://api.coinlayer.com/api/2019-04-03?access_key=007866dcbd35cf6d14951e425a61c422&symbols=ETH,KMD,BTC,DASH

Now this URL will get me the historical data of Ethereum, Komodo, Bitcoin and DASH from the date 3rd April 2019

Response Example:
{

"Success":true,

"terms":"https:\/\/coinlayer.com\/terms",

"privacy":"https:\/\/coinlayer.com\/privacy",

"Timestamp":1554335944,

"target":"USD",

"Historical":true,

"Date":"2019-04-03",

"rates":{"BTC":4966.744299,"DASH":124.93885,"ETH":161.046317,"KMD":1.206555}

}


You can add these APIs to your websites, or bots to get JSON data that is easily understandable by every programming language and you can feed the data to any software, Web application or mobile app using these JSON formats and APIs. This is really useful data and can help you in a lot of ways if you are working with cryptocurrencies etc.

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

Today we will review how to use HitBTC 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. The market currently has more than 700 coins listed to trade from. This means you can get pricing data of every popular cryptocurrency in the world.

Check out our cryptocurrency wallet getting started articles.

Getting Prices with HitBTC API

There can be a lot of functions that can be achieved using the public API of HitBTC. 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.

https://api.hitbtc.com/api/2/public/ticker/ETHBTC

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

JSON Response Example:

{
  "ask": "0.030488",
  "bid": "0.030487",
  "last": "0.030487",
  "open": "0.031790",
  "low": "0.030424",
  "high": "0.031834",
  "volume": "75801.4510",
  "volumeQuote": "2366.3425029031",
  "timestamp": "2019-04-24T01:41:00.233Z",
  "symbol": "ETHBTC"
}

Public API for other market pairs

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.hitbtc.com/api/2/public/ticker/KMDBTC

JSON Response Example:

{
  "ask": "0.00018699",
  "bid": "0.00018625",
  "last": "0.00018691",
  "open": "0.00020104",
  "low": "0.00018578",
  "high": "0.00020144",
  "volume": "116171.5",
  "volumeQuote": "22.386307664",
  "timestamp": "2019-04-24T01:41:55.825Z",
  "symbol": "KMDBTC"
}

BTC to LTC Endpoint: https://api.hitbtc.com/api/2/public/ticker/LTCBTC

JSON Response Example:

{
  "ask": "0.0131614",
  "bid": "0.0131429",
  "last": "0.0131437",
  "open": "0.0142510",
  "low": "0.0128523",
  "high": "0.0143290",
  "volume": "584901.901",
  "volumeQuote": "8113.7049880954",
  "timestamp": "2019-04-24T01:42:19.236Z",
  "symbol": "LTCBTC"
}


BTC to BCH Endpoint: https://api.hitbtc.com/api/2/public/ticker/BCHBTC

JSON Response Example:

{
  "ask": "0.061494",
  "bid": "0.061330",
  "last": "0.061372",
  "open": "0.064887",
  "low": "0.060848",
  "high": "0.066511",
  "volume": "26.8784",
  "volumeQuote": "1.7347668728",
  "timestamp": "2019-04-24T01:43:05.532Z",
  "symbol": "BCHBTC"
}

Advanced API Key Functions

More advanced API endpoints are used with API key in headers or API endpoint.The pricing API used or ticker information is public and do not require secure API key or signup.This data can be used anywhere in your bots, softwares, websites because this data is real time and dynamic which you can feed to your programs.  You can find the API’s on https://api.hitbtc.com/ .

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.

Getting Prices with APIs

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
  }

Getting More Prices:

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.

Experience Crypto
© 2021 komodefi.com. Powered by Komodefi
chevron-down