Snake Diet API
Two small, free JSON APIs. Everything is HTTPS, UTF-8 and read-only unless you give a key permission to write. Unofficial fan project — not affiliated with Cole Robinson.
- Public profile — show a member's stats on any website (only if the member turned it on)
- Personal API keys — read your own data, or log weight and fasts from your own tools
- Quick start and reference — code examples, status codes, tips
GET https://snakediet.org/api/public-profile.php?user=Emil
Works only for members who ticked Make my stats public (Profile settings). It is off by default. Otherwise you get 404 with {"ok":false,"error":"not_public"}. Email, IP address and private photos are never included. Answers are cached for 5 minutes (Cache-Control: public, max-age=300). Limit: 60 requests per minute per IP, then 429. Some members may require an X-Api-Key header.
curl -s "https://snakediet.org/api/public-profile.php?user=Emil"
{
"ok": true,
"user": { "name": "Emil", "profile_url": "https://snakediet.org/profile/Emil",
"avatar_url": "https://snakediet.org/uploads/avatars/…jpg", "level": 7, "ktn": 12840 },
"fasting": { "active": true, "started_at": "2026-11-15T20:10:00+01:00",
"longest_hours": 72.5, "total_hours": 1180.3, "total_fasts": 64, "streak_days": 12 },
"weight": { "unit": "kg", "start": 128.4, "current": 112.9,
"points": [ { "date": "2026-10-01", "value": 119.6 }, … ] },
"body_fat": { "percent": 18.4, "date": "2026-11-15" },
"activity": [ { "type": "article|fast", "title": "…", "url": "…", "at": "2026-11-14T09:00:00+01:00" } ]
}
Weight: one point per day (the last weigh-in), oldest first, at most 365, in the member's own unit (kg or lbs) — only when the member shares weight numbers. activity has the last 10 public events. body_fat only appears when the member has chosen to show their body fat % (off by default). Sections without data are left out (never null). started_at only exists while a fast is running.
Make a key under Account → API access. It is shown once — copy it then. You can have 3 active keys and revoke them any time. Tick "allow writing" only for keys that need to log data.
Authorization: Bearer sd_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Limits per key: 60 reads and 20 writes per minute. Over the limit you get 429 with a Retry-After header. Errors look like {"ok":false,"error":"…"}.
GET /api/v1/me GET /api/v1/stats GET /api/v1/fasts?from=2026-10-01&to=2026-11-15&limit=100 GET /api/v1/weights?from=2026-10-01&to=2026-11-15
curl -s https://snakediet.org/api/v1/stats \ -H "Authorization: Bearer sd_YOURKEY" curl -s "https://snakediet.org/api/v1/weights?from=2026-10-01" \ -H "Authorization: Bearer sd_YOURKEY"
These use exactly the same rules as the website: one weigh-in bonus per day, no future dates, no dates before you joined, sensible weight limits, and KTN, achievements and levels are updated the same way.
POST /api/v1/weights {"date":"2026-11-16","value":112.4,"unit":"kg","body_fat_pct":18.5}
POST /api/v1/fasts/start
POST /api/v1/fasts/end
curl -s -X POST https://snakediet.org/api/v1/weights \
-H "Authorization: Bearer sd_YOURKEY" -H "Content-Type: application/json" \
-d '{"date":"2026-11-16","value":112.4,"unit":"kg"}'
curl -s -X POST https://snakediet.org/api/v1/fasts/start -H "Authorization: Bearer sd_YOURKEY"
curl -s -X POST https://snakediet.org/api/v1/fasts/end -H "Authorization: Bearer sd_YOURKEY"
date and unit are optional (default: today, your profile unit). Times are ISO-8601 with your time zone offset.
- Show someone's stats on a website: the member ticks Make my stats public, then you call
/api/public-profile.php?user=NAME— no key needed. - Use your own data: make a key under Account → API access and send it as a
Bearertoken. - Cache it. Public answers are fresh for 5 minutes, so call from your server (or cache for a few minutes) instead of on every page view.
fetch('https://snakediet.org/api/public-profile.php?user=Emil')
.then(r => r.json())
.then(d => {
if (!d.ok) return; // not public → nothing to show
const f = d.fasting, w = d.weight;
document.querySelector('#fast').textContent =
f.active ? 'Fasting since ' + new Date(f.started_at).toLocaleString()
: 'Not fasting right now';
if (w) document.querySelector('#weight').textContent =
w.start + ' → ' + w.current + ' ' + w.unit;
});
import requests
H = {"Authorization": "Bearer sd_YOURKEY"}
print(requests.get("https://snakediet.org/api/v1/stats", headers=H).json())
requests.post("https://snakediet.org/api/v1/weights", headers=H,
json={"value": 112.4, "unit": "kg"})
Keep keys and any X-Api-Key on the server side — never put them in a web page or app that other people can open.
| Endpoint | Auth | What it does |
|---|---|---|
GET /api/public-profile.php?user= | none* | Public stats of one member |
GET /api/v1/me | key | Name, level, KTN, unit, time zone |
GET /api/v1/stats | key | Fasting totals, streak, weight start/current |
GET /api/v1/fasts | key | Your fasts, newest first (from, to, limit ≤ 100) |
GET /api/v1/weights | key | One weigh-in per day (from, to), with body_fat_pct when recorded |
GET /api/v1/food | key | Food log for one day (date, default today): items, totals, calorie goal, burn |
GET /api/v1/daily | key | Per-day summary, days 1–60: kcal, fasting hours, weight, steps, sleep |
GET /api/v1/workouts | key | Workouts per day (days 1–60): type, minutes, kcal, start time when known |
GET /api/v1/widget | key* | One flat object for widgets: name, username, level, xp, level_xp, level_need, level_pct, streak, week_points, today_label, fasting_now, fast_hours, longest_fast_hours |
GET /api/v1/summary | key* | One sentence (?format=text for plain text) |
GET /api/v1/week | key* | Last 7 days: fasting hours, kcal, points |
GET /api/v1/export.csv | key* | All fasts, weigh-ins and food as CSV (&inline=1 for Google Sheets) |
GET /api/v1/calendar.ics | key* | Your fasts as calendar events (400 days) |
GET /api/v1/card/NAME.svg | none | Public stats card image (only for members with public stats) |
POST /api/v1/posts | key + write | {"text","source","url"} — a post in the feed as you, with "(via source)". 900 chars, 20 per 10 min |
POST /api/v1/steps | key + write | Set steps and/or sleep_min for a date (overwrites, last 60 days) |
POST /api/v1/weights | key + write | Log a weigh-in (optional body_fat_pct) |
POST /api/v1/fasts/start | key + write | Start a fast now |
POST /api/v1/fasts/end | key + write | End the running fast |
* Some members may require an X-Api-Key header on their public profile.
200 / 201 | OK / created |
400 | Bad input — invalid_value, invalid_date, invalid_unit, date_in_future, date_before_joined |
401 | missing_or_malformed_key, invalid_key (revoked or wrong), invalid_api_key |
403 | write_not_allowed — the key is read-only |
404 | not_public (or not found) — also returned for members who don't exist, so names can't be probed |
409 | A fast is already running / none to end |
429 | rate_limited — wait for Retry-After seconds |
- Times are ISO-8601 with the member's own UTC offset. Dates are
YYYY-MM-DDin the member's time zone. - Weights come back in the member's unit (
kgorlbs); you can send either when writing. - CORS is open (
Access-Control-Allow-Origin: *), but a key in browser code is visible to everyone — use a read-only key at most, or call from a server. - The API is v1. Fields may be added, but existing ones won't change meaning without a new version.
?key= and limitsSend the key as Authorization: Bearer KEY or X-Api-Key: KEY. For read-only GET calls marked key* you may use ?key=KEY instead (for widgets, Google Sheets and calendar apps) — never for writes. 60 reads / 20 writes per minute per key; 30 wrong keys from one IP in 10 minutes gives 429. CORS is open. Errors are {"ok":false,"error":"code"}. See Connect and Widgets.
Free to use for personal and community projects. Cache what you can, don't share your key, and be kind to the server. Keys that misbehave are revoked. Questions? Contact.