{
  "openapi": "3.1.0",
  "info": {
    "title": "Gaucho REST API",
    "version": "1.0.0",
    "description": "Public, read-only UCSB dining menus and nutrition from Gaucho’s published D1 snapshot. No API key. GET, HEAD and OPTIONS are supported, with cross-origin access. Refreshes every six hours; successful responses cache for 60 seconds. Saved plans remain in the browser and are not exposed through this API."
  },
  "servers": [
    {
      "url": "https://gaucho.mihir-s.com/api/v1"
    }
  ],
  "security": [],
  "externalDocs": {
    "url": "https://gaucho.mihir-s.com/docs",
    "description": "Examples and API reference"
  },
  "paths": {
    "/halls": {
      "get": {
        "summary": "List dining locations and their sections",
        "operationId": "listHalls",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Halls"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/menus": {
      "get": {
        "summary": "List published dates and meals for a location/section",
        "operationId": "listMenus",
        "parameters": [
          {
            "name": "hall",
            "in": "query",
            "required": true,
            "description": "Dining location name, unique substring, or ID.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Portola"
          },
          {
            "name": "section",
            "in": "query",
            "required": false,
            "description": "Section name, unique substring, or ID. Defaults to the daily menu, or the first section for eateries.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Salad Bar"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Menu date in YYYY-MM-DD format. Defaults to today in California for daily menus. Everyday sections ignore the date when selecting a meal.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "2026-10-09"
          }
        ],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Menus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/menu": {
      "get": {
        "summary": "Get a menu with serving sizes and macros for every food",
        "operationId": "getMenu",
        "parameters": [
          {
            "name": "hall",
            "in": "query",
            "required": true,
            "description": "Dining location name, unique substring, or ID.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Portola"
          },
          {
            "name": "section",
            "in": "query",
            "required": false,
            "description": "Section name, unique substring, or ID. Defaults to the daily menu, or the first section for eateries.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Salad Bar"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Menu date in YYYY-MM-DD format. Defaults to today in California for daily menus. Everyday sections ignore the date when selecting a meal.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "2026-10-09"
          },
          {
            "name": "meal",
            "in": "query",
            "required": false,
            "description": "Meal name, case insensitive. Defaults to Lunch. Use menus to discover Brunch and other choices.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Lunch"
          },
          {
            "name": "menu",
            "in": "query",
            "required": false,
            "description": "Numeric menu ID from menus. Overrides date and meal selection.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "258592"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive substring filter on food names.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "chicken"
          }
        ],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Menu"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/item": {
      "get": {
        "summary": "Get one food’s serving size and macros",
        "operationId": "getItem",
        "parameters": [
          {
            "name": "hall",
            "in": "query",
            "required": true,
            "description": "Dining location name, unique substring, or ID.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Portola"
          },
          {
            "name": "section",
            "in": "query",
            "required": false,
            "description": "Section name, unique substring, or ID. Defaults to the daily menu, or the first section for eateries.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Salad Bar"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Menu date in YYYY-MM-DD format. Defaults to today in California for daily menus. Everyday sections ignore the date when selecting a meal.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "2026-10-09"
          },
          {
            "name": "meal",
            "in": "query",
            "required": false,
            "description": "Meal name, case insensitive. Defaults to Lunch. Use menus to discover Brunch and other choices.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Lunch"
          },
          {
            "name": "menu",
            "in": "query",
            "required": false,
            "description": "Numeric menu ID from menus. Overrides date and meal selection.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "258592"
          },
          {
            "name": "item",
            "in": "query",
            "required": true,
            "description": "Food name, unique substring, or ID from a menu.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Char Grilled Rock Fish w/Lemon Thyme"
          }
        ],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItemResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/label": {
      "get": {
        "summary": "Get a food and its full NetNutrition label HTML",
        "operationId": "getLabel",
        "parameters": [
          {
            "name": "hall",
            "in": "query",
            "required": true,
            "description": "Dining location name, unique substring, or ID.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Portola"
          },
          {
            "name": "section",
            "in": "query",
            "required": false,
            "description": "Section name, unique substring, or ID. Defaults to the daily menu, or the first section for eateries.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Salad Bar"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Menu date in YYYY-MM-DD format. Defaults to today in California for daily menus. Everyday sections ignore the date when selecting a meal.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "2026-10-09"
          },
          {
            "name": "meal",
            "in": "query",
            "required": false,
            "description": "Meal name, case insensitive. Defaults to Lunch. Use menus to discover Brunch and other choices.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Lunch"
          },
          {
            "name": "menu",
            "in": "query",
            "required": false,
            "description": "Numeric menu ID from menus. Overrides date and meal selection.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "258592"
          },
          {
            "name": "item",
            "in": "query",
            "required": true,
            "description": "Food name, unique substring, or ID from a menu.",
            "schema": {
              "type": "string",
              "maxLength": 300
            },
            "example": "Char Grilled Rock Fish w/Lemon Thyme"
          }
        ],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Get snapshot age and freshness",
        "operationId": "getHealth",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Published data. Nutrition values are per serving.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or missing query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Location, section, menu, or food is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous name, or snapshot changed during the request. Use an exact name/ID or retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Data is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Snapshot": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "collected_at": {
            "type": "string",
            "format": "date-time"
          },
          "published_at": {
            "type": "string",
            "format": "date-time"
          },
          "age_seconds": {
            "type": "integer",
            "minimum": 0
          },
          "stale": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "collected_at",
          "published_at",
          "age_seconds",
          "stale"
        ]
      },
      "MenuChoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 0
          },
          "meal": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "description": "YYYY-MM-DD or everyday"
          },
          "date_label": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "meal",
          "date",
          "date_label"
        ]
      },
      "Item": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 0
          },
          "name": {
            "type": "string"
          },
          "serving": {
            "type": "string"
          },
          "calories": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "protein_g": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "carbs_g": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "fat_g": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "fiber_g": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "sugar_g": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "sodium_mg": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Per listed serving. Null means unknown, including values reported as less than a number."
          },
          "category": {
            "type": "string"
          },
          "label_fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "macro_display": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Original values for display, such as <1."
          }
        },
        "required": [
          "id",
          "name",
          "serving",
          "calories",
          "protein_g",
          "carbs_g",
          "fat_g"
        ]
      },
      "Halls": {
        "type": "object",
        "properties": {
          "halls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "minimum": 0
                },
                "name": {
                  "type": "string"
                },
                "sections": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "name"
                    ]
                  }
                }
              },
              "required": [
                "id",
                "name",
                "sections"
              ]
            }
          },
          "snapshot": {
            "$ref": "#/components/schemas/Snapshot"
          }
        },
        "required": [
          "halls",
          "snapshot"
        ]
      },
      "Menus": {
        "type": "object",
        "properties": {
          "hall": {
            "type": "string"
          },
          "hall_id": {
            "type": "integer",
            "minimum": 0
          },
          "section": {
            "type": "string"
          },
          "section_id": {
            "type": "integer",
            "minimum": 0
          },
          "menus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MenuChoice"
            }
          },
          "snapshot": {
            "$ref": "#/components/schemas/Snapshot"
          }
        },
        "required": [
          "hall",
          "hall_id",
          "section",
          "section_id",
          "menus",
          "snapshot"
        ]
      },
      "Menu": {
        "type": "object",
        "properties": {
          "hall": {
            "type": "string"
          },
          "hall_id": {
            "type": "integer",
            "minimum": 0
          },
          "section": {
            "type": "string"
          },
          "section_id": {
            "type": "integer",
            "minimum": 0
          },
          "date": {
            "type": "string",
            "description": "YYYY-MM-DD or everyday"
          },
          "meal": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "snapshot": {
            "$ref": "#/components/schemas/Snapshot"
          },
          "id": {
            "type": "integer",
            "minimum": 0
          },
          "date_label": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            }
          }
        },
        "required": [
          "hall",
          "hall_id",
          "section",
          "section_id",
          "date",
          "meal",
          "source",
          "fetched_at",
          "snapshot",
          "id",
          "date_label",
          "items"
        ]
      },
      "ItemResponse": {
        "type": "object",
        "properties": {
          "hall": {
            "type": "string"
          },
          "hall_id": {
            "type": "integer",
            "minimum": 0
          },
          "section": {
            "type": "string"
          },
          "section_id": {
            "type": "integer",
            "minimum": 0
          },
          "date": {
            "type": "string",
            "description": "YYYY-MM-DD or everyday"
          },
          "meal": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "snapshot": {
            "$ref": "#/components/schemas/Snapshot"
          },
          "menu_id": {
            "type": "integer",
            "minimum": 0
          },
          "item": {
            "$ref": "#/components/schemas/Item"
          }
        },
        "required": [
          "hall",
          "hall_id",
          "section",
          "section_id",
          "date",
          "meal",
          "source",
          "fetched_at",
          "snapshot",
          "menu_id",
          "item"
        ]
      },
      "Label": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ItemResponse"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "document": {
                "type": "string",
                "description": "Full label HTML, with original styles and ingredients. Render in a sandboxed iframe."
              }
            },
            "required": [
              "name",
              "document"
            ]
          }
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "False when the snapshot is older than 12 hours."
          },
          "snapshot": {
            "$ref": "#/components/schemas/Snapshot"
          },
          "plan_storage": {
            "const": "browser"
          }
        },
        "required": [
          "ok",
          "snapshot",
          "plan_storage"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer",
                  "minimum": 0
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}
