{
  "openapi": "3.1.0",
  "info": {
    "title": "Fila de Puentes API",
    "version": "1.0.0",
    "summary": "Live US–Mexico border crossing wait times, history and news.",
    "description": "Read-only, public, no authentication. Wait times come from U.S. Customs and Border Protection (CBP) and refresh every 5 minutes; filadepuentes.com layers its own accuracy calibration, history, best-time analysis, live cameras and Spanish-language border news on top. Covers 26 ports of entry across 11 crossing cities: the six Juárez–El Paso bridges plus Tijuana–San Diego, Mexicali–Calexico, Nogales, Agua Prieta–Douglas, Nuevo Laredo–Laredo, Piedras Negras–Eagle Pass, Acuña–Del Rio, Reynosa–McAllen, Matamoros–Brownsville and Nuevo Progreso–Progreso.\n\nAgents: an MCP server with richer tools (best crossing, best time to cross, ready-to-post answers, border news, the curated knowledge base) is at https://chat.filadepuentes.com/mcp (Streamable HTTP, JSON-RPC 2.0, no auth). Every response includes a source_url; show it to the user.\n\nPlease identify your client with a `client` query parameter (for example ?client=muse) so usage can be attributed. Fair use: 1,000 calls per IP per day.",
    "contact": { "name": "Fila de Puentes", "url": "https://filadepuentes.com/contacto", "email": "hola@filadepuentes.com" },
    "termsOfService": "https://filadepuentes.com/terminos"
  },
  "servers": [{ "url": "https://filadepuentes.com" }],
  "externalDocs": { "description": "Methodology and accuracy numbers", "url": "https://filadepuentes.com/metodologia" },
  "paths": {
    "/api/wait-times": {
      "get": {
        "operationId": "getElPasoWaitTimes",
        "summary": "Live wait times for the six Juárez–El Paso bridges",
        "description": "Returns an object keyed by bridge slug (santa-fe, puente-libre, lerdo, zaragoza, santa-teresa, tornillo). Cached 5 minutes at the edge. The human page for these numbers is https://filadepuentes.com/puentes and each bridge has https://filadepuentes.com/puente/{slug}.",
        "parameters": [{ "$ref": "#/components/parameters/client" }],
        "responses": {
          "200": {
            "description": "Bridge slug → live data",
            "content": { "application/json": { "schema": { "type": "object", "additionalProperties": { "$ref": "#/components/schemas/BridgeWaitTime" } } } }
          }
        }
      }
    },
    "/api/crossings/{citySlug}": {
      "get": {
        "operationId": "getCityCrossingWaitTimes",
        "summary": "Live wait times for every CBP port in a crossing city outside El Paso",
        "description": "Array of ports for the city. Includes a 1-hour trend per port. Human page: https://filadepuentes.com/cruces/{citySlug}. Some ports also have their own page, for example /cruces/tijuana/san-ysidro or /cruces/reynosa/anzalduas.",
        "parameters": [
          { "name": "citySlug", "in": "path", "required": true, "schema": { "type": "string", "enum": ["tijuana", "mexicali", "nogales", "agua-prieta", "laredo", "piedras-negras", "acuna", "reynosa", "matamoros", "progreso"] } },
          { "name": "history", "in": "query", "required": false, "schema": { "type": "string", "enum": ["24h"] }, "description": "Also return 24h of raw standard-lane readings per port." },
          { "$ref": "#/components/parameters/client" }
        ],
        "responses": {
          "200": { "description": "Ports in the city", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PortWaitTime" } } } } },
          "404": { "description": "Unknown city" }
        }
      }
    },
    "/api/bridges/trends": {
      "get": {
        "operationId": "getElPasoTrends",
        "summary": "1-hour trend per Juárez–El Paso bridge",
        "parameters": [{ "$ref": "#/components/parameters/client" }],
        "responses": {
          "200": { "description": "Bridge slug → trend", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": { "$ref": "#/components/schemas/Trend" } } } } }
        }
      }
    },
    "/api/bridges/uuid": {
      "get": {
        "operationId": "getBridgeId",
        "summary": "Resolve a Juárez–El Paso bridge slug to the id used by /api/bridges/history",
        "parameters": [{ "name": "slug", "in": "query", "required": true, "schema": { "type": "string", "enum": ["santa-fe", "puente-libre", "lerdo", "zaragoza", "santa-teresa", "tornillo"] } }],
        "responses": { "200": { "description": "id", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" } } } } } } }
      }
    },
    "/api/bridges/history": {
      "get": {
        "operationId": "getBridgeHistory",
        "summary": "Last 12 hours of readings for one Juárez–El Paso bridge and lane",
        "parameters": [
          { "name": "bridgeId", "in": "query", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "From /api/bridges/uuid." },
          { "name": "laneType", "in": "query", "required": false, "schema": { "type": "string", "enum": ["standard", "sentri", "ready", "pedestrian"], "default": "standard" } },
          { "$ref": "#/components/parameters/client" }
        ],
        "responses": { "200": { "description": "Readings, oldest first", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/HistoryRow" } } } } } }
      }
    }
  },
  "components": {
    "parameters": {
      "client": { "name": "client", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Your agent or app name, for attribution. Example: muse, chatgpt, claude." }
    },
    "schemas": {
      "BridgeWaitTime": {
        "type": "object",
        "description": "Minutes are CBP's published delay. lanesOpen of 0 with a wait of 0 means the lane is not operating, not a zero-minute crossing.",
        "properties": {
          "bridgeSlug": { "type": "string" },
          "portNumber": { "type": "string", "description": "CBP port number" },
          "portName": { "type": "string" },
          "portStatus": { "type": "string" },
          "isClosed": { "type": "boolean" },
          "standardWait": { "type": "integer", "description": "Minutes, standard vehicle lane" },
          "standardLanesOpen": { "type": "integer" },
          "sentriWait": { "type": "integer" },
          "sentriLanesOpen": { "type": "integer" },
          "readyWait": { "type": "integer", "description": "Ready Lane (RFID documents)" },
          "readyLanesOpen": { "type": "integer" },
          "pedestrianWait": { "type": "integer" },
          "pedestrianLanesOpen": { "type": "integer" },
          "hours": { "type": ["string", "null"] },
          "lastUpdated": { "type": ["string", "null"], "format": "date-time" },
          "noDataAvailable": { "type": "boolean" },
          "isManualOverride": { "type": "boolean", "description": "True when staff overrode CBP with a verified on-the-ground number." }
        }
      },
      "PortWaitTime": {
        "type": "object",
        "properties": {
          "portNumber": { "type": "string" },
          "portName": { "type": "string" },
          "crossingName": { "type": "string" },
          "hours": { "type": "string" },
          "updateTime": { "type": "string", "description": "CBP's own stamp, e.g. \"At 2:00 pm PDT\"" },
          "standardWait": { "type": "integer" },
          "standardLanesOpen": { "type": "integer" },
          "noStandardData": { "type": "boolean" },
          "sentriWait": { "type": "integer" },
          "sentriLanesOpen": { "type": "integer" },
          "readyWait": { "type": "integer" },
          "readyLanesOpen": { "type": "integer" },
          "pedestrianWait": { "type": "integer" },
          "pedestrianLanesOpen": { "type": "integer" },
          "isClosed": { "type": "boolean" },
          "status": { "type": "string", "enum": ["green", "yellow", "red", "closed"] },
          "direction": { "type": "string", "enum": ["up", "down", "stable"] },
          "deltaMinutes": { "type": "integer", "description": "Change over the last hour" }
        }
      },
      "Trend": {
        "type": "object",
        "properties": { "direction": { "type": "string", "enum": ["up", "down", "stable"] }, "deltaMinutes": { "type": "integer" } }
      },
      "HistoryRow": {
        "type": "object",
        "properties": {
          "bridge_id": { "type": "string", "format": "uuid" },
          "lane_type": { "type": "string" },
          "wait_minutes": { "type": "integer" },
          "recorded_at": { "type": "string", "format": "date-time" }
        }
      }
    }
  }
}
