1# Python
2
3Uses the standard library `urllib.request` — no third-party dependencies required. Run each example as a standalone script.
4
5## Examples
6
7### Normal success
8
9```python
10import os, urllib.request
11
12req = urllib.request.Request(
13 f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
14 data=b"Finished refactoring the auth middleware in rumilo. Session validation is cleaner now and all tests pass.",
15)
16req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
17req.add_header("Title", "Refactored authentication middleware in rumilo")
18req.add_header("Tags", "hammer_and_wrench")
19urllib.request.urlopen(req)
20```
21
22### Success with a relevant click URL
23
24```python
25import os, urllib.request
26
27req = urllib.request.Request(
28 f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
29 data=b"Bumped the kagi-ken AUR package to v0.4.2 and updated the checksums.",
30)
31req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
32req.add_header("Title", "Updated AUR package for kagi-ken")
33req.add_header("Tags", "package")
34req.add_header("Click", "https://aur.archlinux.org/packages/kagi-ken")
35urllib.request.urlopen(req)
36```
37
38### Something went wrong
39
40```python
41import os, urllib.request
42
43req = urllib.request.Request(
44 f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
45 data=b"Ran into a full disk on the build server while compiling pi-mono. /var/log looks like it needs rotation. The build is blocked until there's space.",
46)
47req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
48req.add_header("Title", "Build failed in pi-mono — disk full")
49req.add_header("Tags", "rotating_light")
50req.add_header("Priority", "4")
51urllib.request.urlopen(req)
52```
53
54### Urgent failure
55
56```python
57import os, urllib.request
58
59req = urllib.request.Request(
60 f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
61 data=b"The primary Postgres instance stopped responding during a migration. Rolled back what we could, but the app is down.",
62)
63req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
64req.add_header("Title", "Production database unreachable")
65req.add_header("Tags", "sos")
66req.add_header("Priority", "5")
67urllib.request.urlopen(req)
68```