Tutorials3 min read

Webhooks vs polling: near-real-time monitoring without webhooks

No webhooks? No problem. A battle-tested polling loop gives you near-real-time crypto transaction monitoring you fully control.

cryptoapi team
Tutorials
On this page

Let's be honest up front: CryptoAPI has no public webhooks and no streaming API. If you want to know when funds land at an address, you poll. That sounds like a downgrade, but a well-built polling loop is simpler to reason about, easier to debug, and gives you full control over timing and idempotency. Here's the pattern we recommend.

Webhooks vs polling, honestly

Webhooks push: the provider calls your URL when something happens. Polling pulls: you ask on an interval.

  • Webhooks pros: lower latency, no wasted calls. Cons: you must run a public HTTPS endpoint, verify signatures, handle retries and duplicate deliveries, and you're at the mercy of the sender's queue.
  • Polling pros: no inbound endpoint, no signature dance, trivial to run from a cron job or worker, and you decide exactly how fresh "fresh" is. Cons: a little latency and some empty calls between events.

For most balance-watching, deposit-detection and treasury use cases, polling wins on operational simplicity.

The polling pattern

Call GET /api/blockchain/transactions on an interval, newest first, and bound the query with startDate so you only ask for what's new. The network parameter is required; every call needs your API key. Keep a set of hashes you've already seen and treat anything new as a fresh event.

bash
curl "https://api.cryptoapi.so/api/blockchain/transactions?network=ethereum&address=$WALLET_ADDRESS&sortBy=timestamp&sortOrder=desc&startDate=$START_TIMESTAMP&limit=100" \
  -H "key: YOUR_API_KEY"

A response row looks like this:

json
{
  "hash": "0xabc...",
  "blockNumber": 19850123,
  "timestamp": 1716960042,
  "fromAddress": "0xsender...",
  "toAddress": "0xYourAddress",
  "valueDecimal": "0.25",
  "feeDecimal": "0.00031",
  "status": "success",
  "tokenSymbol": "ETH"
}

And the loop itself:

output
seen = load_persisted_hashes()
lastSeen = load_last_timestamp()  # unix seconds

loop forever:
  rows = GET /api/blockchain/transactions
           network=ethereum, address=ADDR,
           sortBy=timestamp, sortOrder=desc,
           startDate=lastSeen, limit=100

  for row in reversed(rows):       # process oldest first
    if row.hash not in seen:
      handle(row)                  # fire your notification / credit deposit
      seen.add(row.hash)           # persist BEFORE acking
      lastSeen = max(lastSeen, row.timestamp)

  sleep(interval)

Two rules make this safe:

  • Persist the hash before you act on it, or persist it idempotently in the same transaction as your side effect. The hash is your dedupe key, so you never double-fire on overlapping polls.
  • **Use startDate = your last seen timestamp** (minus a few seconds of slack for late indexing) so each poll stays small and cheap.

Tuning the interval

There's no single right number. Match it to the job:

  • Live dashboard or deposit detection: every 30 seconds.
  • Treasury reconciliation or low-traffic wallets: every few minutes.

Lower intervals mean fresher data and more calls. Pick the trade-off that fits your quota and your users.

Watch the live window

GET /api/blockchain/transactions reads from an indexed store that covers up to 30 days of live indexed data. That's perfect for monitoring, where you only care about recent activity. For a one-off lookup of an older hash, use the live single-transaction endpoint, which depends on the configured provider’s history coverage:

bash
curl "https://api.cryptoapi.so/api/blockchain/transaction?network=ethereum&transactionId=0xabc..." \
  -H "key: YOUR_API_KEY"

Ship it

This pattern works the same across ethereum, bnb, bitcoin and tron, with no nodes to run and no webhook infrastructure to babysit. Grab an API key in the dashboard and read the full reference at https://api.cryptoapi.so/api/doc.

Query available archive days

The live index covers up to 30 days. Use GET /api/blockchain/transactions/history for available archived days and follow nextCursor. The response reports coverage gaps in missingDays. Use GET /api/blockchain/transactions/download to find published daily Parquet files within the one-year retention.

Read it, then ship it

Copy the code above and run it today.

Every snippet in this guide works on the free plan. Grab a key and make your first call in a minute.