The Bitcoin Trading APIs for Cryptocurrency (Updated 2020)

 
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. Access all of these APIs at reasonable prices.

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.

How to Build a Crypto Trading Bot for Binance

A Python Script to Check Your Crypto Portfolio Value

Python Scripts for Crypto Trading Bots


Register for your Developer Account

Using the Shrimpy Universal Crypto Exchange API requires you to first register with the Shrimpy developer platform here. It’s easy to sign up and start collecting market data across every major exchange in the cryptocurrency space.

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, Trade, and Data. 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.


Data

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"
  },
  ...
]

Historical Data

Not only do the Shrimpy APIs support live market data, but the APIs also support detailed historical data. You can collect anything from tick-by-tick trade data, candlesticks that are precise as 1 minute, and order book snapshots. In the following example, we will demonstrate how easy it is to collect historical tick-by-tick trade data.

Request
GET https://dev-api.shrimpy.io/v1/historical/trades

Response:
[
    {
        "time": "2016-09-06T13:01:34.000Z",
        "size": "1891.1316431",
        "price": "0.00002585",
        "takerSide": "buyer"
    },
    {
        "time": "2016-09-06T13:01:35.000Z",
        "size": "35200",
        "price": "0.00002594",
        "takerSide": "buyer"
    },
    ...
    {
        "time": "2016-09-06T13:01:36.000Z",
        "size": "6000",
        "price": "0.00002596",
        "takerSide": "seller"
    }
]

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.

About Shrimpy

Shrimpy is an account aggregating platform for cryptocurrency. It is designed for both professional and novice traders to come and learn about the growing crypto industry. Trade with ease, track your performance, and analyze the market. Shrimpy is the trusted platform for trading over $13B in digital assets.

Follow us on Twitter for updates!