openapi: 3.0.0
info:
  title: CarGurus Search API
  description: |
    The CarGurus Search API returns real-time used and new car listings from CarGurus in the US, searched around a
    ZIP code. Search by make, model, model id or trim and refine with filters such as condition, price, mileage,
    model year, fuel, body type, colour, deal rating, options and listing age. List parameters take several values
    separated by commas.

    **Cross-linking**: a result's `make` with its `model_id`, its `trim`, its `seller.id` and its `features`, and
    the values in `filters`, can be passed back as `make`, `model_id`, `trim`, `seller_id` and `features`.

    **Promoted results**: rows with `is_promoted: true` are paid placements, which can ignore `sort_by`. A promoted
    car that also holds an organic slot on the same page is returned once, as the organic row. A car listed as an
    organic row on one page can come back as a promoted row on another page.

    Prices are in US dollars and distances and mileages 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: CarGurus Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Engine to use for the search'
          schema:
            type: string
            enum: ["cargurus_search"]
            default: "cargurus_search"
        - name: zip
          in: query
          required: true
          description: '5-digit US ZIP code to search around. A ZIP code CarGurus cannot place returns an error.'
          schema:
            type: string
            pattern: "^\\d{5}$"
        - name: radius
          in: query
          required: false
          description: 'Distance around `zip` in miles, from 1 to 500, or `all` for the whole country.'
          schema:
            type: string
            pattern: "^([1-9][0-9]?|[1-4][0-9]{2}|500|all)$"
            default: "50"
        - name: include_delivery
          in: query
          required: false
          description: 'Whether cars of dealers farther away that can be shipped or transferred near `zip` are included.'
          schema:
            type: boolean
            default: true
        - name: make
          in: query
          required: false
          description: 'Vehicle makes, comma-separated, each up to 60 characters. Takes any CarGurus make name, such as those in the `make` group of `filters`, or a slug, such as `toyota` or `land-rover`. An unknown make returns an error naming the closest CarGurus makes.'
          schema:
            type: string
        - name: model
          in: query
          required: false
          description: 'Vehicle models, comma-separated, each up to 60 characters. Requires `make`. Each name is matched within the listed makes, as in the `model` group of `filters`, and a name two listed makes share searches both. A listed make that none of the models or model ids belongs to is searched in full, so `make=bmw,audi&model=a4` returns every BMW and the Audi A4. An unknown model returns an error naming the closest CarGurus models.'
          schema:
            type: string
        - name: model_id
          in: query
          required: false
          description: 'CarGurus model ids, comma-separated, each up to 6 digits, such as the `model_id` of a result. Requires `make`, and each id must be a model of a listed make.'
          schema:
            type: string
        - name: trim
          in: query
          required: false
          description: "Trims, comma-separated, each up to 60 characters. Trims are case-sensitive: spell them as in the `trim` group of `filters` or a result's `trim`. A trim given only in another case returns an error quoting CarGurus' spelling, or no results when that spelling has no cars in the search. An unknown trim, or one with no cars near `zip`, returns an error naming up to 3 of the closest trims with cars in the search, or no results when none has. Requires `make` and a model, from `model` or `model_id`. With several models, each trim narrows the models that list it, and a model that lists none of the trims is searched in full. Send a trim from `filters` with its option's `make` and `model_id` to search only the cars it counts. `make`, `model`, `model_id` and `trim` together select at most 150 CarGurus models and trims, and trims too long together for one CarGurus search return an error."
          schema:
            type: string
        - name: condition
          in: query
          required: false
          description: 'Conditions, comma-separated, from `new`, `used`, `manufacturer_certified` and `third_party_certified`. `used` includes certified cars, and `new` cannot be combined with another value. The default is `used`.'
          schema:
            type: string
        - name: price_min
          in: query
          required: false
          description: "Lowest price in US dollars before any delivery cost, with the dealer's fees only where a result's `has_dealer_fees_included` is true. Cars listed without a price are left out."
          schema:
            type: integer
            minimum: 0
            maximum: 10000000
        - name: price_max
          in: query
          required: false
          description: "Highest price in US dollars before any delivery cost, with the dealer's fees only where a result's `has_dealer_fees_included` is true. Cars listed without a price are left out."
          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: model_year_min
          in: query
          required: false
          description: 'Earliest model year, up to next year.'
          schema:
            type: integer
            minimum: 1900
        - name: model_year_max
          in: query
          required: false
          description: 'Latest model year. A year past next year is searched as next year.'
          schema:
            type: integer
            minimum: 1900
        - name: fuel_type
          in: query
          required: false
          description: 'Fuel types, comma-separated, from `petrol`, `diesel`, `electric`, `hybrid`, `flex_fuel`, `biodiesel`, `cng`, `hydrogen` and `lpg`. `hybrid` includes plug-in hybrids.'
          schema:
            type: string
        - name: transmission
          in: query
          required: false
          description: 'Transmissions, comma-separated, from `automatic` and `manual`.'
          schema:
            type: string
        - name: body_type
          in: query
          required: false
          description: 'Body types, comma-separated, from `coupe`, `convertible`, `hatchback`, `van`, `pickup`, `sedan`, `suv`, `transporter` and `station_wagon`. `van` is a minivan and `transporter` a full-size van.'
          schema:
            type: string
        - name: drivetrain
          in: query
          required: false
          description: 'Drivetrains, comma-separated, from `front`, `rear`, `all_wheel`, `four_wheel` and `four_by_two`. `all_wheel` is all-wheel drive, so send `all_wheel,four_wheel` for every car that drives all four wheels.'
          schema:
            type: string
        - name: color
          in: query
          required: false
          description: 'Exterior colours, comma-separated, from `black`, `white`, `grey`, `silver`, `blue`, `red`, `brown`, `green`, `yellow`, `orange`, `gold`, `violet`, `pink` and `teal`.'
          schema:
            type: string
        - name: interior_color
          in: query
          required: false
          description: 'Interior colours, comma-separated, from `black`, `white`, `grey`, `silver`, `blue`, `red`, `brown`, `green`, `yellow`, `orange`, `gold`, `violet`, `pink` and `teal`.'
          schema:
            type: string
        - name: price_level
          in: query
          required: false
          description: "CarGurus deal ratings, comma-separated, from `top`, `good`, `fair`, `somewhat_expensive`, `expensive` and `outlier`. CarGurus rates a used car's price against its own estimate of the car's market value, and `outlier` is a price far from that estimate either way. Cannot be used with `condition=new`."
          schema:
            type: string
        - name: features
          in: query
          required: false
          description: 'CarGurus option names, comma-separated, as in the `features` group of `filters`, such as `Sunroof/Moonroof`. A car must have all of them. An unknown name returns an error naming the closest CarGurus options.'
          schema:
            type: string
        - name: seller_id
          in: query
          required: false
          description: "CarGurus dealer id, such as the `seller.id` of a result, to list that dealer's cars."
          schema:
            type: string
            pattern: "^\\d{1,9}$"
        - name: is_accident_free
          in: query
          required: false
          description: 'Set to `true` for cars whose history report shows no accidents. Cannot be used with `condition=new`.'
          schema:
            type: boolean
            enum: [true]
        - name: previous_owners_max
          in: query
          required: false
          description: 'Set to `1` for cars whose history report shows one owner. Cannot be used with `condition=new`.'
          schema:
            type: string
            enum: ["1"]
        - name: is_franchise_dealer
          in: query
          required: false
          description: 'Set to `true` for the cars of franchise dealers only.'
          schema:
            type: boolean
            enum: [true]
        - name: is_price_reduced
          in: query
          required: false
          description: 'Set to `true` for cars whose price has dropped.'
          schema:
            type: boolean
            enum: [true]
        - name: time_period
          in: query
          required: false
          description: 'How recently the car was listed.'
          schema:
            type: string
            enum: ["last_day", "last_2_days", "last_3_days", "last_4_days", "last_5_days", "last_6_days", "last_week", "last_2_weeks", "last_month"]
        - name: sort_by
          in: query
          required: false
          description: 'Result order. `best_deal` lists the best deals first and cannot be used with `condition=new`. Paid placements, marked `is_promoted`, can keep their own slots in any order and can repeat a car listed on another page.'
          schema:
            type: string
            enum: ["best_match", "best_deal", "price_asc", "price_desc", "mileage_asc", "mileage_desc", "distance", "model_year_desc", "model_year_asc", "newest", "oldest"]
            default: "best_match"
        - name: page
          in: query
          required: false
          description: 'Page of results. Use `pagination.next_page` for the next one.'
          schema:
            type: integer
            minimum: 1
            maximum: 400
            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 disable logging and persistent storage for this request. 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: 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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        filters:
          type: array
          description: Values the search accepts back, one group per parameter, with CarGurus' count for each.
          items:
            $ref: '#/components/schemas/Filter'
        organic_results:
          type: array
          description: Cars on this page, in CarGurus' order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Explanation of an empty result, such as a ZIP code CarGurus cannot place or a make or model id it no longer lists.
    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: "CarGurus 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: ZIP code searched around
        radius:
          type: string
          description: Distance around the ZIP code, in miles
        include_delivery:
          type: string
          description: Whether delivered cars were included
        make:
          type: string
          description: Makes searched
        model:
          type: string
          description: Models searched
        model_id:
          type: string
          description: Model ids searched
        trim:
          type: string
          description: Trims searched
        condition:
          type: string
          description: Conditions searched
        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
        model_year_min:
          type: string
          description: Value sent in model_year_min
        model_year_max:
          type: string
          description: Value sent in model_year_max
        fuel_type:
          type: string
          description: Value sent in fuel_type
        transmission:
          type: string
          description: Value sent in transmission
        body_type:
          type: string
          description: Value sent in body_type
        drivetrain:
          type: string
          description: Value sent in drivetrain
        color:
          type: string
          description: Value sent in color
        interior_color:
          type: string
          description: Value sent in interior_color
        price_level:
          type: string
          description: Value sent in price_level
        features:
          type: string
          description: Value sent in features
        seller_id:
          type: string
          description: Value sent in seller_id
        is_accident_free:
          type: string
          description: Value sent in is_accident_free
        previous_owners_max:
          type: string
          description: Value sent in previous_owners_max
        is_franchise_dealer:
          type: string
          description: Value sent in is_franchise_dealer
        is_price_reduced:
          type: string
          description: Value sent in is_price_reduced
        time_period:
          type: string
          description: Value sent in time_period
        sort_by:
          type: string
          description: Result order
        page:
          type: string
          description: Value sent in page
        zero_retention:
          type: boolean
          description: Whether persistent request and response storage is disabled.
    SearchInformation:
      type: object
      required: [results_on_page]
      properties:
        total_results:
          type: integer
          description: Number of listings CarGurus reports for the search.
        page:
          type: integer
          description: Page number of this response.
        results_on_page:
          type: integer
          description: Number of cars in `organic_results`.
        location_displayed:
          type: string
          description: Place CarGurus searched around, as it names it.
    Filter:
      type: object
      required: [key, options]
      properties:
        key:
          type: string
          description: Parameter that takes the values of the options.
          enum: ["make","model","trim","seller_id","condition","price_level","body_type","fuel_type","transmission","drivetrain","color","interior_color","features"]
        type:
          type: string
          description: CarGurus' name for the group.
        options:
          type: array
          description: Values the parameter takes, each once, in CarGurus' order.
          items:
            $ref: '#/components/schemas/FilterOption'
    FilterOption:
      type: object
      required: [value]
      properties:
        text:
          type: string
          description: CarGurus' label for the option.
        value:
          type: string
          description: Value the group's parameter takes.
        make:
          type: string
          description: Makes of the models that list a trim option in the search, comma-separated, as the `make` parameter takes them.
        model:
          type: string
          description: Models that list a trim option in the search, comma-separated, as the `model` parameter takes them.
        model_id:
          type: string
          description: Model IDs that list a trim option in the search, comma-separated, as the `model_id` parameter takes them with `make`.
        count:
          type: integer
          description: Number of listings CarGurus counts for the option, under every make or model that lists it.
        is_selected:
          type: boolean
          description: Whether this search asked for the option.
    OrganicResult:
      type: object
      required: [position, id, link, condition]
      properties:
        position:
          type: integer
          description: Rank of the car on this page, from 1.
        id:
          type: string
          description: CarGurus listing id.
        title:
          type: string
          description: Model year, make and model as CarGurus titles the listing.
        link:
          type: string
          description: The car's listing page on CarGurus.
        is_promoted:
          type: boolean
          description: Whether the row is a paid placement, which can ignore `sort_by` and repeat a car listed on another page.
        is_online_purchase:
          type: boolean
          description: Whether the car can be bought online through CarGurus.
        price:
          type: string
          description: Price as CarGurus displays it, including the `delivery` cost of a delivered car.
        extracted_price:
          type: integer
          description: Price in whole US dollars, including the `delivery` cost of a delivered car.
        previous_price:
          type: string
          description: Earlier price CarGurus shows struck through after a price drop.
        extracted_previous_price:
          type: integer
          description: Earlier price in whole US dollars.
        date_price_changed:
          type: string
          format: date-time
          description: Time of the last price drop in ISO 8601, UTC.
        msrp:
          type: string
          description: Manufacturer's suggested retail price as text.
        extracted_msrp:
          type: integer
          description: Manufacturer's suggested retail price in whole US dollars.
        price_before_fees:
          type: string
          description: Price before the dealer's fees as CarGurus displays it.
        extracted_price_before_fees:
          type: integer
          description: Price before the dealer's fees in whole US dollars.
        has_dealer_fees_included:
          type: boolean
          description: Whether CarGurus confirms the price includes the dealer's fees.
        estimated_value:
          $ref: '#/components/schemas/EstimatedValue'
        currency:
          type: string
          description: ISO 4217 code of the prices.
          enum: ["USD"]
        price_level:
          type: string
          description: CarGurus' deal rating of the price against its estimate of the car's market value, in the values `price_level` takes.
          enum: ["top","good","fair","somewhat_expensive","expensive","outlier"]
        price_level_label:
          type: string
          description: CarGurus' wording of the deal rating.
        days_on_market:
          type: integer
          description: Days since the car was listed on CarGurus.
        make:
          type: string
          description: Make name, which `make` takes.
        make_id:
          type: string
          description: CarGurus id of the make.
        model:
          type: string
          description: Model name.
        model_id:
          type: string
          description: CarGurus model id, which `model_id` takes with the car's make.
        trim:
          type: string
          description: Trim name, which `trim` takes with the car's make and model.
        model_year:
          type: integer
          description: The car's model year, which `model_year_min` and `model_year_max` filter on.
        vin:
          type: string
          description: Vehicle identification number.
        stock_number:
          type: string
          description: The dealer's stock number for the car.
        condition:
          type: string
          description: Condition, in the values `condition` takes.
          enum: ["new","used","manufacturer_certified","third_party_certified"]
        mileage:
          type: string
          description: Mileage as CarGurus displays it, with its unit.
        extracted_mileage:
          type: integer
          description: Mileage in `mileage_unit`.
        mileage_unit:
          type: string
          description: Unit of the mileage.
          enum: ["mi"]
        fuel_type:
          type: string
          description: Fuel, in the values `fuel_type` takes.
          enum: ["petrol","diesel","electric","hybrid","flex_fuel","biodiesel","cng","hydrogen","lpg"]
        fuel_type_label:
          type: string
          description: CarGurus' name for the fuel.
        transmission:
          type: string
          description: Transmission, in the values `transmission` takes.
          enum: ["automatic","manual"]
        transmission_label:
          type: string
          description: Transmission as CarGurus describes it.
        drivetrain:
          type: string
          description: Drivetrain, in the values `drivetrain` takes.
          enum: ["front","rear","all_wheel","four_wheel","four_by_two"]
        drivetrain_label:
          type: string
          description: CarGurus' name for the drivetrain.
        body_type:
          type: string
          description: Body type, in the values `body_type` takes.
          enum: ["coupe","convertible","hatchback","van","pickup","sedan","suv","transporter","station_wagon"]
        body_type_label:
          type: string
          description: CarGurus' name for the body type.
        color:
          type: string
          description: Exterior colour, in the values `color` takes.
          enum: ["black","white","grey","silver","blue","red","brown","green","yellow","orange","gold","violet","pink","teal"]
        color_label:
          type: string
          description: CarGurus' name for the exterior colour.
        manufacturer_color:
          type: string
          description: Manufacturer's name for the exterior paint.
        interior_color:
          type: string
          description: Interior colour, in the values `interior_color` takes.
          enum: ["black","white","grey","silver","blue","red","brown","green","yellow","orange","gold","violet","pink","teal"]
        interior_color_label:
          type: string
          description: CarGurus' name for the interior colour.
        motor:
          type: string
          description: Engine as CarGurus describes it.
        power:
          type: string
          description: Engine power in horsepower, as text.
        power_hp:
          type: integer
          description: Engine power in horsepower.
        doors:
          type: integer
          description: Number of doors.
        fuel_economy:
          $ref: '#/components/schemas/FuelEconomy'
        electric_range:
          type: string
          description: Electric range as CarGurus displays it, with its unit.
        extracted_electric_range:
          type: integer
          description: Electric range in `electric_range_unit`.
        electric_range_unit:
          type: string
          description: Unit of the electric range.
          enum: ["mi"]
        battery_capacity:
          type: string
          description: Battery capacity as CarGurus displays it.
        battery_capacity_kwh:
          type: number
          description: Battery capacity in kilowatt-hours.
        features:
          type: array
          description: CarGurus option names of the car, which `features` takes.
          items:
            type: string
        is_accident_free:
          type: boolean
          description: Whether the car's history report shows no accidents.
        previous_owners:
          type: integer
          description: Number of owners the car's history report shows.
        safety_rating:
          type: integer
          description: Overall safety rating in stars, from 1 to 5.
        delivery:
          $ref: '#/components/schemas/Delivery'
        extracted_distance:
          type: number
          description: Distance of the dealer from `zip`, in `distance_unit`.
        distance_unit:
          type: string
          description: Unit of `extracted_distance`.
          enum: ["mi"]
        seller:
          $ref: '#/components/schemas/Seller'
        location:
          $ref: '#/components/schemas/Location'
        thumbnail:
          type: string
          description: URL of the car's main photo.
        images_count:
          type: integer
          description: Number of photos the listing has.
    EstimatedValue:
      type: object
      description: CarGurus' estimate of the car's market value.
      required: [value]
      properties:
        value:
          type: integer
          description: Estimated market value in whole US dollars.
    FuelEconomy:
      type: object
      description: The car's fuel economy ratings.
      required: [unit]
      properties:
        city:
          type: integer
          description: City fuel economy in `unit`.
        highway:
          type: integer
          description: Highway fuel economy in `unit`.
        combined:
          type: number
          description: Combined fuel economy in `unit`.
        unit:
          type: string
          description: Unit of the fuel economy figures.
          enum: ["mpg"]
    Delivery:
      type: object
      description: How a car from a dealer farther away reaches you.
      required: [type]
      properties:
        type:
          type: string
          description: Delivery kind, a transfer to a store near you or shipping.
          enum: ["store_transfer","nationwide_shipping"]
        price:
          type: string
          description: Delivery cost as CarGurus displays it.
        extracted_price:
          type: integer
          description: Delivery cost in whole US dollars.
    Seller:
      type: object
      properties:
        id:
          type: string
          description: CarGurus dealer id, which `seller_id` takes.
        type:
          type: string
          description: Kind of seller.
          enum: ["dealer"]
        name:
          type: string
          description: Dealer's name.
        phones:
          type: array
          description: Phone numbers the dealer lists.
          items:
            type: string
        logo:
          type: string
          description: URL of the dealer's logo.
        is_franchise_dealer:
          type: boolean
          description: Whether the dealer is a franchise dealer.
        franchise_make:
          type: string
          description: Make the dealer holds a franchise for.
    Location:
      type: object
      properties:
        zip:
          type: string
          description: ZIP code of the dealer.
        city:
          type: string
          description: City of the dealer.
        state:
          type: string
          description: Two-letter USPS code of the dealer's state.
    Pagination:
      type: object
      properties:
        current_page:
          type: integer
          description: Page number of this response.
        next_page:
          type: integer
          description: Number of the next page, which `page` takes.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
