API trading: the most efficient way to execute your trading strategy

3Сommas Blog
6 min readJun 9, 2021

Before the advent of the Internet, the telephone was every trader’s hottest tool. Because automatic trading did not yet exist, a phone call to your stock broker was necessary to place a trade on the market. However, with the development of new technologies, trading quickly moved into cyberspace, where API interfaces became the new paradigm. Today, we will discuss how APIs are used in crypto trading and how 3Commas can help you automate your trading strategies.

What is an API?

An API (Application Programming Interface) allows different applications to communicate with one another. APIs are becoming increasingly popular tools, with companies such as Facebook, Amazon, and many others creating their own APIs to allow third-parties to access some of their features without having to completely migrate on to their ecosystem.

Simply put, an API is a feature set that allows developers to conveniently get the data flow they need from a service. For example, Twitter’s API allows outside developers and companies to get information about the platform’s users, followers, tweets, and so on. This information can then be used to inform business decisions like advertising and marketing, among other things. Or, data can be used by third-parties to create even better products and services for consumers.

How are APIs used?

Example: Many travelers use airline booking aggregators to find the best rates. These platforms rely heavily on APIs to extract data regarding flights, prices, available seats, scheduled events, and so on. They get all this information in real-time from various servers. This allows them to simultaneously compare hundreds of offers from airline companies and hotels to find the best travel options.

In addition, apps like Uber and Lyft depend on GPS to quickly route riders to the closest available driver. To accomplish this, these companies rely on the Google Maps API, which also provides data for calculating routes, distances, and prices. Without this API, app developers would have to create their own navigation solutions from scratch to accommodate customers.

Cryptocurrency APIs

In finance and crypto trading, APIs can be used to link a set of automated trading algorithms (bots) with a trader’s preferred platform to automate their trading strategy. APIs can also be useful for tracking exchange balances across a range of crypto exchanges in a single, convenient portfolio.

Example: Messari analytics is a web-based crypto analytics platform. The Messari API provides access to market data, trading pair quantitative indicators, volumes, and much more. By using the Messari API, third-party developers can create their own platforms for cryptocurrency data analysis.

Thanks to APIs, third-party services can receive real-time information about digital assets from crypto exchanges. Platforms such as Binance, FTX, BitMEX, and others freely provide their APIs for traders and investors. By using these third-party apps and services, you can automate your trading strategy through a bot, post cryptocurrency rates on your website, add information about your coins to your portfolio, and so on.

API & 3Commas

3Commas currently allows you to use API data from 21 crypto exchanges to configure trading bots, trade Options, and use the 3Commas trading terminal. This is quite handy if you have many exchange accounts across several trading platforms at once. After connecting your 3Commas profile to preferred exchanges via API keys, you receive up-to-date information on all your portfolios across the platforms you use and can trade directly utilizing the 3Commas interface.

Example: You would like to take advantage of expected drops in several trading pairs — BTC/USDT, ETH/USDT, LTC/USDT, and XMR/USDT. After the expected price drop, you believe the price will rise to the Take Profit level. However, your cryptocurrency holdings are spread across different exchanges, making it cumbersome to place trades across exchanges and acount for trading profits.

Instead of trading across exchanges, you can use the Grid Bot, available on the 3Commas platform. All you need to do is choose the appropriate pairs and trading platforms from the bot’s menu and place a grid of buy and sell orders. Thanks to API connections across your exchange accounts, all operations are carried out on the 3Commas platform automatically, and you can monitor the status of your portfolios across numerous exchanges from a single account in real-time.

How to connect your 3Commas account to an exchange via API?

Let’s practice connecting the 3Commas account to the popular cryptocurrency exchange Binance. To do so, first select the API management menu in your exchange account settings. In the next window, enter the name of the new API.

The exchange will ask you for a verification code sent to your email and a Google Authenticator code.

A new page will display your API key, secret key, and the API configuration options:

  1. Ability to read data from the account;
  2. Margin trading
  3. Options trading
  4. Spot and margin trading
  5. Futures trading
  6. Possibility to withdraw funds via an API request
  7. Universal transfers
  8. API connection from trusted IPs only.

After the first setup stage is complete, head over to the My Exchanges tab in your 3Commas Dashboard. Select Binance from the list, enter the API name, API key, and the secret combination.

Done! If you have done everything according to the instructions above, your Binance account details will be displayed on your 3Commas dashboard.

Security

Many APIs provided by exchanges allow for several levels of permissions — from the most basic level of displaying cryptocurrency rates, to more advanced controls like withdrawing funds from your account at the request of a third-party platform. In general, a good rule of thumb is to not share or store your API with untrusted platforms.

Also, pay special attention to protecting your exchange account. Some ways to do this are to enable two-factor authentication and restrict access to your account from untrusted IP addresses, if possible. This will better ensure that if an untrusted actor attempts to access your exchange account, they won’t get very far. When you create API keys, you also use a secret combination which you should write down and store in a secure location. This is useful if you ever lose access to your API connection. But remember not to disclose the secret combo with anyone, ever.

Conclusion

APIs are a powerful tool used to automate trades. Thanks to this technology, cryptocurrency portfolio management becomes a much easier task. However, users should ensure proper security measures when using APIs, which include keeping API keys and secret combinations safe and enhancing exchange security with features such as two-factor authentication. These measures allow traders to safely and securely utilize exchange APIs without having to worry about bad actors accessing their funds.

--

--