Introducing EMS Trading API  EMS Trading API

- Unlimited trading accounts in just one place.

Market Data API

How Quix and CoinAPI deploy currency alerting pipeline

featured image

While it’s easy to write an app that does useful things with crypto market data, it can involve a bit of tedious busy work. For example, once you’ve programmed all the required steps, you’ll need to find a way to securely deploy and host your app. Luckily, there are a few platforms out there that aim to simplify this part of the process.

Today, we’re going to look at a tool that specializes in helping developers and data engineers deploy real-time data apps and pipelines. It’s called Quix, and it’s a pretty handy tool if you’re working with any kind of volatile market data. 

To help you understand how it works, let’s look at a very simple use case that leverages CoinAPI market data: an alerting app that sends an SMS when the price of Bitcoin crosses a specific threshold.

How do Quix and CoinAPI deploy a currency alerting pipeline?

To build this simple alerting app, we’ll need to code the following major functions.

1. Check The Bitcoin Price
Poll the CoinAPI market data endpoint for the current Bitcoin price (no less than every 15 mins if you’re on the free plan).

2. Compare The Bitcoin Price With The Threshold
See if the Bitcoin price has moved beyond the target price threshold in either direction.

3. Trigger an external notification
Send a message to let you know that the threshold has been met (for example, using an SMS API like Twilio).

We’re going to break down the steps in a bit more detail and look at how you’d create and run them within the Quix platform. But first, it’s important to clarify that in Quix, you write functions in Python (or C#) that interact with Apache Kafka.

– Why Python? The Quix platform runs on the Quix SDK, which enables you to code in Python yet easily interact with Kafka topics. Up until recently, you’d need to know your way around Java before you could work with Apache Kafka, but Quix has built its own SDK so that you code in Python and C#. It’s designed to make Apache Kafka more accessible to data scientists and engineers who are typically more proficient in Python

– And Why Kafka? To keep it simple, this example uses our REST API, but more advanced apps often use our Websocket endpoint—which is a constant stream of data. Apache Kafka is still the industry standard for working with data streams, which is why the Quix platform also uses Kafka as its foundation.

Ok, so how would you make these functions work together in the Quix platform? Let’s look at the end result first. What you see here are the 3 functions chained together to form a simple pipeline:

How Quix and CoinAPI deploy a simple currency alerting pipeline

We’re going to explore a quick way to build each of these functions. Bear in mind that this is not a full tutorial, but rather an overview of how programs are run and deployed in Quix (we’ll link to a more detailed tutorial after the overview). 

1. Polling  the Market Data endpoint


Quix has an extensive library of Python code templates to bring in data from many external sources—including CoinAPI. You just need to copy the library to your workspace and give it the environment variables that it expects. These are as follows:

    • The API key that you use to access CoinAPI.
    • The shortcode for the currency that you want to track (e.g. BTC), 
    • The shortcodes of the equivalent fiat currencies (USD, GBP).

How Quix and CoinAPI deploy a simple currency alerting pipeline

– You’re free to adapt the code however you’d like, but it’s handy to have some boilerplate to get started.

– This boilerplate code writes the market data to a preconfigured Kafka topic called “coin-data”.

2. Do the comparison

Quix’s template library also contains a handy function for checking thresholds, so you can just enter your desired threshold and connect it to the incoming price data.

How Quix and CoinAPI deploy a simple currency alerting pipeline

  • This boilerplate code reads incoming prices from the “coin-data” topic and checks to see if the threshold has been crossed. 
  • When the threshold is crossed, the function will write a message to the “coin-alerts” topic.

3. Send the notification with Twilio

Naturally, Quix also has boilerplate code for accessing Twilio. In this case, you enter a few variables related to your Twilio account. Sadly, there’s no easy way to automate the Twilio account creation process, but once you have a Twilio developer account, you can just plug your account details into the Quix UI. These are then saved as environment variables.

The Twilio boilerplate code checks for incoming messages from the “coin-alerts” topic and uses the Twilio API to send an SMS to your phone.

4. Deploying the code as serverless functions

After you’ve finished setting up each step, you click the big blue “deploy” button. Each function then runs in the Quix platform as a serverless function. 

The kind of architecture that we’ve outlined here is often called “loosely coupled” architecture. It means that the different parts are not highly dependent on each other. For example, if the Twilio service goes down, the alerts will not fail, they will just be delayed. The “coin-alerts” topic will accumulate messages and the Twilio service will process the message backlog once it comes back online.  

How Quix and CoinAPI deploy currency alerting pipeline? Learn More About Deploying Currency Alerts In The Quix Platform

We hope this walkthrough gave you a first taste of what the platform can do. Quix is a great match for market data APIs such as CoinAPI. It can handle more complex pipelines and back-end architectures too. You can use Quix’s built-in connectors to bring your data in and send it back out again—to a mobile app, a data warehouse, or an external service. The choice is yours.

For a detailed tutorial on how to build what we just described in this walkthrough, check out this simple video tutorial

Note that it doesn’t contain the threshold checking step, but you can easily add this step from the Quix library. Happy coding! 

This is a guest blog post written by Tomas Neubauer and was originally published on https://www.quix.io/blog/deploy-real-time-currency-alerting-pipeline/

Stay up-to-date with the latest CoinApi News.

Send

I Agree to CoinApi’s Privacy Policy*

Recent Articles

background

Market Data API

Crypto data standardization – the key to making insight-based decisions

Learn about the importance of data standardization in cryptocurrency markets for accurate analysis and decision-making, highlighting the...
background

Market Data API

The power of crypto API on DEX

Decentralized Exchanges (DEXs) are peer-to-peer marketplaces without a central authority, growing in popularity with examples like Uniswap...
background

EMS Trading API

How CoinAPI crypto trading API enhances crypto trading efficiency?

Today, crypto traders face challenges like limited liquidity causing slippage and difficulty in executing large orders without affecting...
background

News

CoinAPI January update: NaaS, new website, Market Data API on QuickNode marketplace

CoinAPI January update features some exciting info about our future developments such as NaaS...
background

Market Data API

How does CoinAPI maximize the effectiveness of crypto trading bots?

Crypto trading bots are essential for trading on the dynamic cryptocurrency market. They need the best data for the best outcomes, though....
background

Market Data API

Crypto tax API: Discover the future of crypto tax management with CoinAPI

As tax return deadlines approach in various countries worldwide, traders and investors are struggling with the complexities of reporting...
background

CryptoTick

A guide to using Cryptotick for crypto historical data

Did you know that CoinAPI, beyond API products, offers a streamlined solution for those seeking easy access to historical crypto data?...
background

Market Data API

The future of trading: How cryptocurrency API is changing the game

As we move from 2023 into 2024, CoinAPI cements its role as a global leader in the cryptocurrency API space. With the launch of our EMS...
background

EMS Trading API

CoinAPI update: Cryptocurrency trading API and new integrations

This month, CoinAPI is proud to launch our cryptocurrency trading API, alongside key partnerships with Quicknode. We’ve also expanded...

Bring the power of crypto API to your business in minutes