{
  "openapi": "3.1.0",
  "info": {
    "title": "DRNK legal drinking age API",
    "version": "1.0.0",
    "summary": "Today's US legal-drinking cutoff birth date, in any timezone.",
    "description": "Returns the latest birth date that is 21 (or a given age) or older today, computed from the current calendar date in the requested IANA timezone. Public, no authentication, CORS enabled. The answer changes at local midnight (see valid_until)."
  },
  "servers": [
    {
      "url": "https://drnkup.xyz"
    }
  ],
  "security": [],
  "paths": {
    "/api/today": {
      "get": {
        "operationId": "getLegalDrinkingCutoff",
        "summary": "Get today's legal drinking age cutoff birth date",
        "parameters": [
          {
            "name": "tz",
            "in": "query",
            "required": false,
            "description": "IANA timezone, e.g. America/Los_Angeles. Defaults to the caller's timezone (from IP geolocation), then America/New_York. The timezone used is echoed back.",
            "schema": {
              "type": "string",
              "examples": [
                "America/Chicago"
              ]
            }
          },
          {
            "name": "age",
            "in": "query",
            "required": false,
            "description": "Minimum age to check against. Default 21 (the US legal drinking age).",
            "schema": {
              "type": "integer",
              "minimum": 18,
              "maximum": 25,
              "default": 21
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Today's cutoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Answer"
                },
                "example": {
                  "country": "US",
                  "legal_drinking_age": 21,
                  "timezone": "America/Chicago",
                  "current_date": "2026-11-10",
                  "born_on_or_before": "2005-11-10",
                  "answer": "Anyone born on or before November 10, 2005 is 21 or older today (America/Chicago).",
                  "valid_until": "2026-11-11T06:00:00.000Z",
                  "source": "https://drnkup.xyz"
                }
              }
            }
          },
          "400": {
            "description": "Invalid timezone or age.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Answer": {
        "type": "object",
        "required": [
          "country",
          "legal_drinking_age",
          "timezone",
          "current_date",
          "born_on_or_before",
          "answer",
          "valid_until",
          "source"
        ],
        "properties": {
          "country": {
            "type": "string",
            "const": "US"
          },
          "legal_drinking_age": {
            "type": "integer",
            "description": "The age checked against."
          },
          "timezone": {
            "type": "string",
            "description": "IANA timezone the date was computed in."
          },
          "current_date": {
            "type": "string",
            "format": "date",
            "description": "Today's date in that timezone."
          },
          "born_on_or_before": {
            "type": "string",
            "format": "date",
            "description": "Anyone born on or before this date is old enough today."
          },
          "answer": {
            "type": "string",
            "description": "The answer as one plain-English sentence."
          },
          "valid_until": {
            "type": "string",
            "format": "date-time",
            "description": "When the answer changes (next local midnight)."
          },
          "source": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  }
}
