The Bitcoin Trading APIs for Cryptocurrency (Updated 2019)

 
global trading.png
 

So you’re an advanced cryptocurrency trader or maybe an app developer who wants to seamlessly plug into every major exchange. While there are countless APIs which allow you to collect data from various exchanges, there is only one trading API which is designed specifically for developers. This is the Shrimpy Universal Crypto Exchange Trading APIs.

These industry leading APIs provide immediate integration into the top 16 exchanges for trading, exchange account management, data collect, smart order routing, analytics, real-time websockets, and more. The best part about everything these APIs have to offer is their low cost and completely free data access. Instead of charging for access to real-time websockets, order book data, and trades, Shrimpy provides access to these endpoints at no cost.

In this article, we’ll be showing you how to quickly set up trading across every exchange Shrimpy supports, so you can start building tools with these APIs. Shrimpy takes care of the unification across every exchange, so that means we won’t be needing any exchange specific code, obscure error handling, or unique exchange management strategies. Everything is packaged conveniently under the hood of the APIs.

Limit Orders - Universal APIs for Crypto Exchange Trade Execution

The Free Cryptocurrency Exchange Market Data API

Real-Time Websockets for Cryptocurrency Exchange Trade Data


Register for your Free Developer Account

Using the Shrimpy Universal Crypto Exchange API requires you to first register with the Shrimpy developer platform here. It’s free to sign up and everyone gets 10 free credits, which is enough for 10 months of testing the developer APIs. In addition to the free credits, you will have unlimited free access to market data through the Shrimpy Developer APIs.

Sign up for the Shrimpy Universal Crypto Exchange APIs


Create Master API Keys

Before you can start trading, you will first need to create an API Master Key. This will allow you to sign the requests when executing trades, managing user accounts, and collecting data. You must also have Multi-Factor Authentication enabled in Settings.

In the developer dashboard, select Create API Master Key. Verify your account by submitting an API Key request to your email. Complete the email request verification and return to the developer dashboard.

Under API Keys, you should now see a new set of private/public API Keys. These keys communicate with Shrimpy to create users, authorize subscriptions, and execute trades. For security reasons, you will have to verify your account through 2FA again to view the Private API Key. Copy and save both the Public Key and Private Key.

Note: Keep your public and private key secure! The master keys should never be shared with anyone. If you would like users to be able to trade on their own devices, the master keys can be used to generate user keys. The user keys are intended to be shared with users. We will discuss this in more detail in the next sections.

 
api master key.png
 

Within your Master API Key Settings, you will be able to add IP Whitelists and enable specific API Key functions, separated into Users, Account, and Trade. Let’s go over these functions in detail.


User Settings

Create a User

Before you can start trading, we need to create a user that can interact with the exchange. This is easy to do with Shrimpy!

Note: These requests are signed with the master API keys.

Request:
POST https://dev-api.shrimpy.io/v1/users

Request Body:
{
    "name": "customnameforthisuser"
}

Response:
{
    "id": "701e0d16-1e9e-42c9-b6a1-4cada1f395b8"
}

Create a User API Key

User API Keys can also be created for each user. Unlike Master API Keys, User API Keys are specifically designed to manage an individual user and can be shared with the associated user. This allows them to manage their own personal account with these keys by directly sending requests to Shrimpy. 

Multiple exchange accounts can be linked to a single user API key. Therefore allowing one user to manage countless exchange accounts with a single user API key. This user API key can execute trades, collecting account information, or accessing full order book data across every connected exchange. 

Note: These requests are signed with the master API keys

Request:
POST https://dev-api.shrimpy.io/v1/users/<userId>/keys

Request Example:
POST https://dev-api.shrimpy.io/v1/users/701e0d16-1e9e-42c9-b6a1-4cada1f395b8/keys

Response:
{
  "publicKey": "51ac18b7d208f59b3c88acbb1ecefe6ba6be6ea4edc07e7a2450307ddc27ab80",
  "privateKey": "85c977ef4070f1deee70192ba7fd5a6caf534f891e4918cfffec11cd6b625e77db4f80347cb436bcaa8882231bacb02f0798a696f101fdd1ef268d66fc63c213"
}

Account Settings 

In order to complete setup for trading, we also need to link an exchange account that we’ll be using to trade. We’ll be using Bittrex as the exchange we want to link.

Connect an Exchange Account

Note: These requests can be signed with the user API keys.

Request:
POST https://dev-api.shrimpy.io/v1/users/<userId>/accounts

Request Example:
POST https://dev-api.shrimpy.io/v1/users/701e0d16-1e9e-42c9-b6a1-4cada1f395b8/accounts

Request Body:
{
   "exchange": "bittrex",
   "publicKey": "GOelL5FT6TklPxAzICIQK25aqct52T2lHoKvtcwsFla5sbVXmeePqVJaoXmXI6Qd",    
   "privateKey": "SelUuFq1sF2zGd97Lmfbb4ghITeziKo9IvM5NltjEdffatRN1N5vfHXIU6dsqRQw",
}

Response:
{    
   "id": 1234
}

Perfect! Now we have our user all set up. Let’s start trading!


Trading 

Account Balances

In order to know which assets an account is holding on an exchange, we need to collect balance data. This can be done easily with Shrimpy.

Note: These requests can be signed with user API keys.

Request:
GET https://dev-api.shrimpy.io/v1/users/<userId>/accounts/<exchangeAccountId>/balance

Request Example:
GET https://dev-api.shrimpy.io/v1/users/701e0d16-1e9e-42c9-b6a1-4cada1f395b8/accounts/123/balance

Response:
{
   "retrievedAt": "2019-01-09T19:17:33.000Z",
   "balances": [
      {
         "symbol": "KCS",
         "nativeValue": 2306,
         "btcValue": 0.33486579,
         "usdValue": 1327.8775274784
      },
      {
         "symbol": "ETH",
         "nativeValue": 4.0e-8,
         "btcValue": 1.4960564e-9,
         "usdValue": 5.9324652822859e-6
      }
   ]
}

Awesome! It was that simple to get the balances for our exchange account. 

Execute Trades

Let’s see how easy it is to perform a trade with Shrimpy. We will use the following endpoint:

Request:
POST https://dev-api.shrimpy.io/v1/users/<userId>/accounts/<exchangeAccountId>/trades

This endpoint provides a simple method to execute a single trade through the Shrimpy APIs. All we will need to do is specify the “from” asset, the “to” asset, and the “amount”. If we want the order to be a smart order routing order (which means we will optimize for the best trades across all trading pairs), then you simply add the “smartRouting” flag. With this information, Shrimpy will intelligently route your trades through quote currencies to accomplish the trade.

Note: These requests can be signed with the user API keys.

Request Example:
POST https://dev-api.shrimpy.io/v1/users/701e0d16-1e9e-42c9-b6a1-4cada1f395b8/accounts/123/trades

Request Body:
{
  "fromSymbol": "BTC",
  "toSymbol": "ETH",
  "amount": "0.01",
  "smartRouting": true,
}

That’s it! You have now successfully submitted a trade through Shrimpy’s Trading API. Wasn’t that a piece of cake? We even took advantage of a world class smart order routing (SOR) algorithm without any effort.

Now that we’ve gone through the process of trade execution, let’s explore some other useful endpoints that are available.

Market Data

Now, you might be wondering how you can execute a trading strategy based on market data. Shrimpy can collect market data based on the complete order book, live trades being executed, candle sticks, or the ticker. In this example, we will look at the ticker. For the other options, please refer to our API documentation.

Request:
GET https://dev-api.shrimpy.io/v1/exchanges/<exchange>/ticker

Request Example:
GET https://dev-api.shrimpy.io/v1/exchanges/kucoin/ticker

Response:
[
  {
    "name": "Bitcoin",
    "symbol": "BTC",
    "priceUsd": "3700.0089335",
    "priceBtc": "1",
    "percentChange24hUsd": "4.191224354581092",
    "lastUpdated": "2018-12-19T22:51:13.000Z"
  },
  {
    "name": "Ethereum",
    "symbol": "ETH",
    "priceUsd": "100.114205389399",
    "priceBtc": "0.027057825",
    "percentChange24hUsd": "5.432113558652999",
    "lastUpdated": "2018-12-19T22:51:13.000Z"
  },
  ...
]

Start Building

These endpoints should be enough to start building most trading applications. If you have other features you need, check out the Shrimpy API Documentation for additional functionality. We support limit orders, open orders, full order book data, smart order routing, websockets for trade data and order books, backtesting endpoints, exchange balance data, and much more. Each of these endpoints have different use cases, so explore everything these APIs offer.

If you are still missing something, don’t hesitate to request a new endpoint be added. The Shrimpy team is always looking for ways to improve the experience with working with the APIs. To condense and simplify all of the steps above, we created a flowchart for Shrimpy’s Crypto Trading API below.

shrimpy api flow chart.png

Summary

Let’s quickly walk through the steps we took to execute our first trade with Shrimpy. 

  • Created a master key through the Shrimpy UI here.

  • Created a user.

  • Created user keys (optional).

  • Linked an exchange.

  • Executed a trade.

Shrimpy API

Shrimpy | Crypto Trading APIs for Developers

Shrimpy offers the most advanced APIs for developers looking to integrate scalable crypto exchange trading functionality into their app.

Shrimpy’s Crypto Trading API was created as a cloud-based solution to address several crypto developer roadblocks including Exchange Trading, Product Scalability, and User Management. With Shrimpy’s API in hand, developers can focus on creating the next era of groundbreaking products that will shape the future of crypto while leveraging Shrimpy’s existing trading infrastructure for trading platform/app development instead of having to manage connections to each and every exchange themselves.

Shrimpy’s API is readily compatible with every major exchange including Binance, Bittrex, Kraken, KuCoin, Poloniex, Coinbase Pro, Bibox, HitBTC, Bitstamp, Bitfinex, Huobi, and more.

Sign up for the Shrimpy developer APIs today!