API reference
Every endpoint with its method, body fields and status codes.
All paths live under /api/v1. Every endpoint except POST /api/v1/register, POST /api/v1/login and GET /healthz needs an x-access-tokens header with a JWT. Requests and responses are JSON.
Authentication#
| Method | Path | Body | Responses |
|---|---|---|---|
| POST | /api/v1/register | name, password | 200 {message}; 409 name taken; 422 missing field |
| POST | /api/v1/login | HTTP Basic (Authorization: Basic ...) | 200 {token}; 401 bad credentials |
A failed login sends WWW-Authenticate: Basic realm="login required". The token expires after 30 minutes. Send it as x-access-tokens: <token>; a missing or invalid token gets 403 {message}.
Users and customers#
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/user | 200 {users, meta} | |
| GET | /api/v1/customer | 200 {users, meta} | |
| GET | /api/v1/customer/id/:id | 200 {users, meta}; 404 | |
| POST | /api/v1/customer | name, password | 200 {message}; 409 name taken; 422 missing field |
| PUT | /api/v1/customer/id/:id | name, admin, is_active, password (any subset) | 200 {customer, meta}; 400; 404 |
| DELETE | /api/v1/customer/id/:id | 204 [[term:Soft delete |
GET /api/v1/user returns {public_id, name, admin} per user. Customer entries add id and is_active. Password hashes never appear in a response.
Recipes#
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/recipes | 200 {recipes, meta}; 404 when no published recipe exists | |
| GET | /api/v1/recipes/:page | 200; 404 when the page is empty | |
| GET | /api/v1/recipes/id/:id | 200 {recipes, meta}; 404 | |
| POST | /api/v1/recipes | see below | 201 {Recipe, meta}; 400 unknown classification; 409 name taken; 422 invalid |
| PUT | /api/v1/recipes/id/:id | any subset of the create fields | 200 {Recipe, meta}; 400; 404 |
| DELETE | /api/v1/recipes/id/:id | 204 soft delete; 400 mapped to a menu; 404 |
Create fields: recipe_name (required), classification (required, a classification id), description, num_of_servings (default 2), cook_time (default 30), directions, is_publish (default false), nutrition (object of strings, default {}).
A recipe response carries classification (its id), nutrition (object), has_links (true when a Mapping references it) and ingredients (see below).
Ingredients#
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/ingredient | 200 {Ingredient, meta}; 404 when empty | |
| GET | /api/v1/ingredient/:page | 200; 404 when the page is empty | |
| GET | /api/v1/ingredient/id/:id | 200; 404 | |
| POST | /api/v1/ingredient | ingredient_name, recipe (recipe id), unit, count | 201; 409 duplicate name for the recipe or unknown recipe |
| PUT | /api/v1/ingredient/id/:id | any subset of the create fields | 200; 400; 404 |
| DELETE | /api/v1/ingredient/id/:id | 204 hard delete; 404 |
ingredient_name plus recipe must be unique together.
Classifications#
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/recipes-classification | 200 {recipes-classification, meta}; 404 when empty | |
| GET | /api/v1/recipes-classification/:page | 200; 404 when the page is empty | |
| GET | /api/v1/recipes-classification/id/:id | 200; 404 | |
| POST | /api/v1/recipes-classification | name, is_publish | 201; 409 name taken; 422 invalid |
| PUT | /api/v1/recipes-classification/id/:id | name, is_publish | 200; 400; 404 |
| DELETE | /api/v1/recipes-classification/id/:id | 204 soft delete; 400 recipes reference it; 404 |
name holds at most 35 characters.
Reviews#
Recipe reviews and menu reviews share one shape. The foreign key field is recipe (a recipe id) or menu (the id of a Weekly menu); customer is a customer id.
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/recipe-review | 200 {recipe-review, meta}; 404 when empty | |
| GET | /api/v1/recipe-review/:page | 200; 404 | |
| GET | /api/v1/recipe-review/id/:id | 200; 404 | |
| POST | /api/v1/recipe-review | review, summary, recipe, customer, score (1 to 5, default 5), is_publish | 201; 409 one review per customer and recipe, or unknown ids; 422 invalid |
| PUT | /api/v1/recipe-review/id/:id | review, summary, score, is_publish | 200; 400; 404 |
| DELETE | /api/v1/recipe-review/id/:id | 204 soft delete; 404 |
Replace recipe-review with weekly-menu-review and recipe with menu for menu reviews. A response entry names its recipe or menu and its customer, and carries score, summary, pub_date and is_publish.
Weekly menus#
| Method | Path | Body | Responses |
|---|---|---|---|
| GET | /api/v1/weekly-menu | 200 {weekly-menu, meta}; 404 when empty | |
| GET | /api/v1/weekly-menu/:page | 200; 404 when the page is empty | |
| GET | /api/v1/weekly-menu/id/:id | 200; 404 | |
| POST | /api/v1/weekly-menu | week_number, is_publish (default true) | 201; 409 week number taken; 422 invalid |
| PUT | /api/v1/weekly-menu/id/:id | week_number, is_publish | 200; 400; 404 |
| DELETE | /api/v1/weekly-menu/id/:id | 204 soft delete; 404 |
A menu response carries recipes (its mappings) and score (the mean review score, 0 with no reviews).
| Method | Path | Responses |
|---|---|---|
| POST | /api/v1/weekly-menu/id/:id/recipe/id/:recipeId | 201 maps the recipe; 409 already mapped; 404 unknown id |
| DELETE | /api/v1/weekly-menu/id/:id/recipe/id/:recipeId | 202 unmaps; 404 not mapped or unknown id |
Health#
| Method | Path | Responses |
|---|---|---|
| GET | /healthz | 200 {status: "ok"}, no auth |
Pagination and errors#
List endpoints return 10 rows per page. meta carries page, per_page and page_url. An empty list answers 404 with {status, url, error}, matching the 2021 API. Validation failures answer 400 or 422 with {error} and a details object naming each bad field. Unhandled failures answer 500 with {status, url, error}.