Your First Simple Crypto Trading Bot Using LunarCrush and 3Commas –

Trending #10
Social Intelligence for Crypto, NFTs, and Stocks – there's more to markets than trading off price.

As a trader, you might wonder how you can take your trading to the next level. The LunarCrush API is perfect for traders who want to write scripts and work with bots to trigger specific trade activity, but you need a platform that will let you perform the trades. LunarCrush monitors the internet for signals that will identify your next asset opportunity.

If you’re familiar with 3Commas, then you know that it’s a platform for trading with bots. You connect your favorite exchange to your 3Commas dashboard account, and you can automate much of the research and trading that takes hours to do manually. The platform also has an API that can be used in conjunction with the LunarCrush API. LunarCrush serves as your automated research tool, and the 3Commas API serves as a way to take botted action when the LunarCrush research reaches specific thresholds that you determine and design in your scripted bot.

The LunarCrush API returns numerous signals that can be used in custom trader scripts. Using custom scripts with LunarCrush and 3Commas gives you more flexibility in what you want to do instead of being tied to preset features coded in the dashboard. This simple starter guide will help new traders get acclimated to the LunarCrush API and see what it can do for trader bots.


In this example, we’ll use Galaxy Score, which is a score calculated from several social and price metrics. You can read about the other data LunarCrush makes available from the API, but this guide will focus on Galaxy Score as an example.

A brief description of Galaxy Score:
Galaxy score™ is a combination of four metrics — the price score, social impact score, average sentiment, and correlation rank. It measures the relative price appreciation between current and previous interval MACD (moving average convergence divergence), engagement and impact across various social media platforms, average sentiment classified by our machine-learning engines, and correlation of social media volumes and spam to price and volume. The metrics are aggregated and normalized to a scale of 100.

To understand more about why you would use Galaxy Score to guide your trades, check out the Trading Parrot videos illustrating LunarCrush and 3Comma bots work together. These videos will help you figure out the best ways to work with LunarCrush data and use them to build automation into your trading in 3Commas.

Using Galaxy Score, a trader could identify the top crypto opportunities for several assets and trigger trades on the 3Commas platform. You first retrieve the top opportunities via the LunarCrush APIcoins endpoint and then use the smart_trades endpoint on the 3Commas API to act. Before you decide on the action that you want to take, make sure that the action is available on the 3Commas API.

Before you start, you need:


We’ll be using Python as our scripting language, but you can see several other language examples in the LunarCrush documentation. For brevity, we’ll return only the top 2 coins and look at the JSON output. You can, of course, pull the top 10 or top 20 coins and review them.

The sort and limit parameters can be used on the coin endpoint to perform the query. Since the galaxy_score sort value sorts with the most popular asset first, you can use it with a limit value of “2” to get the top two assets. The following code snippet uses the API to pull the top 2 coins based on their Galaxy Score and prints them to the screen:

The print command displays:

The gs value is the Galaxy Score metric, so as you can see SUZUME is the first asset listed with a Galaxy Score of 68. BOMB is the next asset with a Galaxy Score of 67. We can step through each of these values to act as the 3Commas API.

The first step is to add a loop to the code to iterate through each asset. In this example, the name of the asset and its Galaxy Score are printed but will be replaced with 3Commas API action calls:

Now that you’ve tested the LunarCrush API, you can add code to act on the 3Commas API. We’re doing a simple trade in the following code with the new 3Commas code bolded:

In this code snippet, the p3cw 3Commas wrapper simplifies all the calls to the API. The “entity” can be one of several listed in the wrapper documentation. In each of the entity helpers, you can read how to send a payload (command) to the API to act. In this example, trade is done using the smart_trades_v2 endpoint, but you can also make changes to a bot, your account, deals, and the marketplace.

You can add a filter to drill down even further. It’s not enough to pull only coins with the highest Galaxy Score for some traders. You might want a coin with a high trading volume, market cap, or one within a specific category. This filter would be programmed in your Python script, so it takes some extra development. Let’s take the script and edit it to only work with coins in the NFT category.

The newly added lines of code are bolded. It determines if the asset is in the NFT category before processing it on the 3Commas API. You can filter trades even further using any of the data points returned by LunarCrush. Here is the output using a coin with its annotations to describe values you’ll find in the API:

LunarCrush returns the highest-scoring datasets by default, meaning that the default sort order is the highest Galaxy Score coin to the lowest Galaxy Score coin. The limit is set to 50 in this latest example, so the top 50 coins based on Galaxy Score are returned. You may at some point want to get the lowest value Galaxy Score coins, so you can reverse the sort order using the “desc” parameter. Here is the same code, but in descending order:

Try out both code snippets to see the difference in your dataset. We limit it to 50 coins, but you can leave the parameter empty to return all coins or limit your dataset even further.**
While this is a simple script, you can get much more creative and complex by writing your bots in the language of your choice. The two APIs offer a flexible way to control your trade activity to optimize your profits and lower your overhead. For example, you could write a script that continually polls the LunarCrush API for the best opportunities and automatically performs trades without lifting a finger.


Building with LunarCrush introduces opportunities that you might not know without hours of research and constant monitoring. Let LunarCrush help you simplify and automate your discovery process, and use it to automate trades against any bot interface.

Check out what’s happening in the market__ now, orsign up to get started.
Encode, Stream, and Manage Videos With One Simple Platform
Quality Weekly Reads About Technology Infiltrating Everything


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.