{
 "openapi": "3.1.0",
 "info": {
  "title": "Enthusiast Index API",
  "version": "1.0.0",
  "description": "Read-only access to the Enthusiast Index: 605 cars scored 0-10 on ownership reality, with driver involvement, engine sound and DougScores. No authentication. Data CC BY 4.0 - attribute Enthusiast Index with a link.",
  "license": {
   "name": "CC BY 4.0",
   "url": "https://creativecommons.org/licenses/by/4.0/"
  }
 },
 "servers": [
  {
   "url": "https://enthusiast-index.com"
  }
 ],
 "paths": {
  "/api/cars": {
   "get": {
    "operationId": "searchCars",
    "summary": "Search, filter and rank cars",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Words to match in the car name or brand, e.g. '911 gt3'"
     },
     {
      "name": "brand",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Exact brand, e.g. Porsche"
     },
     {
      "name": "category",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "One of: Sports cars & GTs, JDM icons, Hot hatches, Super saloons & wagons, Analog classics, Lightweights, Performance SUVs, Performance EVs, The trophy shelf"
     },
     {
      "name": "min_index",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      },
      "description": "Minimum Index score (0-10)"
     },
     {
      "name": "max_index",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      },
      "description": "Maximum Index score (0-10)"
     },
     {
      "name": "min_sound",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      },
      "description": "Minimum sound score (0-10)"
     },
     {
      "name": "sort",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "index (default), sound, involvement, handling, dougscore, redline, name"
     },
     {
      "name": "order",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "desc (default) or asc"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer"
      },
      "description": "1-50, default 20"
     }
    ],
    "responses": {
     "200": {
      "description": "Matching cars",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "count": {
           "type": "integer"
          },
          "returned": {
           "type": "integer"
          },
          "cars": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/CarSummary"
           }
          },
          "attribution": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/car": {
   "get": {
    "operationId": "getCar",
    "summary": "Full record for one car",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Car id, slug, or exact name. Ambiguous names return candidates instead of guessing."
     }
    ],
    "responses": {
     "200": {
      "description": "The car, with all ratings and their written reasoning"
     },
     "300": {
      "description": "Several cars match; candidates listed"
     },
     "404": {
      "description": "No such car"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "CarSummary": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "brand": {
      "type": "string"
     },
     "category": {
      "type": "string"
     },
     "years": {
      "type": "string"
     },
     "index_score": {
      "type": [
       "number",
       "null"
      ],
      "description": "0-10 ownership reality: miles driven and how rarely the car is flipped. Not a quality score."
     },
     "involvement": {
      "type": "number"
     },
     "sound_score": {
      "type": [
       "number",
       "null"
      ]
     },
     "handling": {
      "type": [
       "number",
       "null"
      ]
     },
     "power_hp": {
      "type": [
       "integer",
       "null"
      ]
     },
     "weight_kg": {
      "type": [
       "integer",
       "null"
      ]
     },
     "dougscore": {
      "type": [
       "integer",
       "null"
      ]
     },
     "verdict": {
      "type": "string"
     },
     "url": {
      "type": "string"
     },
     "cite_as": {
      "type": "string"
     }
    }
   }
  }
 }
}