openapi: "3.0.0"
info:
  title: "Autotrader Listing API"
  description: |
    The Autotrader Listing API returns the details page of one car listed on Autotrader.com: price, MSRP and price
    history, the vehicle with its features, equipment and history report highlights, warranties, the seller, the
    address, photos, videos and the seller's description.

    **Cross-linking**: pass the `link` of an Autotrader Search API (`engine=autotrader_search`) result as `url`, or
    its `id` as `listing_id`. A listing's `vehicle.equipment` ids and `seller.id` can be passed to the Autotrader
    Search API as `equipment` and `seller_id`.

    Listings end when a car is sold, so take them from a fresh search. Prices are in US dollars, and mileage and
    electric range in miles. Boolean fields are present only when true.
  version: "1.0.0"
servers:
  - url: "https://www.searchapi.io/api/v1"
paths:
  /search:
    get:
      summary: "Autotrader Listing"
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: "Engine to use for the search."
          schema:
            type: string
            enum: ["autotrader_listing"]
            default: "autotrader_listing"
        - name: url
          in: query
          required: false
          description: "The Autotrader listing to fetch, such as the `link` of an Autotrader Search API result, the car's URL copied from autotrader.com, or its path `/cars-for-sale/vehicle/{id}`. Listings end when a car is sold, so take the link from a fresh search. Either `url` or `listing_id` is required, not both."
          schema:
            type: string
            maxLength: 500
        - name: listing_id
          in: query
          required: false
          description: "Autotrader listing id, such as the `id` of an Autotrader Search API result. Listings end when a car is sold, so take the id from a fresh search. Either `url` or `listing_id` is required, not both."
          schema:
            type: string
            pattern: "^[1-9]\\d{5,9}$"
        - name: zero_retention
          in: query
          required: false
          description: "Set to `true` to disable logging and persistent storage for this request. Enterprise plans only."
          schema:
            type: boolean
            default: false
        - name: api_key
          in: query
          required: false
          description: "Your SearchApi API key (or use the Authorization header)."
          schema:
            type: string
      responses:
        "200":
          description: "Successful response"
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/SearchResponse"
        "400":
          description: "Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
        "401":
          description: "Authentication Error. The API key is missing or invalid."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
        "403":
          description: "Forbidden. Zero data retention is not available to the account, or the account requires `zero_retention=true`."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
        "429":
          description: "Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
        "500":
          description: "Server Error. Internal server error."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
        "503":
          description: "Timeout. We could not retrieve results in 90 seconds."
          content:
            application/json:
              schema:
                '$ref': "#/components/schemas/ErrorResponse"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: "Use Bearer authentication. Format: \"Bearer YOUR_API_KEY\""
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: "Pass API key as query parameter"
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          '$ref': "#/components/schemas/SearchMetadata"
        search_parameters:
          '$ref': "#/components/schemas/SearchParameters"
        listing:
          '$ref': "#/components/schemas/Listing"
        error:
          type: string
          description: "Explanation of an answer without a car, such as a listing that has ended."
    SearchMetadata:
      type: object
      required: ["status", "created_at"]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Autotrader URL for this search"
        html_url:
          type: string
          description: "URL to view HTML results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: "Engine used"
        url:
          type: string
          description: "Listing URL or path sent"
        listing_id:
          type: string
          description: "Listing id sent"
        zero_retention:
          type: boolean
          description: "Whether logging and persistent storage were disabled for this request."
    Listing:
      type: object
      required: ["id", "link"]
      properties:
        id:
          type: string
          description: "Autotrader listing id."
        title:
          type: string
          description: "Listing title, such as `New 2027 Toyota Camry XSE w/ Premium Plus Package`."
        link:
          type: string
          description: "The car's details page on Autotrader."
        stock_number:
          type: string
          description: "Dealer's own stock number for the car."
        price:
          type: string
          description: "Displayed price in US dollars with dealer fees included, as text such as `$34,590`."
        extracted_price:
          type: integer
          description: "Displayed price in US dollars with dealer fees included."
        currency:
          type: string
          description: "Currency of every price of the car."
          enum: ["USD"]
        is_price_on_request:
          type: boolean
          description: "Whether the car is listed without a price."
        price_before_fees:
          type: string
          description: "Price before the dealer's fees, as text."
        extracted_price_before_fees:
          type: integer
          description: "Price before the dealer's fees in US dollars."
        estimated_value:
          '$ref': "#/components/schemas/EstimatedValue"
        price_level:
          type: string
          description: "Autotrader's deal rating, as the token the `price_level` parameter takes."
          enum: ["top", "good"]
        price_level_label:
          type: string
          description: "Autotrader's deal rating as the site shows it, such as `Great Price`."
        is_price_reduced:
          type: boolean
          description: "Whether Autotrader marks the price as reduced."
        price_history:
          type: array
          description: "Earlier prices of the car, oldest first."
          items:
            '$ref': "#/components/schemas/PriceChange"
        msrp:
          type: string
          description: "Manufacturer's suggested retail price, as text."
        extracted_msrp:
          type: integer
          description: "Manufacturer's suggested retail price in US dollars."
        days_on_market:
          type: integer
          description: "Days since the car was listed on Autotrader."
        vehicle:
          '$ref': "#/components/schemas/Vehicle"
        warranties:
          type: array
          description: "The manufacturer's original warranties that cover the car."
          items:
            '$ref': "#/components/schemas/Warranty"
        seller:
          '$ref': "#/components/schemas/Seller"
        location:
          '$ref': "#/components/schemas/Location"
        videos:
          type: array
          description: "Videos of the car."
          items:
            type: string
        images:
          type: array
          description: "Photos of the car."
          items:
            type: string
        description:
          type: string
          description: "Seller's description of the car as plain text, with its line breaks."
    Vehicle:
      type: object
      description: "The car's own attributes."
      properties:
        condition:
          type: string
          description: "Condition of the car, as the token the `condition` parameter takes."
          enum: ["new", "used", "manufacturer_certified", "third_party_certified"]
        certification_program:
          type: string
          description: "Certification programme the car is listed under, such as `Toyota Certified Pre-Owned`."
        model_year:
          type: integer
          description: "Model year of the car, such as `2026`."
        make:
          type: string
          description: "Make name, such as `Toyota`."
        make_id:
          type: string
          description: "Autotrader make code, which the `make` parameter also takes."
        model:
          type: string
          description: "Model name, such as `Camry`."
        model_id:
          type: string
          description: "Autotrader model code, which the `model` parameter also takes."
        trim:
          type: string
          description: "Trim as Autotrader's catalogue names it, which can differ from the values the Autotrader Search API's `trim` parameter takes."
        vin:
          type: string
          description: "Vehicle identification number."
        mileage:
          type: string
          description: "Mileage as text with its unit, such as `2,558 mi`."
        extracted_mileage:
          type: integer
          description: "Mileage in miles."
        mileage_unit:
          type: string
          description: "Unit of the mileage."
          enum: ["mi"]
        body_type:
          type: string
          description: "Body type, as the token the `body_type` parameter takes."
          enum: ["convertible", "coupe", "hatchback", "sedan", "suv", "pickup", "van", "station_wagon"]
        body_type_label:
          type: string
          description: "Body style as Autotrader names it, such as `Sport Utility`."
        bed_length:
          type: string
          description: "Length of a pickup's bed as Autotrader shows it, such as `5'6\"`."
        fuel_type:
          type: string
          description: "Fuel, as the token the `fuel_type` parameter takes."
          enum: ["petrol", "diesel", "electric", "hybrid", "plug_in_hybrid"]
        fuel_type_label:
          type: string
          description: "Fuel as Autotrader names it, such as `Hybrid Gas/Electric`."
        transmission:
          type: string
          description: "Transmission, as the token the `transmission` parameter takes."
          enum: ["automatic", "manual"]
        transmission_label:
          type: string
          description: "Transmission as Autotrader describes it, such as `Continuously Variable Automatic`."
        drivetrain:
          type: string
          description: "Drivetrain, as the token the `drivetrain` parameter takes."
          enum: ["all_wheel", "front", "rear"]
        drivetrain_label:
          type: string
          description: "Drivetrain as Autotrader describes it, such as `All wheel drive`."
        motor:
          type: string
          description: "Engine as Autotrader names it, such as `2.5L Inline-4 Gas`."
        cylinders:
          type: integer
          description: "Number of cylinders."
        color:
          type: string
          description: "Exterior colour, as the token the `color` parameter takes."
          enum: ["beige", "black", "blue", "brown", "burgundy", "charcoal", "gold", "grey", "green", "off_white", "orange", "pink", "violet", "red", "silver", "tan", "turquoise", "white", "yellow"]
        color_label:
          type: string
          description: "Exterior colour as Autotrader's colour filter names it."
        manufacturer_color:
          type: string
          description: "Exterior colour as the manufacturer names it, such as `Reservoir Blue`."
        interior_color:
          type: string
          description: "Interior colour, as the token the `interior_color` parameter takes."
          enum: ["beige", "black", "blue", "brown", "burgundy", "charcoal", "gold", "grey", "green", "off_white", "orange", "pink", "violet", "red", "silver", "tan", "turquoise", "white", "yellow"]
        interior_color_label:
          type: string
          description: "Interior colour as Autotrader's colour filter names it."
        fuel_economy:
          '$ref': "#/components/schemas/FuelEconomy"
        extracted_electric_range:
          type: integer
          description: "Electric range in miles."
        electric_range_unit:
          type: string
          description: "Unit of the electric range."
          enum: ["mi"]
        battery_type:
          type: string
          description: "Chemistry of the traction battery of a hybrid or electric car, such as `Lithium-Ion`."
        packages:
          type: array
          description: "Option packages the car has, such as `Premium Plus Package`."
          items:
            type: string
        is_accident_free:
          type: boolean
          description: "Whether the history report shows no accidents."
        has_accident_history:
          type: boolean
          description: "Whether the history report shows an accident."
        previous_owners:
          type: integer
          description: "Number of previous owners the history report shows."
        has_clean_title:
          type: boolean
          description: "Whether the history report shows no salvage title."
        has_salvage_title:
          type: boolean
          description: "Whether the history report shows a salvage title."
        has_frame_damage:
          type: boolean
          description: "Whether the history report shows frame damage."
        has_free_history_report:
          type: boolean
          description: "Whether the car's history report is free to read on Autotrader."
        history_report_link:
          type: string
          description: "Link to the car's AutoCheck vehicle history report."
        consumer_rating:
          type: number
          description: "Average Kelley Blue Book consumer rating of the model, out of 5."
        consumer_reviews:
          type: integer
          description: "Number of Kelley Blue Book consumer reviews behind the rating."
        features:
          type: array
          description: "Every feature the details page lists, in the page's category order."
          items:
            type: string
        equipment:
          type: object
          description: "Features Autotrader ranks for the car, by category such as `safety` or `technology`."
          additionalProperties:
            type: array
            description: "Features of the category."
            items:
              '$ref': "#/components/schemas/EquipmentItem"
        open_recalls:
          type: integer
          description: "Number of open safety recalls the details page reports."
    EquipmentItem:
      type: object
      required: ["name"]
      properties:
        id:
          type: string
          description: "Equipment id, which the `equipment` parameter of the Autotrader Search API takes."
        name:
          type: string
          description: "Feature name."
    Warranty:
      type: object
      required: ["name"]
      properties:
        name:
          type: string
          description: "Kind of warranty, such as `Basic` or `Powertrain`."
        details:
          type: string
          description: "Coverage as Autotrader states it, such as `3 Years/36,000 Miles`."
        years:
          type: integer
          description: "Coverage in years."
        miles:
          type: integer
          description: "Coverage in miles."
    EstimatedValue:
      type: object
      required: ["value"]
      description: "Kelley Blue Book's fair purchase price for the car and its range."
      properties:
        value:
          type: integer
          description: "Fair purchase price in US dollars."
        low:
          type: integer
          description: "Low end of the fair purchase range in US dollars."
        high:
          type: integer
          description: "High end of the fair purchase range in US dollars."
    PriceChange:
      type: object
      required: ["date", "price", "extracted_price"]
      properties:
        date:
          type: string
          description: "Date the price was set, as YYYY-MM-DD."
          format: date
        price:
          type: string
          description: "Price set on that date, as text."
        extracted_price:
          type: integer
          description: "Price set on that date in US dollars."
    FuelEconomy:
      type: object
      required: ["unit"]
      description: "Fuel economy rated for the car."
      properties:
        city:
          type: integer
          description: "City fuel economy in miles per gallon."
        highway:
          type: integer
          description: "Highway fuel economy in miles per gallon."
        unit:
          type: string
          description: "Unit of the fuel economy."
          enum: ["mpg"]
    Location:
      type: object
      description: "Where the seller lists the car."
      properties:
        street:
          type: string
          description: "Street of the seller's address."
        city:
          type: string
          description: "City of the seller's address."
        state:
          type: string
          description: "Two-letter state code of the seller's address."
        zip:
          type: string
          description: "ZIP code of the seller's address."
        latitude:
          type: number
          description: "Latitude of the seller's address."
        longitude:
          type: number
          description: "Longitude of the seller's address."
    Seller:
      type: object
      required: ["id", "type"]
      properties:
        id:
          type: string
          description: "Autotrader seller id, which the `seller_id` parameter of the Autotrader Search API takes."
        type:
          type: string
          description: "Whether the seller is a dealer or a private seller, as the token the `seller_type` parameter takes."
          enum: ["dealer", "private"]
        name:
          type: string
          description: "Seller's name."
        phones:
          type: array
          description: "Seller's phone numbers."
          items:
            type: string
        rating:
          type: number
          description: "Average dealer rating out of 5."
        reviews:
          type: integer
          description: "Number of dealer reviews behind the rating."
        website:
          type: string
          description: "The car's page on the dealer's own website."
        logo:
          type: string
          description: "Dealer's logo image."
        has_home_delivery:
          type: boolean
          description: "Whether the dealer offers to deliver the car to the buyer's home."
        hours:
          type: array
          description: "Dealer's opening hours, one entry per open day, from Monday. A day with no entry is closed."
          items:
            '$ref': "#/components/schemas/OpeningPeriod"
    OpeningPeriod:
      type: object
      required: ["day", "open", "close"]
      properties:
        day:
          type: string
          description: "Day of the week."
          enum: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
        open:
          type: string
          description: "Opening time in the dealer's local time, formatted HH:MM."
        close:
          type: string
          description: "Closing time in the dealer's local time, formatted HH:MM."
    ErrorResponse:
      type: object
      required: ["error"]
      properties:
        error:
          type: string
          description: "Error message describing what went wrong"
