Use Node.js and Cassandra to build an encrypted currency price tracker

Since the 15 years ago, the data technology is a big explosion, the technology like Hadoop catering to four “V” (quantity, speed and accuracy), which is increasingly common: use specialized functions Database to meet different types of data and usage patterns. Many companies now use the graph database, time series database, document database, and other databases to handle different customers and internal workloads.

ApacheCassandraTM is a wide column NOSQL database that is ideal for more applications that obtain data from the Internet of Think sensors, GPS devices, transaction logs, and any time series applications, write intensive workloads. Many of these applications need to be combined with visualization engines to create reports and dashboards. Since most visual libraries are written using JavaScript, it is a good idea to interact with the database and visualization engine using Node.js.

This tutorial will introduce how to get encrypted currency data from the API using a small Node.js application, and continuously in Cassandra for caster consumption. You can feed data from Cassandra to numerous applications, such as encrypted currency trading platforms, encrypting currency prices monitoring and alarms.


You need the following before you start learning this tutorial:

Node.js – Local node.js installation with the default package manager NPM. Git-clone contains the GitHub code repository with this tutorial code. DataStax Astra- is used to start unstartful Cassandra databases, use with API or drivers. Coingecko-API- Node.js library for accessing COINGECKO encrypted currency data.

Clone repository

You can use the gitclone command to clone Cassandra Node.js Cryptotracker’s GitHub repository:

[email protected]: kovid-r / cassandra-nodejs-cryptotracker.git

After the cloned store, the primary task is to install the Node.js dependencies specified in the package.json file and the package-lock.json file. NPM will install dependencies in the repository directory using the following command:


These instructions also exist in the README file of the repository.

Configuring Astra

Create a database

Before running the application, you need to register with the DataStax Astra supported by Apache Cassandra and launch the Cassandra database.

Although price information will change as you change cloud providers and regions, for conceptual prove, even small production applications, you only need Astra already available $ 25 free points per month, you can let you Get approximately 40 GB of free storage space, 40 million reads and 5 million times. You can register without a credit card, just use Google or Github to log in.

Click the CreateDatabase option to enter the following page: You can create a database on any of the world’s three cloud providers (Google Cloud, AWS and Azure). You need to provide a database name (node ??application) and key space name (COINGECKO). Please use the specified name.

Initialization database

For the first time to access the database, use the CQLSH browser console, as shown below:

If there is no key space in the database, use the console to run two commands to create and create a table in the specified key space. The structure of the table is predefined in the Initialize.sql file in the repository. Data from CoingeckoAPI will appear in this table.

Download Secure Bundle

You need to download the DataStax Secure bundlezip file to the Node.js application directory. Make sure your browser does not decompress files when downloading files.

You need to provide the path to the configuration in the following steps; if you want to know more about Secure Bundle, visit the official documentation of DataStaxastra.

Generate authentication tokens

The next step is to generate an authentication token. To do this, click the billing option on the top menu bar. The screen shown below will appear:

Enter the token management option in the left menu bar, select the R / W User role in the Select Role drop-down menu, and press GenerateToken.

You will see the screen with the authentication token. Download the CSV format Client ID, Client Secret, and Token, or copy them directly. Run CRYPTOTRACKER

Authentication using NPM Config

Now we can continue to run the Node.jscryptotracker application. In this tutorial, we use the config package to avoid storeing tokens information in your code. We contain a file in the repository config / default.json, which looks like this:

Want to verify the identity, follow the instructions to replace the value of SecureConnectBundle, username, and password in the JSON file, but make sure not to submit it to the code base.

Run NPM Start

If you have configured everything correctly, you should now be able to run the following command from the node.js application directory:


Node.js application will run 40 seconds, hit the Coingecko API. You can change it by finding the two lines in the index.js file and reconfigure the main function call.

After running NPM Start a few times, you can go to the Astra website to see how much your quota is used, as shown below:

You can also log in to the CQL console, write a CQL query, get some data from the COINGECKO.COIN_PRICES table, as shown below:

If you want to get the price of other currency, you can pass different parameters to getCoinPrice method variables: CoinName and COINSYMBOL.

Connect other applications

Other applications can use data from Cassandra. DataStaxastra supports drivers for C #, Python, Node.js, Java, and C ++. You can seamlessly integrate popular visualization engines such as Grafana and Astra.


This tutorial introduces how to use Cassandra as a time series database, use the Node.js application to get encrypted currency price change information, but also introduce the cloud provider that uses your preferred cloud configuration DataSTASTRA database.

Original title: Build a crypto price tracker using node.js and cassandra, Author: Kovidrathee