Skip to content

Coin price alert

$0.05 per callUSDC via x402POST /api/coin-alert

Get one signed POST at your https URL when a coin's price crosses a level you set.

Category: Crypto & onchain dataTags: crypto price alert webhook notificationAlso found as: coin-price-alert crypto-price-alert

Try in playground →

Details

Give "coin" (a coin id such as bitcoin), "level" (US dollars) and "url". The message says the level was crossed and which way, up or down; it never carries the price. It fires once, whichever way the price crosses from where it was when you made the alert. The price is checked about every 5 minutes, less often when many coins are watched or this server is near its daily reads, so a move that crosses and comes back between checks is missed. An alert lasts 30 days ("expiresAt") and ends then if the level was never crossed. The answer carries a secret; each POST is signed with it in X-Agent402-Signature. A POST your receiver does not accept is tried up to 5 times, with the same delivery id. One wallet holds up to 25. Cancel free with POST /api/coin-alert/cancel and the id and secret. Not investment advice, and not for automatic trading. Deterministic code, no model. Powered by CoinGecko (https://www.coingecko.com/en/api).

Parameters

NameTypeRequiredDescription
coinstringyesCoin id, such as bitcoin, ethereum or solana (not a ticker). Also accepted as symbol, id, ticker, asset, currency. Up to 100 characters. The example sends bitcoin.
levelnumberyesThe price in US dollars to watch for. The example sends 100000.
urlstringyesThe https URL that receives the signed POST. No credentials in the URL; it must resolve to a public address. Also accepted as link, uri, href, page. Up to 2048 characters. The example sends https://example.com/.

Example request

curl -i -X POST https://agent402.tools/api/coin-alert \
  -H "Content-Type: application/json" \
  -d '{"coin":"bitcoin","level":100000,"url":"https://example.com/"}'

Watch a call get paid

RequestPOST /api/coin-alert
402$0.05 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example response

{
  "id": "ca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c",
  "url": "https://example.com/",
  "coin": "bitcoin",
  "level": 100000,
  "currency": "usd",
  "secret": "a402whsec_<64 hex characters>",
  "signature": {
    "header": "X-Agent402-Signature",
    "scheme": "t=<unix seconds>,v1=<hex HMAC-SHA256, with the secret, of \"<t>.<body>\": the timestamp, a dot, and the body as sent>"
  },
  "event": "coin.level_crossed",
  "unsubscribe": {
    "method": "POST",
    "url": "https://agent402.tools/api/coin-alert/cancel",
    "body": {
      "id": "ca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c",
      "secret": "<the secret above>"
    }
  },
  "expiresAt": "2027-01-04T12:00:00.000Z",
  "registered": false,
  "delivers": false,
  "note": "example.com is a documentation host: the registration is answered as a real one would be, and nothing is stored or sent.",
  "credit": "Powered by CoinGecko (https://www.coingecko.com/en/api)."
}
FieldTypeAlways presentIn the example
idstringyesca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c
urlstringyeshttps://example.com/
coinstringyesbitcoin
levelnumberyes100000
currencystringyesusd
secretstringyesa402whsec_<64 hex characters>
signatureobjectyes2 fields: header, scheme
eventstringyescoin.level_crossed
unsubscribeobjectyes3 fields: method, url, body
expiresAtstringyes2027-01-04T12:00:00.000Z
registeredbooleanyesfalse
deliversbooleanyesfalse
notestringyesexample.com is a documentation host: the registration is answered as a real o...
creditstringyesPowered by CoinGecko (https://www.coingecko.com/en/api).

From an MCP client

catalog.call {
  "slug": "coin-alert",
  "params": {
    "coin": "bitcoin",
    "level": 100000,
    "url": "https://example.com/"
  }
}

Hosted connector (https://agent402.tools/mcp): paid in the call. Stdio package (npx -y agent402-mcp@0.20.1): pays from a wallet or AGENT402_CREDITS_KEY.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.05" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/coin-alert", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "coin": "bitcoin",
    "level": 100000,
    "url": "https://example.com/"
  }),
});

Get a wallet or run npx -y agent402-mcp@0.20.1 wallet new.

The quote (Python)

import base64, json, urllib.error, urllib.request

req = urllib.request.Request("https://agent402.tools/api/coin-alert", method="POST", data="{\"coin\":\"bitcoin\",\"level\":100000,\"url\":\"https://example.com/\"}".encode(), headers={"Content-Type": "application/json"})
try:
    urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
    quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
    print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]])  # the price, per chain, in base units

Related tools