{"openapi":"3.0.3","info":{"title":"Calcho Public API","description":"カロリー・体重・運動の記録を取得する公開 API。公開設定のユーザーのみアクセス可能。","version":"1.0.0"},"servers":[{"url":"/api/public","description":"Public endpoint"}],"paths":{"/{accessKey}":{"get":{"summary":"ユーザー情報","description":"公開設定ユーザーの基本情報を返します。","operationId":"getUser","parameters":[{"$ref":"#/components/parameters/accessKey"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/{accessKey}/summary":{"get":{"summary":"日次サマリー","description":"指定日のカロリー摂取・消費・PFCSの合計を返します。","operationId":"getDailySummary","parameters":[{"$ref":"#/components/parameters/accessKey"},{"$ref":"#/components/parameters/date"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DailySummary"}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/{accessKey}/records":{"get":{"summary":"日次レコード一覧","description":"指定日に記録された食事・運動の一覧を返します。","operationId":"getDailyRecords","parameters":[{"$ref":"#/components/parameters/accessKey"},{"$ref":"#/components/parameters/date"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Record"}}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/{accessKey}/stats/month":{"get":{"summary":"月次統計","description":"指定月の日別カロリー・体重データと月合計を返します。","operationId":"getMonthStats","parameters":[{"$ref":"#/components/parameters/accessKey"},{"name":"year","in":"query","description":"年 (例: 2026)","schema":{"type":"integer","example":2026}},{"name":"month","in":"query","description":"月 (1〜12)","schema":{"type":"integer","minimum":1,"maximum":12,"example":4}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MonthStats"}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/{accessKey}/stats/year":{"get":{"summary":"年次統計","description":"指定年の月別カロリー・体重データと年合計を返します。","operationId":"getYearStats","parameters":[{"$ref":"#/components/parameters/accessKey"},{"name":"year","in":"query","description":"年 (例: 2026)","schema":{"type":"integer","example":2026}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/YearStats"}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/{accessKey}/stats/body":{"get":{"summary":"身体データ","description":"指定期間の体重・体脂肪・腹囲の記録を返します。","operationId":"getBodyStats","parameters":[{"$ref":"#/components/parameters/accessKey"},{"name":"start","in":"query","description":"開始日 (YYYY-MM-DD)","schema":{"type":"string","format":"date","example":"2026-04-01"}},{"name":"end","in":"query","description":"終了日 (YYYY-MM-DD)","schema":{"type":"string","format":"date","example":"2026-04-30"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BodyStats"}}}},"403":{"$ref":"#/components/responses/Forbidden"}}}}},"components":{"parameters":{"accessKey":{"name":"accessKey","in":"path","required":true,"description":"ユーザーのアクセスキー (設定画面の共有URLに含まれる32文字の文字列)","schema":{"type":"string","example":"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"}},"date":{"name":"date","in":"query","description":"対象日 (YYYY-MM-DD)。省略時は今日","schema":{"type":"string","format":"date","example":"2026-04-28"}}},"responses":{"Forbidden":{"description":"このユーザーの記録は非公開です","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}},"schemas":{"User":{"type":"object","properties":{"id":{"type":"integer","description":"ユーザーID"},"name":{"type":"string","description":"ユーザー名"}}},"DailySummary":{"type":"object","properties":{"today":{"type":"object","properties":{"intake":{"type":"integer","description":"摂取カロリー (kcal)"},"exercise":{"type":"integer","description":"消費カロリー (kcal)"},"saving":{"type":"integer","description":"月累計節約カロリー (kcal)"},"target":{"type":"integer","description":"目標カロリー (kcal)"},"p":{"type":"number","description":"たんぱく質 (g)"},"f":{"type":"number","description":"脂質 (g)"},"c":{"type":"number","description":"炭水化物 (g)"},"s":{"type":"number","description":"食塩相当量 (g)"}}}}},"Record":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string","description":"品名"},"brand":{"type":"string","nullable":true,"description":"ブランド名"},"calorie":{"type":"integer","description":"カロリー (kcal)。運動は負値"},"protein":{"type":"number","nullable":true,"description":"たんぱく質 (g)"},"fat":{"type":"number","nullable":true,"description":"脂質 (g)"},"carb":{"type":"number","nullable":true,"description":"炭水化物 (g)"},"salt":{"type":"number","nullable":true,"description":"食塩相当量 (g)"},"type":{"type":"integer","description":"0=直接入力 1=マスターアイテム 2=運動 3=標準成分表"},"mealType":{"type":"integer","description":"0=未設定 1=朝 2=昼 3=夜 4=間食"},"refValue":{"type":"number","nullable":true,"description":"数量(%) または 時間(分)"},"unit":{"type":"string","nullable":true},"memo":{"type":"string","nullable":true},"date":{"type":"string","format":"date"}}},"DayStat":{"type":"object","properties":{"date":{"type":"string","format":"date"},"title":{"type":"string","example":"28日(月)"},"weight":{"type":"number","nullable":true},"fat":{"type":"number","nullable":true},"waist":{"type":"number","nullable":true},"intake":{"type":"integer","description":"摂取カロリー (kcal)"},"exercise":{"type":"integer","description":"消費カロリー (kcal)"},"calorie":{"type":"integer","description":"正味カロリー (摂取−消費)"},"left_calorie":{"type":"integer","description":"目標残りカロリー"}}},"MonthStats":{"type":"object","properties":{"title":{"type":"string","example":"2026年4月"},"target_calorie":{"type":"integer"},"left_calorie":{"type":"integer"},"ave_calorie":{"type":"integer","description":"日平均カロリー"},"ave_exercise":{"type":"integer"},"calorie":{"type":"integer"},"ave_protein":{"type":"number"},"ave_fat":{"type":"number"},"ave_carb":{"type":"number"},"ave_salt":{"type":"number"},"records":{"type":"array","items":{"$ref":"#/components/schemas/DayStat"}}}},"MonthRow":{"type":"object","properties":{"month":{"type":"integer"},"title":{"type":"string","example":"4月"},"calorie":{"type":"integer","nullable":true},"ave_calorie":{"type":"integer"},"left_calorie":{"type":"integer"},"intake":{"type":"integer"},"exercise":{"type":"integer"},"activeDaysCount":{"type":"integer"},"profile":{"type":"object","properties":{"weight":{"type":"number","nullable":true},"fat":{"type":"number","nullable":true},"waist":{"type":"number","nullable":true}}}}},"YearStats":{"type":"object","properties":{"title":{"type":"string","example":"2026年"},"calorie":{"type":"integer"},"ave_calorie":{"type":"integer"},"left_calorie":{"type":"integer"},"ave_protein":{"type":"number"},"ave_fat":{"type":"number"},"ave_carb":{"type":"number"},"ave_salt":{"type":"number"},"records":{"type":"array","items":{"$ref":"#/components/schemas/MonthRow"}}}},"BodyRecord":{"type":"object","properties":{"date":{"type":"string","format":"date"},"weight":{"type":"number","nullable":true,"description":"体重 (kg)"},"fat":{"type":"number","nullable":true,"description":"体脂肪率 (%)"},"waist":{"type":"number","nullable":true,"description":"腹囲 (cm)"}}},"BodyStats":{"type":"object","properties":{"records":{"type":"array","items":{"$ref":"#/components/schemas/BodyRecord"}}}}}}}