openapi: 3.0.0
info:
  title: AutoTrader UK Search API
  description: |
    The AutoTrader UK Search API returns real-time car listings from AutoTrader UK (autotrader.co.uk) around a UK
    postcode, 20 cars a page in AutoTrader's order, plus paid placements inline as additional rows. Narrow the
    search by make, model, trim and advert text, and refine with structured filters such as price, mileage,
    registration year, fuel, body type, colour, doors, seats, engine size, power, seller type and insurance
    write-offs. List parameters take several values separated by commas.

    **Cross-linking**: the values in `filters` can be sent back in the parameter named by the group's `key`, and
    `pagination.next_page` in `page`.

    **Promoted results**: rows with `is_promoted: true` are paid placements, added inline to the page's 20 cars, so a
    page can hold more than 20 rows. They can ignore `sort_by` and be priced below `price_min`. A promoted car that
    also holds an organic slot on the same page is returned once, as the organic row.
    `search_information.results_on_page` counts every row, and `pagination.next_page` continues the search.

    **Pagination limit**: AutoTrader UK serves at most 100 pages of one search, so narrow with filters to reach
    deeper inventory.

    **Partial answers**: when AutoTrader UK returns the cars but not the filter options, the answer has no
    `filters` and `search_information.is_partial` is `true`.

    Prices are in pounds sterling and distances and mileages in miles, as AutoTrader UK shows them. Boolean fields
    are present only when true.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: AutoTrader UK Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Engine to use for the search'
          schema:
            type: string
            enum: ["autotrader_uk_search"]
            default: "autotrader_uk_search"
        - name: zip
          in: query
          required: true
          description: 'UK postcode to search from, written in full, such as `SW1A 1AA`. The server trims surrounding spaces. Trim the input before applying the pattern. A postcode AutoTrader UK cannot find returns an error.'
          schema:
            type: string
            pattern: "^[A-Za-z]{1,2}[0-9][A-Za-z0-9]?[ \\t\\r\\n\\f\\v]?[0-9][A-Za-z]{2}$"
        - name: radius
          in: query
          required: false
          description: 'Distance from `zip` in miles. Without it, AutoTrader UK searches the whole UK.'
          schema:
            type: integer
            enum: [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 200]
        - name: make
          in: query
          required: false
          description: 'Car makes, comma-separated, up to 5, each up to 40 characters, such as `BMW` or `Ford,Vauxhall`. Takes the names in the `make` group of `filters`, in any letter case. An unknown make returns an error naming the closest AutoTrader UK makes.'
          schema:
            type: string
        - name: model
          in: query
          required: false
          description: 'Models, comma-separated, up to 50, each up to 60 characters, such as `3 Series`. Requires `make`. Takes the names in the `model` group of `filters`, and a name AutoTrader UK does not know returns no cars.'
          schema:
            type: string
        - name: trim
          in: query
          required: false
          description: 'Trims, comma-separated, up to 50, each up to 60 characters, such as `M Sport`. Case-sensitive: takes the names in the `trim` group of `filters` as spelled there. With `model`, a trim listed in another letter case returns an error naming its spelling. Without a listed alternative, a trim with no matches returns no cars.'
          schema:
            type: string
        - name: q
          in: query
          required: false
          description: 'Words to find in the advert text, such as `sunroof`. The server trims surrounding whitespace and collapses repeated whitespace to one space. Apply the same normalization before validating the 100-character limit.'
          schema:
            type: string
            maxLength: 100
        - name: price_min
          in: query
          required: false
          description: 'Lowest price in pounds. A paid placement, marked `is_promoted`, can be priced below it.'
          schema:
            type: integer
            minimum: 0
            maximum: 10000000
        - name: price_max
          in: query
          required: false
          description: 'Highest price in pounds.'
          schema:
            type: integer
            minimum: 0
            maximum: 10000000
        - name: mileage_min
          in: query
          required: false
          description: 'Lowest mileage in miles.'
          schema:
            type: integer
            minimum: 0
            maximum: 2000000
        - name: mileage_max
          in: query
          required: false
          description: 'Highest mileage in miles.'
          schema:
            type: integer
            minimum: 0
            maximum: 2000000
        - name: registration_year_min
          in: query
          required: false
          description: 'Earliest registration year, up to the current year. Cannot be combined with `condition=new`, which lists new cars.'
          schema:
            type: integer
            minimum: 1900
        - name: registration_year_max
          in: query
          required: false
          description: 'Latest registration year. A year after the current one returns the same cars as the current year. Any value leaves out new cars, which have no registration year. Cannot be combined with `condition=new`.'
          schema:
            type: integer
            minimum: 1900
        - name: condition
          in: query
          required: false
          description: 'Car conditions, comma-separated, from `new`, `used` and `manufacturer_certified`. `used` includes manufacturer-certified cars, and `new` cannot be combined with another value or with a registration year.'
          schema:
            type: string
        - name: fuel_type
          in: query
          required: false
          description: 'Fuel types, comma-separated, from `petrol`, `diesel`, `electric`, `hybrid`, `hybrid_petrol`, `plug_in_hybrid_petrol`, `hybrid_diesel`, `plug_in_hybrid_diesel`, `bi_fuel`, `hydrogen` and `cng`. `hybrid` selects all four hybrid kinds, while `hybrid_petrol` and `hybrid_diesel` leave out plug-in hybrids.'
          schema:
            type: string
        - name: body_type
          in: query
          required: false
          description: 'Body types, comma-separated, from `convertible`, `coupe`, `station_wagon`, `hatchback`, `sedan`, `van`, `suv`, `pickup`, `camper`, `car_derived_van`, `combi_van`, `limousine`, `minibus`, `panel_van`, `window_van` and `ambulance`. `van` is the MPV class.'
          schema:
            type: string
        - name: transmission
          in: query
          required: false
          description: 'Transmissions, comma-separated, from `automatic` and `manual`.'
          schema:
            type: string
        - name: drivetrain
          in: query
          required: false
          description: 'Drivetrains, comma-separated, from `front`, `rear` and `all_wheel`.'
          schema:
            type: string
        - name: color
          in: query
          required: false
          description: 'Exterior colours, comma-separated, from `beige`, `black`, `blue`, `bronze`, `brown`, `gold`, `green`, `grey`, `multicolour`, `orange`, `pink`, `red`, `silver`, `violet`, `white` and `yellow`.'
          schema:
            type: string
        - name: doors_min
          in: query
          required: false
          description: 'Fewest doors.'
          schema:
            type: integer
            minimum: 0
            maximum: 7
        - name: doors_max
          in: query
          required: false
          description: 'Most doors.'
          schema:
            type: integer
            minimum: 0
            maximum: 7
        - name: seats_min
          in: query
          required: false
          description: 'Fewest seats.'
          schema:
            type: integer
            minimum: 1
            maximum: 18
        - name: seats_max
          in: query
          required: false
          description: 'Most seats.'
          schema:
            type: integer
            minimum: 1
            maximum: 18
        - name: displacement_min
          in: query
          required: false
          description: 'Smallest engine size in cc. AutoTrader UK lists engine sizes in tenths of a litre, so the value is rounded to the nearest 100 cc: 1,550 to 1,649 all search from 1.6 litres.'
          schema:
            type: integer
            minimum: 0
            maximum: 20000
        - name: displacement_max
          in: query
          required: false
          description: 'Largest engine size in cc. AutoTrader UK lists engine sizes in tenths of a litre, so the value is rounded to the nearest 100 cc: 1,550 to 1,649 all search up to 1.6 litres.'
          schema:
            type: integer
            minimum: 0
            maximum: 20000
        - name: power_min
          in: query
          required: false
          description: 'Lowest engine power in the unit `power_unit` sets, up to 2000 kW or 2719 hp.'
          schema:
            type: integer
            minimum: 0
            maximum: 2719
        - name: power_max
          in: query
          required: false
          description: 'Highest engine power in the unit `power_unit` sets, up to 2000 kW or 2719 hp.'
          schema:
            type: integer
            minimum: 0
            maximum: 2719
        - name: power_unit
          in: query
          required: false
          description: 'Unit of `power_min` and `power_max`.'
          schema:
            type: string
            enum: ["kw", "hp"]
            default: "kw"
        - name: seller_type
          in: query
          required: false
          description: 'Lists the cars of dealers only, or of private sellers only.'
          schema:
            type: string
            enum: ["dealer", "private"]
        - name: damage
          in: query
          required: false
          description: 'Insurance write-offs, which results mark with `write_off_category`, are left out with `exclude`, included with `include`, or returned alone with `only`.'
          schema:
            type: string
            enum: ["exclude", "include", "only"]
            default: "include"
        - name: is_ulez_compliant
          in: query
          required: false
          description: "Set to `true` for cars that meet London's Ultra Low Emission Zone standards."
          schema:
            type: boolean
            enum: [true]
        - name: sort_by
          in: query
          required: false
          description: 'Result order. Paid placements, marked `is_promoted`, can keep their own slots in every order.'
          schema:
            type: string
            enum: ["best_match", "price_asc", "price_desc", "mileage_asc", "registration_desc", "registration_asc", "newest", "distance"]
            default: "best_match"
        - name: page
          in: query
          required: false
          description: 'Page of results. AutoTrader UK serves at most 100 pages of one search.'
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 1
        - name: api_key
          in: query
          required: false
          description: 'Your SearchApi API key (or use the Authorization header).'
          schema:
            type: string
        - name: zero_retention
          in: query
          required: false
          description: Set to true to prevent request parameters, HTML, and JSON response content from being stored or logged. Operational metadata and billing records are retained. Enterprise plans only.
          schema:
            type: boolean
            default: false
      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: Retrieval failed, for example because the source refused the request or results could not be retrieved within 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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        filters:
          type: array
          description: Values the search accepts back, grouped by parameter, with counts for suggested values and optional counts for values marked `is_selected`.
          items:
            $ref: '#/components/schemas/Filter'
        organic_results:
          type: array
          description: Cars on this page, in AutoTrader UK's order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Explanation of an answer without cars, such as a postcode or filter value AutoTrader UK refused or a trim sent in another letter case.
    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 UK URL for this search"
        html_url:
          type: string
          description: "URL to view the stored response as escaped JSON"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        zip:
          type: string
          description: Postcode searched from
        radius:
          type: string
          description: Value sent in radius
        make:
          type: string
          description: Makes searched
        model:
          type: string
          description: Models searched
        trim:
          type: string
          description: Trims searched
        q:
          type: string
          description: Words searched in the advert text
        price_min:
          type: string
          description: Value sent in price_min
        price_max:
          type: string
          description: Value sent in price_max
        mileage_min:
          type: string
          description: Value sent in mileage_min
        mileage_max:
          type: string
          description: Value sent in mileage_max
        registration_year_min:
          type: string
          description: Value sent in registration_year_min
        registration_year_max:
          type: string
          description: Value sent in registration_year_max
        condition:
          type: string
          description: Value sent in condition
        fuel_type:
          type: string
          description: Value sent in fuel_type
        body_type:
          type: string
          description: Value sent in body_type
        transmission:
          type: string
          description: Value sent in transmission
        drivetrain:
          type: string
          description: Value sent in drivetrain
        color:
          type: string
          description: Value sent in color
        doors_min:
          type: string
          description: Value sent in doors_min
        doors_max:
          type: string
          description: Value sent in doors_max
        seats_min:
          type: string
          description: Value sent in seats_min
        seats_max:
          type: string
          description: Value sent in seats_max
        displacement_min:
          type: string
          description: Value sent in displacement_min
        displacement_max:
          type: string
          description: Value sent in displacement_max
        power_min:
          type: string
          description: Value sent in power_min
        power_max:
          type: string
          description: Value sent in power_max
        power_unit:
          type: string
          description: Unit of the power range
        seller_type:
          type: string
          description: Value sent in seller_type
        damage:
          type: string
          description: How insurance write-offs were treated
        is_ulez_compliant:
          type: string
          description: Value sent in is_ulez_compliant
        sort_by:
          type: string
          description: Result order
        page:
          type: integer
          description: Page of results
        zero_retention:
          type: boolean
          description: Whether persistent request and response storage is disabled.
    SearchInformation:
      type: object
      required: [total_results, results_on_page]
      properties:
        total_results:
          type: integer
          description: Number of cars AutoTrader UK reports for the search.
        total_pages:
          type: integer
          description: Number of pages the search can browse, at most 100.
        page:
          type: integer
          description: Page number of this response.
        results_on_page:
          type: integer
          description: Number of cars in `organic_results`, paid placements included.
        is_partial:
          type: boolean
          description: Whether AutoTrader UK returned the cars but not the filter options, so `filters` is missing from this answer.
    Filter:
      type: object
      required: [key, options]
      properties:
        key:
          type: string
          description: Parameter that takes the values of this group.
          enum: ["make", "model", "trim", "fuel_type", "body_type", "transmission", "drivetrain", "color", "seller_type", "damage"]
        options:
          type: array
          description: Values of the group in AutoTrader UK's order.
          items:
            $ref: '#/components/schemas/FilterOption'
    FilterOption:
      type: object
      required: [value]
      properties:
        text:
          type: string
          description: AutoTrader UK's label for the value.
        value:
          type: string
          description: Value the parameter named by the group's `key` accepts.
        count:
          type: integer
          description: Number of cars AutoTrader UK counts for the value.
        is_selected:
          type: boolean
          description: Whether this search sent the value.
    OrganicResult:
      type: object
      required: [position, id, link]
      properties:
        position:
          type: integer
          description: Rank of the car on this page, from 1.
        id:
          type: string
          description: AutoTrader UK advert id, a string of digits.
        title:
          type: string
          description: Make, model and the advert's version text.
        link:
          type: string
          description: The car's advert page on AutoTrader UK.
        is_promoted:
          type: boolean
          description: Whether the row is a paid placement, which can ignore `sort_by`.
        price:
          type: string
          description: Price as AutoTrader UK displays it, with the pound sign.
        extracted_price:
          type: integer
          description: Price in whole pounds.
        currency:
          type: string
          description: ISO 4217 code of the price.
          enum: ["GBP"]
        msrp:
          type: string
          description: Manufacturer's recommended retail price as AutoTrader UK displays it.
        extracted_msrp:
          type: integer
          description: Manufacturer's recommended retail price in whole pounds.
        price_level:
          type: string
          description: AutoTrader UK's rating of the price against similar cars, from `top` for a great price down to `somewhat_expensive` for a higher price, or `too_low` for a lower price.
          enum: ["top", "good", "fair", "somewhat_expensive", "too_low"]
        price_level_label:
          type: string
          description: AutoTrader UK's wording of the price rating, such as Great price.
        make:
          type: string
          description: Make name as AutoTrader UK lists it.
        model:
          type: string
          description: Model name as AutoTrader UK lists it.
        variant:
          type: string
          description: Version text of the advert, such as the engine and trim.
        condition:
          type: string
          description: Whether the car is new, used or a manufacturer-certified used car.
          enum: ["new", "used", "manufacturer_certified"]
        registration_year:
          type: integer
          description: Registration year AutoTrader UK shows for the car.
        plate:
          type: string
          description: UK registration age identifier, such as 17 or F.
        mileage:
          type: string
          description: Mileage as AutoTrader UK displays it, in miles.
        extracted_mileage:
          type: integer
          description: Mileage in `mileage_unit`.
        mileage_unit:
          type: string
          description: Unit of `extracted_mileage`.
          enum: ["mi"]
        write_off_category:
          type: string
          description: Insurance write-off category the seller declares.
          enum: ["S", "N", "C", "D"]
        tagline:
          type: string
          description: Headline the seller wrote for the advert.
        seller:
          $ref: '#/components/schemas/Seller'
        location:
          $ref: '#/components/schemas/Location'
        extracted_distance:
          type: integer
          description: Distance from the postcode in `zip`, in `distance_unit`.
        distance_unit:
          type: string
          description: Unit of `extracted_distance`.
          enum: ["mi"]
        thumbnail:
          type: string
          description: The first photo at 480 pixels wide.
        images:
          type: array
          description: Up to four photos at 800 pixels wide.
          items:
            type: string
        images_count:
          type: integer
          description: Number of photos the advert has.
    Seller:
      type: object
      properties:
        id:
          type: string
          description: AutoTrader UK id of the dealer.
        type:
          type: string
          description: Whether a dealer or a private seller lists the car.
          enum: ["dealer", "private"]
        info_page:
          type: string
          description: AutoTrader UK page of the dealer.
        rating:
          type: number
          description: Dealer's review rating from 0 to 5.
    Location:
      type: object
      properties:
        city:
          type: string
          description: Town where the car is.
    Pagination:
      type: object
      properties:
        current_page:
          type: integer
          description: Page number of this response.
        total_pages:
          type: integer
          description: Number of pages the search can browse, at most 100.
        next_page:
          type: integer
          description: Number of the next page, which `page` accepts.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
