{
  "openapi": "3.0.3",
  "info": {
    "title": "AUTO.MOTO.pt Catalog API",
    "description": "Read-only, unauthenticated search and retrieval of published vehicle listings (cars, motorcycles, commercial vehicles) on auto.moto.pt. This is a small REST surface for AI agents and other automated clients — the site's full API is GraphQL at /graphql (see /graphql-docs.md), but that endpoint has introspection disabled, so this document exists to give agents a machine-readable description of the public read operations.",
    "version": "1.0.0",
    "contact": { "url": "https://auto.moto.pt" }
  },
  "servers": [ { "url": "https://auto.moto.pt" } ],
  "paths": {
    "/api/catalog": {
      "get": {
        "operationId": "getCatalogIndex",
        "summary": "Catalog API index",
        "description": "Links to every operation below, plus the GraphQL endpoint and other discovery documents.",
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CatalogIndex" } } } }
        }
      }
    },
    "/api/catalog/categories": {
      "get": {
        "operationId": "getCategories",
        "summary": "List vehicle categories, live counts, and districts",
        "description": "The three public vehicle categories (cars, motorcycles, commercial vehicles), each with a live published-listing count, plus the list of districts (areas) that /api/catalog/products?area= accepts.",
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CategoriesResponse" } } } }
        }
      }
    },
    "/api/catalog/products": {
      "get": {
        "operationId": "searchProducts",
        "summary": "Search / list published vehicle listings",
        "parameters": [
          { "name": "cat", "in": "query", "schema": { "type": "string", "enum": ["AUTO", "MOTO", "COM"] }, "description": "Category: AUTO = cars, MOTO = motorcycles, COM = commercial vehicles." },
          { "name": "brand", "in": "query", "schema": { "type": "string" }, "description": "Brand slug, e.g. \"bmw\" (same slug used in the site's own URLs)." },
          { "name": "area", "in": "query", "schema": { "type": "string" }, "description": "District slug, e.g. \"lisboa\"." },
          { "name": "search", "in": "query", "schema": { "type": "string" }, "description": "Free-text search (title/description), or a numeric listing id." },
          { "name": "priceMin", "in": "query", "schema": { "type": "number" } },
          { "name": "priceMax", "in": "query", "schema": { "type": "number" } },
          { "name": "page", "in": "query", "schema": { "type": "integer", "minimum": 1, "default": 1 } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 50, "default": 20 }, "description": "Hard-capped at 50." }
        ],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductList" } } } },
          "429": { "description": "Rate limited" }
        }
      }
    },
    "/api/catalog/products/{id}": {
      "get": {
        "operationId": "getProduct",
        "summary": "Get a single published vehicle listing (spec, price, availability)",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "The listing id." }
        ],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Product" } } } },
          "404": { "description": "Not found (unknown id, or the listing is not currently published)" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CatalogIndex": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "version": { "type": "string" },
          "base_url": { "type": "string" },
          "documentation": { "type": "string" },
          "authentication": { "type": "string" },
          "endpoints": { "type": "array", "items": { "type": "object" } },
          "related": { "type": "object" }
        }
      },
      "CategoriesResponse": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string", "enum": ["AUTO", "MOTO", "COM"] },
                "catUrl": { "type": "string" },
                "count": { "type": "integer" },
                "url": { "type": "string" }
              }
            }
          },
          "areas": {
            "type": "array",
            "items": { "type": "object", "properties": { "id": {}, "name": { "type": "string" } } }
          }
        }
      },
      "ProductList": {
        "type": "object",
        "properties": {
          "total": { "type": "integer" },
          "page": { "type": "integer" },
          "limit": { "type": "integer" },
          "items": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": { "description": "Stable listing id — does not depend on language, URL slug, or price." },
          "category": { "type": "string", "enum": ["AUTO", "MOTO", "COM"] },
          "title": { "type": "string" },
          "price": {
            "type": "object",
            "properties": { "amount": { "type": "number" }, "currency": { "type": "string", "example": "EUR" } }
          },
          "year": { "type": "integer", "nullable": true },
          "run": { "type": "integer", "description": "Odometer, km" },
          "runType": { "type": "string", "nullable": true },
          "fuel": { "type": "string", "nullable": true },
          "transmission": { "type": "string", "nullable": true },
          "hp": { "type": "integer", "nullable": true },
          "brand": { "type": "string", "nullable": true },
          "model": { "type": "string", "nullable": true },
          "type": { "type": "string", "nullable": true },
          "area": { "type": "string", "nullable": true },
          "availability": { "type": "string", "enum": ["in_stock", "unavailable"] },
          "published": { "type": "boolean" },
          "image": { "type": "string", "nullable": true },
          "url": { "type": "string", "description": "Canonical HTML page for this listing." },
          "seller": {
            "type": "object",
            "nullable": true,
            "properties": { "name": { "type": "string", "nullable": true }, "phone": { "type": "string", "nullable": true } }
          }
        }
      }
    }
  }
}
