Save 44% with yearly billing, 5 months free.View Plans
textbee Logotextbee.dev
Advent of Code SMS Alerts: A Text When Each Puzzle Unlocks and When Someone Passes You

Advent of Code SMS Alerts: A Text When Each Puzzle Unlocks and When Someone Passes You

Get a text from your own phone when each Advent of Code puzzle unlocks and when someone passes you on your private leaderboard. One Python script, two cron lines.

TT

textbee team

13 min read
Share

Advent of Code 2026 is running, and two moments matter each day: the puzzle unlocks, and someone on your private leaderboard passes you. This guide sends you a text for both. One Python script (standard library only, 79 lines) does the work, and two cron lines run it. Cron runs unlock at 05:00 UTC, the unlock time, to text "Day 6 of Advent of Code is live". It runs watch every 30 minutes to read your private leaderboard JSON and text you only when your rank changes. The texts go out from your own Android phone through textbee.

We ran every snippet below on 3 December 2026 (Python 3.11) against a local copy of the leaderboard JSON and a local mock of the textbee API. We did not call the real leaderboard and did not use a real session cookie.

TL;DR

  • Unlock text: 0 5 1-12 12 * in a crontab on a UTC server. Puzzles unlock at midnight EST (UTC-5), which is 05:00 UTC.
  • Leaderboard text: the script fetches https://adventofcode.com/2026/leaderboard/private/view/<id>.json with your session cookie, compares it with the last snapshot, and texts when your rank changes. The text names who passed you and who gained stars.
  • The 15-minute rule: AoC asks you not to request the leaderboard JSON more often than once every 15 minutes. Cron runs every 30 minutes, and the script refuses to fetch again within 15 minutes, even when you run it by hand.
  • Few texts: no text when nothing changes, and a QUIET_HOURS setting holds rank texts overnight and sends one summary after.
  • Cost: textbee Free covers 300 messages a month (50 a day). 12 unlock texts plus a few rank texts fit easily.

What changed in Advent of Code this year?

Three facts from adventofcode.com shape this script (checked December 2026):

  • Puzzles unlock at midnight EST/UTC-5. The About page says so in its FAQ. On 3 December the calendar countdown pointed at 05:00 UTC on 4 December for Day 4.
  • Fewer days. The About page says puzzles still start on December 1st, come out every day, and end mid-December. The 2025 calendar has 12 days. This guide assumes 12 days for 2026 too. If the 2026 calendar shows more, change 1-12 in the cron line.
  • No global leaderboard. The 2026 leaderboard page says "Advent of Code 2026 doesn't have a global leaderboard." Private leaderboards remain, and the About page asks you not to use their data to build a new global one. This script only reads your own board.

Before you start

  • The textbee app on an Android phone: download it and follow the quickstart.
  • A textbee API key from the dashboard. See API keys.
  • Python 3.9 or later on a machine that is always on: a small server, a VPS or a Raspberry Pi. No packages to install.
  • For the leaderboard part: a private leaderboard you are a member of, its id (the number at the end of the leaderboard's URL), your session cookie and your user id. Step 3 shows where to find them.

What are the AoC rules for scripts?

The automation guidelines on the r/adventofcode wiki has three points that matter here. Reddit blocked our fetch, so we read the Wayback Machine copy from August 2025:

  1. Throttle. The wiki quotes the private leaderboard JSON page: "avoid sending requests more often than once every 15 minutes (900 seconds)."
  2. Identify yourself. Put the contact info of the person who maintains the script in the User-Agent header. Generic values such as python-requests/x.y.z can get blocked.
  3. You are responsible. If your tool misbehaves, your account is the one that gets banned.

The script follows all three. It also never solves anything: the About page asks people not to use AI to solve the puzzles, and this script only reads scores.

Step 1: Save the script

Save this as aoc_sms.py in a folder such as ~/aoc. Change the USER_AGENT line to your own email or repo URL.

Python
#!/usr/bin/env python3
"""Advent of Code texts through textbee: puzzle unlocks and leaderboard rank changes."""
import json, os, sys, time, urllib.request
from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo

TEXTBEE_URL = os.environ.get("TEXTBEE_URL", "https://api.textbee.dev/api/v1")
AOC_URL = os.environ.get("AOC_URL", "https://adventofcode.com")
YEAR = os.environ.get("AOC_YEAR", "2026")
STATE_FILE = os.environ.get("AOC_STATE", os.path.join(os.path.dirname(os.path.abspath(__file__)), "aoc-state.json"))
USER_AGENT = "aoc-sms-alerts by [email protected]"  # Your contact info, as AoC asks.
MIN_GAP = 15 * 60  # AoC: no more than one leaderboard request every 15 minutes.


def send_text(message):
    body = json.dumps({"recipients": os.environ["ALERT_PHONES"].split(","), "message": message})
    req = urllib.request.Request(f"{TEXTBEE_URL}/gateway/send-sms", data=body.encode(), method="POST",
                                 headers={"x-api-key": os.environ["TEXTBEE_API_KEY"],
                                          "Content-Type": "application/json"})
    with urllib.request.urlopen(req, timeout=30) as res:
        print("Sent:", message, "| batch", json.load(res)["data"]["smsBatchId"])


def quiet_now():
    hours = os.environ.get("QUIET_HOURS")  # For example "23-7": no texts from 23:00 to 06:59.
    if not hours:
        return False
    start, end = map(int, hours.split("-"))
    hour = datetime.now(ZoneInfo(os.environ.get("QUIET_TZ", "UTC"))).hour
    return start <= hour < end if start < end else hour >= start or hour < end


def unlock():
    day = datetime.now(timezone(timedelta(hours=-5))).day  # AoC unlocks at midnight UTC-5.
    send_text(f"Day {day} of Advent of Code is live: {AOC_URL}/{YEAR}/day/{day}")


def ranking(board):
    members = sorted(board["members"].values(), key=lambda m: (-m["local_score"], -m["stars"], m.get("last_star_ts", 0)))
    return {str(m["id"]): {"rank": i + 1, "stars": m["stars"],
                           "name": m["name"] or f"anonymous user #{m['id']}"}
            for i, m in enumerate(members)}


def watch():
    state = json.load(open(STATE_FILE)) if os.path.exists(STATE_FILE) else {}
    if time.time() - state.get("fetched_at", 0) < MIN_GAP:
        return print("Last fetch was less than 15 minutes ago. Not fetching.")
    state["fetched_at"] = time.time()  # Saved before the request, so failures count too.
    json.dump(state, open(STATE_FILE, "w"))

    url = f"{AOC_URL}/{YEAR}/leaderboard/private/view/{os.environ['AOC_BOARD_ID']}.json"
    req = urllib.request.Request(url, headers={"Cookie": f"session={os.environ['AOC_SESSION']}",
                                               "User-Agent": USER_AGENT})
    with urllib.request.urlopen(req, timeout=30) as res:
        now = ranking(json.load(res))
    before, me = state.get("ranking"), os.environ["AOC_USER_ID"]

    if before and me in before and now[me]["rank"] != before[me]["rank"]:
        if quiet_now():
            return print("Rank changed during quiet hours. Will text after them.")
        old, new = before[me]["rank"], now[me]["rank"]
        text = f"AoC: you are #{new} now (was #{old})."
        passed = [m["name"] for uid, m in now.items()
                  if uid in before and before[uid]["rank"] > old and m["rank"] < new]
        if passed:
            text += " Passed by " + ", ".join(passed) + "."
        stars = [f"{m['name']} +{m['stars'] - before[uid]['stars']}" for uid, m in now.items()
                 if uid in before and m["stars"] > before[uid]["stars"]]
        if stars:
            text += " Stars: " + ", ".join(stars) + "."
        send_text(text)
    state["ranking"] = now
    json.dump(state, open(STATE_FILE, "w"))
    print(f"You are #{now[me]['rank']} of {len(now)}.")


if __name__ == "__main__":
    {"unlock": unlock, "watch": watch}[sys.argv[1]]()

How it works:

  • unlock sends one text with the day number and the puzzle link. It takes the day from the UTC-5 date, so it names the newest puzzle at any hour.
  • watch checks the time of the last fetch in aoc-state.json first. It saves the new time before it sends the request, so a failed request also counts toward the 15 minutes.
  • ranking sorts members by local score, then stars, then who got their last star first. To rank by stars, swap the first two keys.
  • A text goes out only when your rank changes. Stars that others gain without a rank change update the snapshot quietly. They show up in the next rank-change text only if they happen in the same 30-minute window.
  • Quiet hours do not update the snapshot. The first run after quiet hours compares against the last snapshot from before them and sends one text if your rank differs from that snapshot.
  • AOC_URL and TEXTBEE_URL exist for local tests. Leave them unset in real use. TEXTBEE_URL also lets a self-hosted textbee server use the same script.

Step 2: Put the settings in a file

Create ~/aoc/aoc.env and run chmod 600 aoc.env, so only your user can read it:

Shell
export TEXTBEE_API_KEY=your-textbee-api-key
export ALERT_PHONES=+15555550123
export AOC_SESSION=your-session-cookie
export AOC_BOARD_ID=123456
export AOC_USER_ID=123456
export QUIET_HOURS=23-7
export QUIET_TZ=Europe/Berlin

ALERT_PHONES takes one number or several, separated by commas. Use any number your phone could text: local format works inside the SIM's country, and international format (+1...) reaches other countries. See phone number format.

QUIET_TZ is your own time zone, as an IANA name. Without QUIET_HOURS, rank texts go out at any hour.

AoC links the leaderboard JSON from the private leaderboard page, which is behind a login, so we could not read that page ourselves. The URL and the fields below come from open-source clients: the Haskell advent-of-code-api (its src/Advent/API.hs and src/Advent/Types.hs) and a Go client (checked December 2026). The Haskell client updated its parser on 1 December 2025, because global_score became optional when the global leaderboard went away (changelog).

  • Board id: open your private leaderboard while logged in. The number at the end of the URL is the id.
  • Session cookie: in your browser's developer tools, open the cookies for adventofcode.com and copy the value of session. Treat it like a password: anyone with it is logged in as you. Do not commit it and do not paste it into chat tools.
  • User id: open https://adventofcode.com/2026/leaderboard/private/view/<board id>.json once in the same browser. Find your name under members. The key, which is also the id field, is your user id.

The JSON has this shape (trimmed to one member). The script reads only members, id, name, stars, local_score and last_star_ts:

JSON
{
  "event": "2026",
  "owner_id": 1001,
  "members": {
    "1001": {
      "id": 1001,
      "name": "Ada",
      "stars": 6,
      "local_score": 52,
      "last_star_ts": 1796274000,
      "completion_day_level": {
        "3": {
          "1": { "get_star_ts": 1796273100, "star_index": 51 },
          "2": { "get_star_ts": 1796274000, "star_index": 52 }
        }
      }
    }
  }
}

Members who hide their name have "name": null. The script shows them as "anonymous user #id".

Step 4: Add the cron lines

Cron uses the server's clock. Run date on the server first. These lines assume the clock is on UTC. Open crontab -e and add:

Shell
# Day 1 to 12 of December at 05:00 UTC (midnight EST): unlock text.
0 5 1-12 12 *  cd $HOME/aoc && . ./aoc.env && python3 aoc_sms.py unlock >> aoc.log 2>&1
# Every 30 minutes in December: leaderboard check.
*/30 * * 12 *  cd $HOME/aoc && . ./aoc.env && python3 aoc_sms.py watch >> aoc.log 2>&1

If the server clock is not on UTC, convert 05:00 UTC to the server's time. For example, a server on Central European Time (UTC+1) needs 0 6 1-12 12 *. If midnight EST is the middle of your night, set quiet hours for the leaderboard check and read the unlock text in the morning.

Why every 30 minutes and not every 15? Cron starts each run at the top of a minute, but the script's own start time varies by a fraction of a second. With a 15-minute schedule, two requests can land a moment under 900 seconds apart, or the guard skips every other run. 30 minutes keeps a clear margin. Remove the lines when you stop playing.

How do I test it without an AoC account?

Run it against two local servers. We wrote a 26-line mock (Python http.server) that serves a leaderboard file on port 8901 and answers POST /api/v1/gateway/send-sms on port 8902 with textbee's 200 body. It prints each request.

We made two leaderboard files. In board-1.json, Ada (id 1001, the user we watch) leads with 52 points, Grace has 47, and an anonymous member has 30. In board-2.json, Grace has 55 and the anonymous member has 53, so Ada drops to third.

Point the script at the mocks with two extra lines in a test copy of aoc.env:

Shell
export AOC_URL=http://127.0.0.1:8901
export TEXTBEE_URL=http://127.0.0.1:8902/api/v1

Then run the first snapshot, switch the mock to board-2.json, try again at once, and once more after the gap. We moved fetched_at in the state file back by 16 minutes to stand in for the wait:

$ python3 aoc_sms.py watch   # run 1
You are #1 of 3.
$ python3 aoc_sms.py watch   # run 2, right away
Last fetch was less than 15 minutes ago. Not fetching.
$ python3 aoc_sms.py watch   # run 3, 16 minutes later
Sent: AoC: you are #3 now (was #1). Passed by Grace, anonymous user #1003. Stars: Grace +1, anonymous user #1003 +2. | batch mock-batch-1
You are #3 of 3.
$ python3 aoc_sms.py unlock
Sent: Day 3 of Advent of Code is live: http://127.0.0.1:8901/2026/day/3 | batch mock-batch-1

The mock log shows two leaderboard requests (run 2 made none), each with the cookie and the User-Agent, and the two texts:

[aoc] GET /2026/leaderboard/private/view/1001.json cookie='session=fake-session-cookie' ua='aoc-sms-alerts by [email protected]'
[aoc] GET /2026/leaderboard/private/view/1001.json cookie='session=fake-session-cookie' ua='aoc-sms-alerts by [email protected]'
[textbee] POST /api/v1/gateway/send-sms key='test-key' body={"recipients": ["+15555550123"], "message": "AoC: you are #3 now (was #1). Passed by Grace, anonymous user #1003. Stars: Grace +1, anonymous user #1003 +2."}
[textbee] POST /api/v1/gateway/send-sms key='test-key' body={"recipients": ["+15555550123"], "message": "Day 3 of Advent of Code is live: http://127.0.0.1:8901/2026/day/3"}

We also tested quiet hours. With QUIET_HOURS=23-12 at 08:07 UTC, the run printed "Rank changed during quiet hours. Will text after them." and sent nothing. The next run outside quiet hours sent the same summary text as above.

When the mock works, remove the two test lines and run python3 aoc_sms.py unlock once. That sends one real text to ALERT_PHONES.

Frequently asked questions

Does this break the Advent of Code rules?

No. It reads your own private leaderboard, once per 30 minutes, with your contact info in the User-Agent. That is within the automation guidelines. It does not open puzzles, download inputs or submit answers, and it uses no AI. The unlock text sends no request to AoC at all.

What does it cost?

textbee Free covers 300 messages a month, up to 50 a day. 12 unlock texts plus a handful of rank texts fit easily. Each recipient counts as one message, so 5 friends on the unlock text use 60 messages over the event. Pro is $14.99 a month for up to 5,000 messages. Your phone sends the texts on its SIM plan, so there is no per-message fee from textbee. See pricing.

Can the whole team get the texts?

Yes. Put every number in ALERT_PHONES, separated by commas: +15555550123,+15555550124. The script sends them in the recipients array of one request. The rank text is about one member (AOC_USER_ID), so it makes most sense for the unlock text. For per-person rank texts, each person runs their own copy with their own cookie and state file, so each account stays within the 15-minute limit.

Can I get a text for every new star, not only rank changes?

Yes. In watch, change the condition to send whenever the stars list is not empty. Expect many more texts on a busy board, so keep quiet hours on.

The request fails or returns a page that is not JSON. Either way the script stops with an error, and cron writes it to aoc.log. The 15-minute guard still counts the failed request. Copy a fresh cookie into aoc.env.

Does it work with Node.js instead?

The logic is the same: two fetch calls and a JSON file. See Send SMS from Node.js for the textbee call.

Keep going

Download textbee and get a text the moment the next puzzle unlocks.

Get more textbee in Google Search

Add textbee.dev as a preferred source. Our posts show up more often in your Google results.

Add as a preferred source