Build a Crypto Price Alert Bot
Learn how to create a real-time cryptocurrency price alert system using DexPaprika API and Telegram
The API is currently in beta and we cannot guarantee the stability of the data. Please be aware that the data might be inaccurate or incomplete and therefore should not be used for any critical applications. If you find any issues, please contact us.
Overview
This tutorial guides you through building a real-time cryptocurrency price alert system that monitors prices using the DexPaprika API and sends notifications to your Telegram when price thresholds are met. Perfect for traders and developers who want to stay updated on market movements without constant manual checking.
The complete code for this tutorial is available on GitHub.
Features
- Track any cryptocurrency available on DexPaprika API
- Set custom price thresholds for buy/sell opportunities
- Get instant alerts when prices go above or below your targets
- Configure check intervals to match your trading strategy
- Receive notifications directly on Telegram
Prerequisites
- Node.js (v14 or higher)
- npm (Node Package Manager)
- A Telegram account
- A Telegram Bot (created using BotFather)
Step 1: Create Your Telegram Bot
- Open Telegram and search for “BotFather” (@BotFather)
- Start a chat and send the command
/newbot
- Follow the instructions to create your bot
- Save the bot token BotFather provides you
Step 2: Get Your Telegram Chat ID
- Start a conversation with your new bot
- Send any message to your bot
- Visit this URL in your browser (replace with your actual token):
- Find the
"chat":{"id":XXXXXXXXX,
value in the response - this is your chat ID
Step 3: Set Up the Project
- Clone the repository or set up a new project:
- Install required dependencies:
- Create the following files in your project directory:
.env
(configuration file)index.js
(main application)
Step 4: Configure Your Settings
Create a .env
file in the project directory with the following parameters:
Make sure to replace placeholder values with your actual configuration details.
Step 5: Create the Alert Bot
Create an index.js
file with the following code:
Step 6: Finding the Right Token Address
Need to track a different token? Use DexPaprika API to find its address:
- List available networks:
- Search for your token:
Step 7: Running the Bot
- Start the bot:
- You’ll receive a confirmation message on Telegram.
- The bot will check prices at your specified interval
- When your price condition is met, you’ll get an alert
Running as a Background Service
On Linux/Mac:
On Windows:
How It Works
- The application connects to DexPaprika API to retrieve real-time token prices
- It compares the current price against your target threshold
- When the condition is met, it sends an immediate alert via the Telegram Bot API
- The process repeats based on your configured check interval
Troubleshooting
- Not receiving messages? Double-check your bot token and chat ID
- Ensure your network/token combination is valid in DexPaprika
- Check console output for any error messages
Next Steps
Add Multiple Alerts
Extend the code to monitor multiple tokens or set different thresholds.
Create a Web Dashboard
Build a visual interface to manage your alerts and view price history.
Share Your Extensions! Built something cool by extending this tutorial? We’d love to see it! Share your work on our Discord - your tutorial might be featured on our website. Ideas to try: smart trend alerts, multi-token tracking, or historical data analysis.
Get Support
Was this page helpful?