Community
Challenges Feed Leaderboard Forum Members Articles Results Map Levels & points Start here guide About this site Home snakediet.com ↗
Join free Log in

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
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.

Personal API keys

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":"…"}.

Read
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"
Write (key must allow writing)

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.

Quick start
  1. 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.
  2. Use your own data: make a key under Account → API access and send it as a Bearer token.
  3. 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.
Show a profile on your page (JavaScript)
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;
  });
Python
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.

Reference
EndpointAuthWhat it does
GET /api/public-profile.php?user=none*Public stats of one member
GET /api/v1/mekeyName, level, KTN, unit, time zone
GET /api/v1/statskeyFasting totals, streak, weight start/current
GET /api/v1/fastskeyYour fasts, newest first (from, to, limit ≤ 100)
GET /api/v1/weightskeyOne weigh-in per day (from, to), with body_fat_pct when recorded
GET /api/v1/foodkeyFood log for one day (date, default today): items, totals, calorie goal, burn
GET /api/v1/dailykeyPer-day summary, days 1–60: kcal, fasting hours, weight, steps, sleep
GET /api/v1/workoutskeyWorkouts per day (days 1–60): type, minutes, kcal, start time when known
GET /api/v1/widgetkey*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/summarykey*One sentence (?format=text for plain text)
GET /api/v1/weekkey*Last 7 days: fasting hours, kcal, points
GET /api/v1/export.csvkey*All fasts, weigh-ins and food as CSV (&inline=1 for Google Sheets)
GET /api/v1/calendar.icskey*Your fasts as calendar events (400 days)
GET /api/v1/card/NAME.svgnonePublic stats card image (only for members with public stats)
POST /api/v1/postskey + write{"text","source","url"} — a post in the feed as you, with "(via source)". 900 chars, 20 per 10 min
POST /api/v1/stepskey + writeSet steps and/or sleep_min for a date (overwrites, last 60 days)
POST /api/v1/weightskey + writeLog a weigh-in (optional body_fat_pct)
POST /api/v1/fasts/startkey + writeStart a fast now
POST /api/v1/fasts/endkey + writeEnd the running fast

* Some members may require an X-Api-Key header on their public profile.

Status codes
200 / 201OK / created
400Bad input — invalid_value, invalid_date, invalid_unit, date_in_future, date_before_joined
401missing_or_malformed_key, invalid_key (revoked or wrong), invalid_api_key
403write_not_allowed — the key is read-only
404not_public (or not found) — also returned for members who don't exist, so names can't be probed
409A fast is already running / none to end
429rate_limited — wait for Retry-After seconds
Good to know
Keys, ?key= and limits

Send 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.

Fair use

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.