Shrimpy Developer API User Flow Reference

photo-1505664194779-8beaceb93744.jpg

The Shrimpy Universal Crypto Exchange APIs are a powerful resource for cryptocurrency application developers. The APIs provide solutions to some of the largest problems encountered when integrating crypto exchange functionality including:

  1. Low-Latency Trade Execution, Smart Order Routing, & Automated Strategies

  2. User Authorization & Management

  3. Exchange Integration & Endpoint Unification

  4. Real-time Data & Analytics

Taking advantage of everything the Shrimpy APIs have to offer requires an understanding of how the APIs work and the way users are managed. This reference will guide you through the details of how to conceptually think about the Shrimpy APIs, discuss how users can be managed, and highlight a few of the most common request flows. Since our APIs are an institutional grade solution designed to enable large scale developments, mastering this topic will allow you to seamlessly scale your application to millions of active users and countless exchanges.

Register for a Shrimpy API developer account here. Don’t forget to also join our developer telegram to keep up to date with the latest news.

Exchange Management — Conceptual Discussion

This high-level diagram shows how the developer does not need to directly manage users, execute trades, or integrate with each individual exchange. Developers perform only a single integration with the Shrimpy APIs to connect each of these important components.

This high-level diagram shows how the developer does not need to directly manage users, execute trades, or integrate with each individual exchange. Developers perform only a single integration with the Shrimpy APIs to connect each of these important components.

The Shrimpy Universal Crypto Exchange APIs are a simple way for developers to connect to every major exchange through consistent endpoints. Integrating our APIs eliminates the need for specialized code for each exchange, reduces the demand from sporadic exchange updates, cuts costs of exchange infrastructure, increases data availability, seamlessly scales to manage an unlimited number of users, accelerates development speeds, and standardizes the way trades are executed across every major exchange. 

Conceptually, Shrimpy is a unified interface to each exchange. This interface creates a uniform way to manage every exchange. Without Shrimpy APIs, individually integrating an exchange can take weeks or even months to complete. Even upon completion, exchanges require updates and maintenance at a recurring cost with no ultimate ending. With Shrimpy APIs, executing a trade on one exchange is identical to executing trades on every other exchange. Our team manages upgrades, maintenance, and integrations, so you never again need to struggle to keep up. Our list of supported exchanges is expanding constantly and allows for instant integration into your application or service without any additional work. 

Some of the features Shrimpy provides across every major exchange:

  • Real-time order book data

  • Exchange account balances

  • Market ticker

  • User management

  • Free Coinbase Pro and KuCoin trading

  • Real-time order execution

  • High fidelity backtesting

  • Smart order routing

  • Automated portfolio rebalancing

  • Asset selection insights

  • Real-time websockets for trade and order book data

As an application developer, the problem is simplified to a single integration with the Shrimpy APIs. 

User Request Flows

There are 2 primary different ways Shrimpy allows developers to conveniently manage requests from users. The first is a developer controlled (centralized) request flow. The second method is a user-controlled (decentralized) request flow. 

In addition to these general user request flows, we will also discuss patterns for other common request flows which you are likely to encounter as a developer.

Developer Controlled (centralized) Request Flow

1_eLaVAr2EBwL5P9LDus-dEA.png

A developer controlled request flow means every request sent to Shrimpy will come from the developers own servers. Essentially, every request is routed through a centralized server which manages the communication with Shrimpy servers. Since developers can create Master Shrimpy API Keys which manage every user, developers can send requests to Shrimpy on behalf of any user by signing the requests with the Master Shrimpy API Keys. The responses to these requests can then be routed back to the user through the centralized developer server. 

This flow is popular among mobile application developers. Mobile application developers find this request flow to be convenient because changes to the way users communicate with Shrimpy can be adjusted quickly. Since the developer controls the servers which manage the requests, updates can be deployed without users updating their applications.

By default, Master Shrimpy API Keys have a limit of 1,000 requests per minute. Developers who plan on sending thousands of requests per minute can receive a rate limit increase by emailing us at contact@shrimpy.io. 

To implement a developer controlled request flow, use the following steps: 

  1. When a user signs up for your application or service, collect the necessary information required to register this user with Shrimpy. We recommend including a unique identifier like email in the optional “name” field when creating a user with Shrimpy. 

  2. Create a new user with Shrimpy. This action is completely free, so you can make as many users as you want. The developer will only be charged once the user is “enabled” for trading. Shrimpy will respond with a unique user ID. This request must be signed with the master key.

  3. Link the user ID Shrimpy returns to the user information you have stored in your own system. This way you can properly route requests from your users to Shrimpy. 

  4. Allow each user to send requests for linking exchange accounts, executing trades, collecting data, and managing their portfolio. In this request flow, you are responsible for maintaining these connections with users and properly routing the requests to Shrimpy. 

  5. Route the request to Shrimpy on behalf of each user. Use your Master Shrimpy API Key to sign the appropriate requests. 

User Controlled (decentralized) Request Flow

1_6T1ohVQYNZEQ9-OWBf5n5w.png

The second user request flow option that’s possible with the Shrimpy developer APIs is a user controlled request flow. This means each individual user will manage their own requests for trading, data collection, and linking exchange accounts by directly communicating with Shrimpy. Each of these requests will be signed with the individual User Shrimpy API Keys. These are not the same as the Master Shrimpy API Keys. The User Shrimpy API Keys are unique to each individual user. DO NOT EVER PROVIDE MASTER SHRIMPY API KEYS TO USERS.

This user flow is accessible to all developers, but we’ve found it’s particularly desirable for web developers. Since websites can be redeployed quickly, there is no risk of needing to migrate users if the website ever needs to be updated. The benefit of this request flow is a drastic reduction in server load. 

The above diagram illustrates how developers implementing this request flow still need a centralized server to initiate the creation of users. In addition to the creation of the user, the developer will also need to generate Shrimpy User API Keys for each individual user. These keys are sent back to the user so they can communicate directly with Shrimpy by signing requests to access their personal account. 

Implementing the user controlled request flow will require the following steps: 

  1. When a user signs up for your application or service, collect the necessary information required to register this user with Shrimpy. We recommend including a unique identifier like email in the optional “name” field when creating a user with Shrimpy.

  2. Create a new user with Shrimpy. This action is completely free, so you can make as many users as you want. The developer will only be charged once the user is “enabled” for trading. Shrimpy will respond with a unique user ID. This request must be signed with the master key.

  3. Request to create Shrimpy User API Keys for this user. These keys are unique to each individual user and can only sign requests for the associated user account. The request to generate these keys is signed by the Master Shrimpy API Keys.

  4. Route the Shrimpy User API Keys and user ID back to the appropriate user. These keys will be used to directly communicate with Shrimpy. 

  5. Each of your individual users can now directly communicate with Shrimpy by signing requests with the Shrimpy User API Keys. Users can execute trades, collect data, link exchange accounts, manage their portfolio, run backtests, and more by signing requests with their individual keys. 

Linking Exchange Account

1_WR_sHXJaWzlWnuktkD1HdA.png

The following discussion will focus on the request flow for linking exchange accounts for a user and executing a trade. Although this diagram is specific to the user controlled request flow, the process is essentially the same for a developer controlled request flow. The major difference is the requests will be signed with the Master Shrimpy API Keys when using the developer controlled request flow. 

Once a user receives their Shrimpy User API Keys they can communicate directly with Shrimpy to link exchanges, execute trades, collect data, and more. The process for generating a Shrimpy User API Key is outlined in the section titled “User Controlled (decentralized) Request Flow”. 

In order to begin executing trades on an exchange, you must first link an exchange account for the user. This can be done through the following steps: 

  1. Link the user’s Exchange API Keys to Shrimpy using the “Link an Exchange Account” endpoint. Exchange API Keys are not the same as Shrimpy User API Keys. Exchange API Keys are obtained and configured on the exchange. These keys are specific to each exchange account. This request should be signed with the Shrimpy User API Keys.

  2. Shrimpy will communicate with the exchange to verify the exchange account, collect data, and manage the connection.

  3. Once the verification is complete, Shrimpy will respond with an account ID for the exchange account which has been linked. A user is allowed to link up to 20 exchange accounts, so this account ID is the way Shrimpy identifies each exchange account. If your users need to link more than 20 exchange accounts, please contact us at contact@shrimpy.io.

  4. The user can now request Shrimpy to execute trades, link more exchange accounts, run backtests, and more. These requests should be signed with the Shrimpy User API Keys. 

User Portfolio Allocation and Rebalancing

1_UgP2TMxCXJa4ZSI0DyGocg.png

The following discussion will focus on the request flow for allocating a portfolio and setting up a periodic rebalance for a user which has already linked an exchange account to Shrimpy. Although this diagram is specific to the user controlled request flow, the process is essentially the same for a developer controlled request flow. The major difference is the requests will be signed with the Master Shrimpy API Keys when using the developer controlled request flow.

Once a user has connected an exchange account using the steps outlined in “Linking Exchange Account”, they can allocate a portfolio and set up a strategy.

Note: The request flow for simply placing limit orders, smart orders, or collecting data is different than this request flow. No portfolio or strategy needs to be set in order to place limit orders, execute smart orders, or collect data; however, an exchange account still needs to be linked.

The process for allocating a portfolio and setting up a rebalancing strategy with Shrimpy is as follows:

  1. Send the portfolio allocations to Shrimpy. This request is signed with the Shrimpy User API Keys. 

  2. Request a rebalance. A rebalance in this instance will simply execute the trades necessary to construct the portfolio which was specified in step 1. This request should be signed with the Shrimpy User API Keys.

  3. Shrimpy will then communicate with the exchange to collect data, execute the trades, and construct the desired portfolio. 

  4. Periodically request for the status of the rebalance by calling the “List Accounts” endpoint. The user can also follow up with more requests to execute trades, collect balance data, access the latest market data, and more. These requests are signed with the Shrimpy User API Keys. 

Conclusions

The Shrimpy APIs are a flexible option for application developers looking for a cloud-based solution which addresses major hurdles for exchange trading, data collection, product scalability, and user management. Integrate every major exchange with consistent endpoints by leveraging our universal crypto exchange trading infrastructure. Simplify your user requests flows by taking advantage of our novel design patterns. Scale your service to millions of users without worry.

Related Articles

Shrimpy vs CCXT: The Case for Centralization in a Decentralized Ecosystem

Trading Crypto Through APIs

Universal Websockets for Real-Time Crypto Exchange Order Book Data

Historical OHLCV Trade Charting Data for Crypto Exchanges

Crypto API for Smart Order Routing