
Build a Bitcoin Price Alert Bot in Python (Under 60 Lines, No API Key)
Everyone says "buy the dip" — but who's watching the price at 3am? I got tired of manually checking CoinGecko every hour. So I built a simple Python price alert bot. No API key, no crypto exchange account, no libraries to install. Under 60 lines. Works on Mac, Windows, Linux. Here's exactly how I built it. What It Does Fetches live BTC price from CoinGecko's free public API Compares to your target buy/sell price Prints a color-coded alert in your terminal Runs on a loop (check every N minutes) Logs price history to a local JSON file The Code import urllib.request import json import time import datetime import os # ─── CONFIG ──────────────────────────────── BUY_ALERT_BELOW = 60000 # Alert if price drops BELOW this SELL_ALERT_ABOVE = 90000 # Alert if price rises ABOVE this CHECK_INTERVAL = 300 # Check every 5 minutes (300 seconds) COIN = " bitcoin " CURRENCY = " usd " LOG_FILE = " btc_price_log.json " # ─────────────────────────────────────────── def fetch_price ( coin = COIN , currency
Continue reading on Dev.to Python
Opens in a new tab




