# Point a script at anything. Get *tapped* when it changes.

> Turn any Python script into a price drop or restock alert on WhatsApp: a polling loop and one POST to pingwa. A two-way variant asks you before buying.

Recipe · Watchers & scrapers

Restock watches, price drop alerts, appointment slots: the pattern is always the same loop. Fetch, check, and when the thing finally happens, one `POST /v1/notify` buzzes your WhatsApp. Text **join** to get a key, paste the loop, walk away.

§ 1

## The watcher loop

The whole recipe is a dozen lines. Poll the page on a polite interval, and the moment your condition flips, send yourself a ping. Swap the `if` line for whatever you're watching: a price under a threshold, a "sold out" badge disappearing, a calendar slot opening up.

restock_watch.py

```
import httpx, os, time

while True:
    page = httpx.get("https://shop.example/product/42").text
    if "out of stock" not in page.lower():
        httpx.post("https://pingwa.dev/v1/notify",
                   headers={"Authorization": f"Bearer {os.environ['PINGWA_KEY']}"},
                   json={"text": "Restock: product 42 is back 📦"})
        break
    time.sleep(300)
```

Run it under `nohup`, tmux, cron, a Raspberry Pi: anywhere Python runs. The `break` means it pings once and stops; drop it if you want a standing watcher (see the FAQ on duplicate pings). Rather not run your own loop? [changedetection.io + pingwa](/changedetection) is the hosted version of this recipe.

§ 2

## Two-way: ask before acting

If the watcher should *do* something (add to cart, book the slot), don't let it act alone. Swap `/v1/notify` for `POST /v1/ask`: it sends the question with tap buttons and holds the connection open until you answer (up to 90 s, so give httpx a slightly longer timeout). Buttons get positional ids: `b0` is the first button, `b1` the second, `b2` the third. If the watcher fires outside your 24h reply window (likely, when it triggers days later), the buttons arrive as a numbered list instead of tap buttons. Replying **1** works the same and still maps to `b0`.

restock_watch_and_ask.py

```
import httpx, os, time

while True:
    page = httpx.get("https://shop.example/product/42").text
    if "out of stock" not in page.lower():
        r = httpx.post("https://pingwa.dev/v1/ask",
                       headers={"Authorization": f"Bearer {os.environ['PINGWA_KEY']}"},
                       json={"text": "Restock found — buy now?",
                             "buttons": ["yes", "no"],
                             "timeout": 90},
                       timeout=95)
        if r.status_code == 200 and r.json()["reply"]["button_id"] == "b0":
            buy_product_42()   # your checkout logic
        break
    time.sleep(300)
```

A `408` means you didn't answer within the window. The question is still delivered, and the reply stays retrievable via `GET /v1/messages/<id>/reply`. See the [API docs](/docs) for the full response shapes.

§ 3

## Or just tell your agent to build it

Don't feel like writing the loop? Hand the job to your coding agent. The docs are agent-readable.

✂ paste this to your coding agent `Build me a Python watcher that checks <URL> every 5 minutes and asks me on WhatsApp before buying. API docs: https://pingwa.dev/llms.txt`

§ 4

## FAQ

### Can I get a price drop alert on WhatsApp?

Yes. That's the same loop with a different condition. Parse the price out of the page (a regex or BeautifulSoup one-liner), compare it to your threshold, and `POST /v1/notify` with the price in the text when it drops. Track the last-seen price in a file if you want "dropped since yesterday" rather than "below X".

### How do I write a restock notification script?

Recipe § 1 above is exactly that. Two honest caveats. Keep the interval polite: every 5 minutes (`time.sleep(300)`) is plenty for a restock, and hammering a shop every few seconds is a good way to get your IP blocked. And if a site sits behind serious bot protection, pingwa can't help with that part: it delivers the ping, it doesn't bypass anyone's defenses. Check the site's terms before you scrape it.

### Can I build an appointment slot checker that pings my phone?

Same skeleton: fetch the booking page (or its JSON endpoint, found in the network tab and usually cleaner than HTML), test whether a slot appears, and notify. Slots vanish fast, so this is the case for the § 2 variant: `/v1/ask` with buttons, so you can approve the booking from your phone the moment the watcher finds one.

### My watcher is flaky and pings me twice for the same event.

Send an `Idempotency-Key` header with a value derived from the event (e.g. `restock-product-42-2026-07-16`). pingwa honors the key for 24 hours: the same key replays the original result (no duplicate message, no extra quota) even if your loop fires twice or a retry races. Same key with a different body returns `409`.

[Send “join” on WhatsApp →](https://wa.me/48797882513?text=join%20watchers) [More recipes](/use-cases) [Read the API](/docs)

![QR code to join pingwa on WhatsApp](/join.svg?tag=watchers&n=48797882513)

Scan the code and get instant access. It opens WhatsApp with “join” ready to send, and your API key comes straight back.

Watchers poll on your machine, on your responsibility: respect each site's terms and rate limits. pingwa only carries the ping, over the official Meta Cloud API. The free plan's 30 paid messages a month go a long way here: a watcher that fires once when the thing happens costs one.
