A price alert is a loop: fetch the prices, compare each with its level, notify once. One /v2/simple/price call covers up to 250 alerts, and each price says when it was seen, so an alert never fires on an old price.
- One call checks every coin on your list.
- Each price carries
last_updated_at, so a stale price can be skipped. - Every plan stops at its monthly limit, so the polling interval decides which plan you need.
Routes it uses
| Job | Route |
|---|---|
| Check price levels | /v2/simple/price?ids=...&vs_currencies=usd&include_last_updated_at=true |
| Check a candle close | /v2/coins/{id}/ohlc?interval=1h&limit=2 |
| Watch without polling | The price stream |
Check the levels
This script holds three alerts and checks them in one call. It skips a price older than 60 seconds. Thin coins can be minutes or hours old; that is real, not an outage. It needs requests and the key in COINPRICE_API_KEY. Run it once a minute from cron or any scheduler.
import osimport timeimport requestsAPI = "https://api.coinprice.dev/v2"HEADERS = {"Authorization": f"Bearer {os.environ['COINPRICE_API_KEY']}"}# coin id: (direction, price in USD)ALERTS = {"bitcoin": ("above", 55000), "ethereum": ("below", 1500), "solana": ("above", 100)}def check(): response = requests.get( f"{API}/simple/price", headers=HEADERS, params={"ids": ",".join(ALERTS), "vs_currencies": "usd", "include_last_updated_at": "true"}, timeout=10, ) response.raise_for_status() prices = response.json() for coin, (direction, level) in ALERTS.items(): price = prices[coin]["usd"] if time.time() - prices[coin]["last_updated_at"] > 60: print(f"{coin}: price is stale, skipped") elif (direction == "above" and price >= level) or (direction == "below" and price <= level): print(f"ALERT {coin} is {price:,.2f}, {direction} {level:,}") else: print(f"{coin} is {price:,.2f}, no alert")check() # run this once a minute from cron or a schedulerALERT bitcoin is 60,459.71, above 55,000ethereum is 1,699.27, no alertsolana is 71.74, no alertA real alert also stores that it has fired, so the next run does not send the same message again. Replace the print with a message to Slack, email or a push service.
Polling interval and plan
| Check every | Calls a month | Fits |
|---|---|---|
| 60 seconds | 43,200 | Free, 50,000 a month |
| 15 seconds | 172,800 | Starter, 500,000 a month |
| 5 seconds | 518,400 | Basic, 2 million a month |
The count is the same for 1 coin or 250, because one call covers them all. When a plan reaches its limit the API answers 429 quota_exceeded until the next month, with no Retry-After, and it resets on the 1st of the month UTC. We email you at 80% and 100%. An alert service should stop and tell you on quota_exceeded. A 429 rate_limited means too many calls in a minute: wait Retry-After seconds and retry.
Why this data fits
- A price made from seven exchanges does not jump because one feed misprinted, so a level is crossed when the market crossed it.
- The stream is there when polling is not fast enough: Free has one stream of 10 channels every 5 seconds, and paid plans push every second.