Back to Developer Tutorials
Automation & Telegram Bots• 8 min read•Last Updated: October 2026

How to Build a Real-Time IPO GMP Tracker with Node.js & Telegram Alerts

In this guide, you will learn how to build an automated background worker in Node.js that polls real-time Grey Market Premium (GMP) rates from IPO API PRO, detects price movements, and dispatches instant Telegram channel alerts before market opening.

Prerequisites

  • Node.js v18 or higher installed on your system
  • An active IPO API PRO Subscription (ApiKey & ApiSecret)
  • A Telegram Bot token created via @BotFather and your target Channel/Chat ID

1Initialize Node.js Project & Dependencies

Create an empty directory and initialize a new Node.js package with modern ECMAScript module ("type": "module") support. Install Axios for HTTP requests, node-telegram-bot-api for Telegram communications, and node-cron for scheduling.

package.json
json
{
  "name": "ipo-gmp-telegram-tracker",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "axios": "^1.7.0",
    "dotenv": "^16.4.5",
    "node-cron": "^3.0.3",
    "node-telegram-bot-api": "^0.66.0"
  }
}

2Configure Environment Credentials

Store your secrets in a local .env file. Never hardcode API keys into source repositories.

.env
bash
IPO_API_KEY=YOUR_ACTUAL_API_KEY
IPO_API_SECRET=YOUR_ACTUAL_API_SECRET
TELEGRAM_BOT_TOKEN=123456789:ABCDefGhIJKlmNoPQRsTUVwxyZ
TELEGRAM_CHAT_ID=-1001234567890

3Implement the GMP Polling & Notification Script

Create tracker.js. The script maintains an in-memory cache of past GMP quotes to avoid spamming the channel when rates are unchanged. When a rate shifts by even ₹1, it formats an alert with expected listing gain percentage and sends it to Telegram.

tracker.js
javascript
import axios from 'axios';
import TelegramBot from 'node-telegram-bot-api';
import cron from 'node-cron';
import dotenv from 'dotenv';

dotenv.config();

const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN, { polling: false });
const API_URL = 'https://api.ipoapipro.in/api/gmp/live-rates';

// Cache previous GMP state to detect movements
const lastKnownGmp = new Map();

async function checkGmpMovements() {
  try {
    console.log('[%s] Polling live IPO GMP quotes...', new Date().toISOString());

    const response = await axios.get(API_URL, {
      headers: {
        'ApiKey': process.env.IPO_API_KEY,
        'ApiSecret': process.env.IPO_API_SECRET,
      },
      timeout: 10000,
    });

    const ipos = response.data?.data || [];

    for (const ipo of ipos) {
      const { ipoId, companyName, ipoPrice, gmpPrice, estimatedListingPercentage } = ipo;
      const previousGmp = lastKnownGmp.get(ipoId);

      // Check if GMP has changed
      if (previousGmp !== undefined && previousGmp !== gmpPrice) {
        const diff = gmpPrice - previousGmp;
        const trendEmoji = diff > 0 ? '🚀 UP' : '🔻 DOWN';

        const message = 
          `🔔 *IPO GMP Movement Alert*\n\n` +
          `*Company:* ${companyName}\n` +
          `*Issue Price:* ₹${ipoPrice}\n` +
          `*Current GMP:* ₹${gmpPrice} (${trendEmoji} ₹${Math.abs(diff)})\n` +
          `*Expected Listing Gain:* +${estimatedListingPercentage}%\n` +
          `*Estimated Listing Price:* ₹${ipoPrice + gmpPrice}\n\n` +
          `_Data via IPO API PRO • Real-time Feed_`;

        await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, message, { parse_mode: 'Markdown' });
        console.log(`Alert dispatched for ${companyName} (GMP changed: ₹${previousGmp} -> ₹${gmpPrice})`);
      }

      // Update state
      lastKnownGmp.set(ipoId, gmpPrice);
    }
  } catch (error) {
    console.error('Error fetching live GMP feed:', error.message);
  }
}

// Schedule task to run every 15 minutes during Indian market hours (9:00 AM - 5:00 PM IST Mon-Fri)
cron.schedule('*/15 9-17 * * 1-5', () => {
  checkGmpMovements();
});

// Run initial execution on startup
checkGmpMovements();
console.log('IPO GMP Telegram alert tracker started successfully.');

4Run & Deploy as a 24/7 Background Service

Run your tracker locally or deploy it to a cloud VPS using PM2 to ensure automatic recovery upon system restart:

deploy.sh
bash
npm install -g pm2
pm2 start tracker.js --name "ipo-gmp-bot"
pm2 save
pm2 startup

Related Endpoints Used in this Guide