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 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, a few platforms out there aim to simplify this part of the process.

Using Quix and CoinAPI for Bitcoin price tracking

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 straightforward use case that leverages CoinAPI’s Market Data API: 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.

Step 1. Check the Bitcoin price

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

Step 2. Compare the Bitcoin price with the threshold

See if the Bitcoin price has moved beyond the target price threshold in either direction.

Step 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

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:

A pipeline view showing three connected stages: "Coin API" (blue), "Threshold Alert" (purple), and "Twilio Alerter" (orange). Each stage displays its running status and resource usage. The stages are connected by arrows, indicating a workflow from left to right.

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).
Setup and deploy interface for Coin API configuration. It shows input fields for Name ("Coin API - Source"), output ("coin-data"), API key (hidden), primary currency (BTC), and secondary currencies (USD,GBP). A blue "Deploy" button is at the bottom.
  1. You’re free to adapt the code however you’d like, but it’s handy to have some boilerplate to get started.
  2. 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.

The image contains two main parts. The top half shows a graph with a blue wavy line representing a signal value, a dashed horizontal line for a threshold value, and orange dots indicating alerts where the signal crosses the threshold. The bottom half displays a code editor with Python code visible, focusing on a function that processes signal values and determines inequality sides for threshold alerts.
  • 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.

Setup and deploy interface for Twilio configuration. It displays input fields for Name ("Twilio - Destination"), input, numbers, account_sid, auth_token, messaging_service_sid, and message_limit (set to 2). A blue "Deploy" button is at the bottom of the form.

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.

Deploy interface for Coin API project. It shows project details, version tag, environment variables, and deployment settings. The deployment type is set to "Service - runs indefinitely and restarts automatically" with CPU, Memory, and Replicas options. Public Access and State Management toggles are visible. The deployment name is set to "Coin" with Deploy and Cancel buttons at the bottom.

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 do Quix and CoinAPI deploy a currency alerting pipeline?

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.

A web interface for setting up the Coin API in a development environment. The left side shows input fields for configuring the API, including name, output, API key, and currency options. The right side displays setup instructions, requirements, and environment variables. The interface includes options to deploy or save as a project. A small profile picture of a man with glasses is visible in the bottom right corner.

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 Quix.io.

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

Send

I Agree to CoinApi’s Privacy Policy*

Recent Articles

background

News, Market Data API

Hyperliquid - A New Decentralized Crypto Exchange Integrated

Hyperliquid is a decentralized cryptocurrency derivatives exchange launched in 2022. It specializes in perpetual futures trading, offering...
background

Market Data API

Redundancy - The Basis of Crypto Data Services

In a modern, technological business, one of the most important challenges is to ensure that your product keeps working. That's mean you...
background

EMS Trading API

13 Advanced Order Types That Can Increase Your Profits in Crypto

Advanced order types address traders' needs for better risk management, greater flexibility and...
background

News

CoinAPI November update: New documentation, Open API and Metrics API

As 2023 wraps up, were excited to highlight the CoinAPI November update. Weve rolled out some enhancements to elevate your experience....
background

Node as a service, EMS Trading API, Market Data API

Understanding CoinAPI User Permissions and Rights

Many of our customers have been seeking clarity on “CoinAPI user permissions and rights” when using our data. Recognizing the...
background

EMS Trading API

Multi-Asset Crypto Trading With EMS Trading API

Did you know? The fundamental principle of diversification, which lies at the heart of multi-asset trading, can be likened to the age-old...
background

EMS Trading API

EMS Trading API for Hedge Funds

Did you know that hedge funds manage approximately $3.6 trillion in assets globally? This staggering figure underscores the critical need...
background

EMS Trading API

The Role of EMS Trading API in Portfolio Management

Managing investments isnt easy. With trillions of dollars globally stake, portfolio managers have a huge responsibility. They need the best...
background

EMS Trading API

High-Frequency Trading With EMS Trading API: Unveiling its Impact on Cryptocurrency

In the dynamic world of cryptocurrency trading, where trillions of dollars are transacted every...
background

Node as a service

Blockchain Nodes – Shared, Semi-Shared, or Dedicated Nodes

Blockchain nodes are the pillars that uphold the integrity and functionality of a blockchain network. These internet-connected devices...
background

Use case

Preventing Crypto Manipulation With Cryptocurrency API

Did you know that market manipulation in the crypto sector leads to billions of dollars in losses every year? This critical issue poses...
background

Market Data API

How CoinAPI Ensures Data Accuracy and Speed

  One of the most frequently asked questions we receive from our customers is, “What is the collection process for your...

Crypto API made simple: Try now or speak to our sales team