TrendWeight Has an API Now

I'm a father and husband, a software developer, a computer geek, a board game collector, and a heart transplant recipient living in Sun Prairie, Wisconsin.
TrendWeight has an API now. If you're comfortable writing a bit of code, you can pull your weight data out (including the calculated trend values you see on your dashboard) and push new weight readings in. Here's a tour of what it can do, with some Python snippets to get you started.
Why an API?
In my last post, I explained why TrendWeight can't support the new Google Health API: with more than 100 Fitbit users, TrendWeight would need an annual third-party security audit, and that's just not something I'm signing up for with a free hobby project.
But that 100-user limit actually works in your favor as an individual. You can get your own Google Health API access for your own data without any of that process. You just need somewhere to send the data once you have it. That's the main reason this API exists. Instead of TrendWeight connecting to Google Health for everyone, you can wire up your own connection, just for you, and push the readings in.
And it doesn't have to be Google Health. Once there's an API, the data can come from anywhere: Apple Health, a spreadsheet, a smart scale TrendWeight doesn't support, or a shell script that runs when you step off the scale.
It works in the other direction too. Everything can be read back out, so it's also handy for backups, analysis, or building your own charts and widgets.
Getting an API key
Head to the Settings page and generate an API key. Keys start with sk- and are only shown once when you create them, so copy yours somewhere safe. And treat it like a password — anyone who has it can read and change your data.
Send the key with every request, either as a bearer token or in an X-Api-Key header:
Authorization: Bearer sk-your-key-here
or
X-Api-Key: sk-your-key-here
What the API can do
There are two groups of endpoints.
Weight data (read-only):
GET /api/v1/measurements— your daily weight data with the trend math already applied: actual weight, trend weight, body fat trends, and interpolation flags. These are the same numbers you see on your dashboard chart.GET /api/v1/measurements/sources— the raw readings exactly as reported by each scale source (Withings, Fitbit, and legacy TrendWeight data). This is basically the API version of the download page, which makes it handy for automated backups.
Weight log (read-write):
GET /api/v1/measurements/manual— list the readings you've entered manually.PUT /api/v1/measurements/manual/{date}— add or replace the entry for a date. It's idempotent, so it's safe to retry.POST /api/v1/measurements/manual— add or replace up to 1,000 entries in one call. This is the one to use if you're importing history from another system.DELETE /api/v1/measurements/manual/{date}— remove an entry.
A few things to know:
All weights are kilograms, everywhere, regardless of your display settings. If you think in pounds like I do, divide by 2.20462 before sending.
Body fat is a 0–1 ratio, not a percentage: 22.5% is
0.225.Dates are
yyyy-MM-ddstrings in your local timezone, and the weight log has one entry per date.The API can only write manual entries. Readings synced from a scale are read-only.
The full interactive reference lives at trendweight.com/api-docs/v1 — you can paste in your API key there and try every endpoint right from the browser.
Example: log today's weight
Here's the simplest useful script: record today's weight.
import requests
from datetime import date
API_KEY = "sk-your-key-here"
BASE = "https://trendweight.com/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
weight_lbs = 185.2
weight_kg = weight_lbs / 2.20462
resp = requests.put(
f"{BASE}/measurements/manual/{date.today().isoformat()}",
headers=HEADERS,
json={"weight": round(weight_kg, 2)},
)
resp.raise_for_status()
print(resp.json())
Because PUT replaces the entry for that date, running it twice just updates the reading — no duplicates to worry about.
Example: what's my trend weight?
import requests
API_KEY = "sk-your-key-here"
BASE = "https://trendweight.com/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
resp = requests.get(f"{BASE}/measurements", headers=HEADERS)
resp.raise_for_status()
measurements = resp.json()
latest = measurements[-1]
trend_lbs = latest["trendWeight"] * 2.20462
print(f"{latest['date']}: trend weight is {trend_lbs:.1f} lbs")
You could pipe that into a widget, a daily notification, or a Home Assistant dashboard. There's also a since query parameter (?since=2026-01-01) if you only want recent data.
Example: bulk import from a CSV
If you're bringing over history from another app, export it to a CSV with date,weight_lbs,body_fat_percent columns and push it in batches:
import csv
import requests
API_KEY = "sk-your-key-here"
BASE = "https://trendweight.com/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
entries = []
with open("weights.csv") as f:
for row in csv.DictReader(f):
entry = {
"date": row["date"], # yyyy-MM-dd
"weight": round(float(row["weight_lbs"]) / 2.20462, 2),
}
if row.get("body_fat_percent"):
entry["fatRatio"] = round(float(row["body_fat_percent"]) / 100, 4)
entries.append(entry)
# The API accepts up to 1,000 entries per call
for i in range(0, len(entries), 1000):
batch = entries[i : i + 1000]
resp = requests.post(f"{BASE}/measurements/manual", headers=HEADERS, json=batch)
resp.raise_for_status()
print(f"Imported {i + len(batch)} of {len(entries)}")
The whole batch is validated before anything is stored, so if one row is bad, you get an error pointing at exactly which entry is wrong, and there's nothing partial to clean up.
Some ideas
A few things this makes possible:
A Google Health bridge. Get your own personal Google Health API access, and run a scheduled script that pulls your weight from Google Health and pushes it into TrendWeight. Your Fitbit scale keeps feeding your trend — just with one extra hop.
Apple Health / Shortcuts. An iOS Shortcut can make an HTTP request, so you can log your weight to TrendWeight straight from your phone, or bridge readings over from HealthKit.
IFTTT / Zapier. No code required for this one. Both services can send a generic web request as an action, and both let you set custom headers, so you can point a webhook action at the API with your key in an
X-Api-Keyheader. If your scale's vendor has an IFTTT or Zapier integration, that's a way to get automatic syncing from a scale TrendWeight doesn't directly support.Home automation. If your smart home already knows your weight (some scales integrate with Home Assistant), a small automation can forward it along.
Backups and analysis. A cron job that pulls
/measurements/sourcesinto a file gives you an automatic backup of your raw data, and the trend data is ready for whatever spreadsheet nerdery you want to throw at it.
If you build something useful (or delightfully unnecessary) with it, I'd love to hear about it — reach out at erv@ewal.net.





