Cookest
Backend APIEndpoints

Auth & Ingredients

Authentication endpoints and ingredient search

Auth & Ingredients

POST /api/auth/register

Create a new user account.

MethodPathAuthTier
POST/api/auth/registerNoneFree

Request body

{
  "email": "user@example.com",
  "password": "securepassword",
  "name": "Alice"
}

Response 201 Created

{
  "id": "uuid",
  "email": "user@example.com",
  "name": "Alice"
}

POST /api/auth/login

Authenticate and receive tokens.

MethodPathAuthTier
POST/api/auth/loginNoneFree

Request body

{
  "email": "user@example.com",
  "password": "securepassword"
}

Response 200 OK

{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 900
}

The refresh_token is set as an httpOnly cookie (Set-Cookie: refresh_token=...).


POST /api/auth/refresh

Obtain a new access token using the refresh cookie.

MethodPathAuthTier
POST/api/auth/refreshCookieFree

Sends no body. The browser/Dio cookie jar forwards the refresh cookie automatically.

Response 200 OK

{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 900
}
StatusMeaning
401Refresh token missing, expired, or revoked

POST /api/auth/logout

Revoke the refresh token.

MethodPathAuthTier
POST/api/auth/logoutJWT BearerFree

No body required. Deletes the refresh token from the database. The httpOnly cookie is also cleared.

Response 200 OK

{ "message": "Logged out successfully" }

POST /api/auth/onboarding

Complete the user profile after registration.

MethodPathAuthTier
POST/api/auth/onboardingJWT BearerFree

Request body

{
  "household_size": 2,
  "dietary_restrictions": ["vegetarian"],
  "allergies": ["nuts"],
  "health_goals": ["weight_loss"],
  "cooking_skill": "intermediate"
}

cooking_skill values: beginner | intermediate | advanced

Response 200 OK

Returns the updated user object.


POST /api/me/change-password

Change the authenticated user's password.

MethodPathAuthTier
POST/api/me/change-passwordJWT BearerFree

Request body

{
  "current_password": "oldpassword",
  "new_password": "newpassword"
}

Response 200 OK

{ "message": "Password changed successfully" }
StatusMeaning
400Current password incorrect

DELETE /api/me

Permanently delete the authenticated user's account and all associated data.

MethodPathAuthTier
DELETE/api/meJWT BearerFree

This action is irreversible. All user data including recipes, meal plans, inventory, and chat history is permanently deleted.

Response 204 No Content


GET /api/ingredients

Search the ingredient catalog.

MethodPathAuthTier
GET/api/ingredientsNoneFree

Query parameters

ParameterTypeDescription
qstringSearch query (uses pg_trgm fuzzy matching)
limitintegerMax results (default: 20)
offsetintegerPagination offset

Response 200 OK

[
  {
    "id": 1,
    "name": "Chicken Breast",
    "category": "meat",
    "calories_per_100g": 165,
    "protein_per_100g": 31.0,
    "carbs_per_100g": 0.0,
    "fat_per_100g": 3.6
  }
]

GET /api/ingredients/:id

Get full ingredient details including micronutrients and portion sizes.

MethodPathAuthTier
GET/api/ingredients/:idNoneFree

Response 200 OK

{
  "id": 1,
  "name": "Chicken Breast",
  "category": "meat",
  "calories_per_100g": 165,
  "protein_per_100g": 31.0,
  "carbs_per_100g": 0.0,
  "fat_per_100g": 3.6,
  "nutrients": {
    "fiber": 0,
    "sugar": 0,
    "sodium": 74,
    "vitamin_c": 0,
    "calcium": 11,
    "iron": 0.9
  },
  "portion_sizes": [
    { "name": "1 breast", "grams": 174 },
    { "name": "100g", "grams": 100 }
  ]
}
StatusMeaning
404Ingredient not found

On this page