background-hooknotifierbackground-hooknotifier
Last update: Jul 04, 20262 minutes read

Send yourself a push notification from Python

low-code

Send yourself a real push notification from any Python script with a few lines and the requests library. No app to build, no backend. Free.

To send yourself a push notification from Python, make one request to your Hook.Notifier URL with the requests library. A few lines and your phone rings.

import requests

requests.post("https://hooknotifier.com/{IDENTIFIER}/{KEY}", json={
    "object": "Done",
    "body": "My Python script finished",
})

A fuller example

Here is a script that notifies you when a long job finishes, with a color and tags.

import requests

def notify(object, body):
    requests.post("https://hooknotifier.com/{IDENTIFIER}/{KEY}", json={
        "object": object,
        "body": body,
        "tags": "python,jobs",
    })

# ... your long-running work ...

notify("Training done", "The model finished after 3 hours")

Notify on error too

Wrap your work so a crash reaches your phone instead of a silent log.

try:
    run_the_job()
    notify("Job done", "Everything went fine")
except Exception as e:
    notify("Job failed", str(e))
    raise

Priorities and live updates

Two parameters worth knowing. priority (low, normal, high, critical) decides how loud the ping is: low skips the phone push, high and critical cut through quiet hours. And the send returns an id you can PUT back to, updating the notification in place instead of stacking new ones.

import requests

url = "https://hooknotifier.com/{IDENTIFIER}/{KEY}"

# Send returns {"status": "ok", "id": 42}
res = requests.post(url, json={
    "object": "Batch job",
    "body": "Started",
    "priority": "low",
})
notification_id = res.json()["id"]

# ... run the job ...

# Update the same notification in place
requests.put(f"{url}/{notification_id}", json={
    "object": "Batch job",
    "body": "Done, 4210 rows processed",
})

Add "markdown": True and the body renders as markdown, bold, lists, links and all.

hook notifier notification

First get your URL

Your Hook.Notifier URL is https://hooknotifier.com/{IDENTIFIER}/{KEY}. Create a free account to get yours, then drop it into your script.

Why it matters

Python scripts often run for a while and then sit there, waiting for you to check. A couple of lines turn that into a phone that tells you the moment the work is done or broken.

New to this? Start with how to send yourself a native push notification.