rclabs · lab notebookentry Nº 005

Getting my heartbeat out of my phone

Objective
An iOS Shortcut, a zero-dependency Node webhook and a JSON file per day. How I got Apple Health data onto infrastructure I control, and the honest list of what's still rough.
Date
· 3 min read
Apparatus
ioshealthrailwayshipped
Experiment
EXP-008 · Apple Health → Railway
Observer
RC · Berlin

This is the story behind Apple Health → Railway, the smallest experiment in the distillate, and the one with the most lessons per line of code.

My phone knows my resting heart rate, how long I slept, my blood-oxygen level, my step count and my weight. It has known for years. But that data lives in the Health app, and the Health app is not a place you can query, chart the way you want, or connect to anything else.

The question was simple: can I get a copy of my own health data onto a server I control, without writing an iOS app?

The trick: Shortcuts is an integration platform

Most people think of iOS Shortcuts as a way to set a timer by voice. It’s actually a small, visual programming environment with first-class access to HealthKit, and it can make HTTP requests. No App Store review, no Xcode, no developer account.

The Shortcut does four things:

  1. Find Health Samples five times: heart rate, step count, sleep, oxygen saturation and body mass, each sorted by date with a limit of 1, so it gets the latest reading.
  2. Dictionary builds a JSON payload with the keys heartRate, steps, sleep, spo2, weight and date.
  3. Get Contents of URL POSTs it to my server with an Authorization header.
  4. A personal automation runs it every morning at 7 AM with “Run Immediately” turned on. There’s also an optional trigger after a workout.

That’s the whole client. It’s surprisingly powerful for something you build by dragging blocks around.

The server: no framework at all

On the other end is a webhook server built on Node’s plain http module. package.json has zero dependencies, which I like: nothing to update and nothing to audit.

GET  /health   → "I'm alive" (Railway's health check)
POST /vitals   → store today's reading   (needs the API key)
GET  /data     → read today's reading     (needs the API key)

The API key check accepts Bearer <key>, ApiKey <key> or the bare key, because Shortcuts makes it easy to get the header format slightly wrong, and I’d rather be forgiving than debug a phone.

Storage is the simplest thing that could possibly work: one JSON file per day at /data/.health-profile/vitals/YYYY-MM-DD.json. On Railway, /data is a persistent volume, so the files survive redeploys. Each POST reads the day’s file, merges in the new values and writes it back. The server also appends every request to a plain-text log.

For one person posting once a day, this is perfect. A database would be ceremony.

Where the simple version shows its seams

This experiment is small and honest, so here’s the honest part. These are the things I’d fix before anyone else relied on it:

  • A default secret is a trap. If the API_KEY environment variable isn’t set, the server falls back to a built-in default key. That’s convenient in development and dangerous in production, where one missing config value makes the endpoint effectively public. The fix is to refuse to start without a key.
  • Read-merge-write without a lock. Two POSTs arriving at the same moment could overwrite each other. With one phone and one automation it never happens, but it’s a real race.
  • Server time decides the day. The server files everything under its UTC date and ignores the date the phone sends. Around midnight in Berlin, a reading can land in the wrong file.
  • Validation is just parseFloat. Nothing checks that SpO₂ is between 0 and 100, or that a heart rate isn’t 4,000.
  • The dashboard isn’t wired up yet. The vitals dashboard (four Chart.js line charts and trend cards) is a static page where you paste JSON, and it keeps the data in your browser’s localStorage. It never calls the webhook. That was deliberate for privacy, but it means the loop isn’t closed.
  • Shortcuts automations aren’t guaranteed. iOS decides when background automations actually run, and some can still ask for confirmation. A missed morning just means a missing day.

What I learned

Health data deserves the same care as credentials. Every one of the gaps above is small, and every one would matter if this weren’t just my own data. Building it made me much more sympathetic to why health platforms are so locked down, and much more convinced that people should be able to get a copy of their own numbers anyway.

The boring stack was the right stack. A Shortcut, a file per day and no framework. The next step isn’t more technology. It’s closing the loop so the dashboard reads from the server, adding a lock, and trusting the phone’s date.

The docs and server are at github.com/chandrasekar-r/apple-health-railway-docs.

Recorded byRCBerlin · 25 Sept 2026
Witnessed byyou, just nowquestions or corrections: rcsekar.v3@gmail.com