{
  "openapi": "3.1.0",
  "info": {
    "title": "AutoWholesaleNJ Inventory API",
    "version": "1.0.0",
    "summary": "Read-only access to vehicles currently listed by AutoWholesaleNJ, a used-car dealership in Delran, NJ.",
    "description": "Public and read-only; no API key. A listed vehicle is 'currently listed', not reserved. Prices exclude sales tax, title, registration and dealer/documentation fees. Customers submit credit applications, trade-in, test-drive and contact forms themselves on the website; this API cannot submit them.",
    "contact": {
      "name": "AutoWholesaleNJ",
      "email": "njsales@njautowholesale.com",
      "url": "https://autowholesalenj.com/contact-us"
    }
  },
  "servers": [
    {
      "url": "https://autowholesalenj.com"
    }
  ],
  "externalDocs": {
    "url": "https://autowholesalenj.com/llms.txt"
  },
  "paths": {
    "/api/inventory": {
      "get": {
        "operationId": "searchInventory",
        "summary": "Search currently listed vehicles",
        "description": "Text filters match the start of the value, case-insensitively. Accepts the same parameters as the website's /inventory page URL.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Free text matched against year, make, model, trim, body type, color and VIN"
          },
          {
            "name": "make",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "e.g. Honda"
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "e.g. Accord"
          },
          {
            "name": "body",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Body type, e.g. SUV"
          },
          {
            "name": "transmission",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "e.g. Automatic"
          },
          {
            "name": "fuel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Fuel type"
          },
          {
            "name": "drivetrain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "e.g. AWD"
          },
          {
            "name": "yearMin",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Oldest model year"
          },
          {
            "name": "yearMax",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Newest model year"
          },
          {
            "name": "minPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "Minimum advertised price, whole US dollars"
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "Maximum advertised price, whole US dollars"
          },
          {
            "name": "mileageMax",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Maximum mileage"
          },
          {
            "name": "featured",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Only featured (Premium Collection) vehicles"
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "price_asc",
                "price_desc",
                "mileage_asc",
                "mileage_desc",
                "year_desc",
                "year_asc"
              ],
              "default": "newest"
            },
            "description": "Sort order"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "description": "Maximum vehicles to return"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching vehicles",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryResult"
                }
              }
            }
          },
          "503": {
            "description": "Inventory temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/vehicles/{id}": {
      "get": {
        "operationId": "getVehicle",
        "summary": "Get one currently listed vehicle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The vehicle",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VehicleResult"
                }
              }
            }
          },
          "400": {
            "description": "Not a vehicle id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not currently listed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Inventory temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/dealership": {
      "get": {
        "operationId": "getDealershipInfo",
        "summary": "Address, hours, approved policy wording and website links",
        "responses": {
          "200": {
            "description": "Dealership information",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Whether live inventory can be read",
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "listed_vehicles": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Inventory unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "unavailable"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Vehicle": {
        "type": "object",
        "required": [
          "id",
          "title",
          "url",
          "price_usd",
          "on_special",
          "featured",
          "listed_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The vehicle's page on this website"
          },
          "year": {
            "type": [
              "integer",
              "null"
            ]
          },
          "make": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "trim": {
            "type": [
              "string",
              "null"
            ]
          },
          "price_usd": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Advertised price in whole US dollars (the special price when one applies). Excludes tax, title, registration and dealer fees."
          },
          "regular_price_usd": {
            "type": [
              "integer",
              "null"
            ]
          },
          "on_special": {
            "type": "boolean"
          },
          "mileage": {
            "type": [
              "integer",
              "null"
            ]
          },
          "exterior_color": {
            "type": [
              "string",
              "null"
            ]
          },
          "interior_color": {
            "type": [
              "string",
              "null"
            ]
          },
          "body_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "drivetrain": {
            "type": [
              "string",
              "null"
            ]
          },
          "transmission": {
            "type": [
              "string",
              "null"
            ]
          },
          "fuel_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "engine": {
            "type": [
              "string",
              "null"
            ]
          },
          "city_mpg": {
            "type": [
              "number",
              "null"
            ]
          },
          "highway_mpg": {
            "type": [
              "number",
              "null"
            ]
          },
          "vin": {
            "type": [
              "string",
              "null"
            ]
          },
          "carfax_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Free CARFAX report"
          },
          "featured": {
            "type": "boolean"
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "listed_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VehicleDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Vehicle"
          },
          {
            "type": "object",
            "properties": {
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "images": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "InventoryResult": {
        "type": "object",
        "required": [
          "total_matches",
          "returned",
          "vehicles"
        ],
        "properties": {
          "total_matches": {
            "type": "integer"
          },
          "returned": {
            "type": "integer"
          },
          "vehicles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Vehicle"
            }
          },
          "note": {
            "type": "string"
          }
        }
      },
      "VehicleResult": {
        "type": "object",
        "required": [
          "vehicle"
        ],
        "properties": {
          "vehicle": {
            "$ref": "#/components/schemas/VehicleDetail"
          },
          "availability": {
            "type": "string"
          }
        }
      }
    }
  }
}
