Cryptocurrency Exchange APIs

Crypto Trading for the Aspirational and Seasoned Programmer

As cryptocurrency continues to mature, more exchanges continue to list an increasingly diverse set of assets. Formal exchanges offer a multitude of benefits including centralizing the process of exchanging crypto assets, leveraging your trades with margin, and exchanging currencies across networks (example, ADA to ETH and vice versa).

I’ve had some experience with building out connected applications that employ algorithms to trade for me so that I don’t need to constantly monitor the volatile markets. My algorithms have had mixed results and I haven’t kept up on it, however I wanted to provide some information to this forum on what the APIs are, which exchanges offer them, and why the aspirational or seasoned developer may be interested in exploring them.

For those not experienced in sending information and consuming result to API endpoints, I’ll provide a very brief primer on what an API is. As with everything else on this forum, I want to assure you all this is not a surefire way to play the system. Building code to manage money is very risky, and personal circumstances as innocuous as network connectivity or modem reset times can be the difference between a good and bad play.

What is an API?

API is an acronym (obviously) that means Application Programming Interfaces. Effectively an API is an exposed endpoint in which two computers can pass information to one another regardless of whether they’re on the same network. API end points are quite simply URLs that are broken into a few different parts. To explain the parts, I’m going to use a public API from Kraken:

https://api .kraken.com/0/public/OHLC?pair=XBTUSD

As highlighted above, there are 4 parts to a simple public API:

  • The protocol
  • The domain
  • The path
  • The query string

Without the security needs of a private API, you can take this URL, plug it into your browser, and see a result:

image

Displayed as JSON, this is the OHLC (Open-High-Low-Close) data for the Bitcoin to USD conversion on the Kraken exchange. JSON is easy to read once you get the swing of it, and I do recommend using applications such as Postman to peruse results.

image

What can I do with cryptocurrency APIs?

Your only limitation is your imagination. A few examples from least to most complex can be found below:

  • Pulling live data into a spreadsheet for analysis
  • Creating “quick trade” buttons to optimize pair trading hours
  • Building an algorithm trading bot

The first item is one that I started with – getting data and trying to perform analysis on it to identify trends. These analyses then informed limit orders that would be keyed manually and was a great way to start pulling large data from these exchanges.

Why would I use exchange APIs?

There are pros and cons to using exchange APIs. Anecdotally, I have found the following to be benefits:

  • When creating a trade on margin, the difference between success and failure is predicated on timing as rapid shifts in valuation may result in entering a larger or smaller position than desired. Having “quick invest” buttons are usually faster than using the standard exchange interfaces
  • Broadening knowledge on interfacing with other systems is a valuable skill to have for any current or aspirational programmer.
  • Experimenting with algo development to have systems trade for you while you sleep.

However, there are drawbacks as well that you should be aware of:

  • Cryptocurrency exchanges do generally charge as a percentage of the total trade. If you create an algorithm you may need to worry about death by fees (I woke up one morning with my small account depleted by 50% solely by fees incurred after my program decided to execute 1300 trades over a period of 9 hours)
  • Code requires quality testing, and even the best of code may sometimes go haywire without thorough testing. Not many exchanges offer “paper” accounts, so most testing is done in live environments with real money. Make sure to keep your testing investments low if you are new to the space and not confident in your code.

What are some exchanges that offer APIs?

Some of the larger exchanges offer APIs and provide a slew of help documentation on using them. These include:

Many of these resources also provide help documentation on how to get started and provide syntax help for languages such as Python and VB.

What should I know before I dive into this?

Minimally you should be aware of two domains:

  • How to make REST callouts
  • How to consume JSON data

Many languages come equipped with pre-built libraries and methods to do the former. Even VBA, the build in language for Microsoft Office, can do REST callouts (however VBA can only natively handle XML as a response, so you would need to do some JSON parsing into dictionaries to work with the results).

What programming language should I use?

The shortest answer to this question is “whatever you feel most comfortable using”. Many of the exchanges help documentation provides syntax help in Python including one of the most complex matters of private endpoints – hash encryption.

Feel free to ask any questions and I can try to help point you towards resources that could help!
(edited - didn’t include my screenshots)

3 Likes

Brilliant info thank you for sharing.