Skip to main content

Motive Source

Motive (ridemotive.com) builds dealer websites as Next.js apps. A Motive site's vehicle search queries one Algolia index that all Motive dealers share. Two raw assets per market read it:

assetrowsraw source
<oem>/<market>/raw/motive_homepagesone per dealerai_public_api.dealer_providers.motive:homepages
<oem>/<market>/raw/motive_dealer_listingsone per search responseai_public_api.dealer_providers.motive:INVENTORY

The homepages asset reads the market's dealers/website_platform, described in Dealer website platform classification. The listings asset reads the homepages asset.

Dealers​

The dealers are the website_platform rows of the same partition whose platform is motive, except the rows of dealers whose websites redirected to another dealer's site, as described in Dealer website platform classification. The homepages asset requests each row's domain. No dealer file is checked in.

Credentials​

Algolia needs an application id and a search-only API key. Every Motive site's page source holds the same pair, as ALGOLIA_APP_ID and ALGOLIA_API_KEY in the Next.js env object. ai_public_api.dealer_providers.motive holds the pair as constants of the same names.

Homepage requests go through website_platform's fetch_homepages, so they retry and fall back to Zyte as described under Credentials in the website platform doc. Each homepages asset's params set the Zyte key's prefix (zyte_key_prefix: DEALER_WEBSITE) and the oem tag of each Zyte request. The market tag is the market that PublicApiRawComponent infers from the defs path.

The homepage​

A site's homepage holds the site's Motive dealer object in the Next.js payload, in a JavaScript string whose quotes are escaped:

self.__next_f.push([1,"...\"dealer\":{\"id\":2780,\"name\":\"Mercedes-Benz of Louisville\",\"domain\":\"mblouisville.com\",..."])

A raw row holds {"dealer_id": 2780}. The listings asset raises when two dealer codes' homepages name the same dealer id, because both would list that rooftop's vehicles.

website_platform does not record the dealer id in platform_params:

  • website_platform reads only the first 600,000 bytes of a homepage.
  • On some Motive homepages, the dealer object starts after byte 600,000.
  • website_platform never chooses a platform for a homepage unless it extracts all of that platform's params.

A dealer whose homepage yields no dealer id is recorded as a failed fetch attempt with one of these reasons:

reasonmeaning
unreachableno response, or a status other than 2xx or 403
refuseda 403, or a bot check in place of the homepage, after the direct retries and Zyte
no_dealer_idno dealer object on the page, after Zyte for an HTML page

A 2xx HTML page without a dealer object is fetched once more through Zyte, like a refused homepage. A 2xx body that parses as JSON is not, and the log line for the dealer includes the JSON.

A bot check is a page that website_platform recognizes as one; see Refusals.

POST https://G58LKO3ETJ-dsn.algolia.net/1/indexes/production-inventory-global_price_desc/query
X-Algolia-Application-Id: G58LKO3ETJ
X-Algolia-API-Key: <ALGOLIA_API_KEY>
{"filters": "is_active:true AND dealer_id:2780", "hitsPerPage": 1000, "page": 0}
  • The index name is the site's ALGOLIA_INVENTORY_INDEX prefix, global_ and a sort order. The site's default search uses price_desc.
  • hitsPerPage is capped at 1,000. A request for 2,000 returns 1,000 hits.
  • page numbers start at 0. A search returns at most 20 pages: an unfiltered search of 384,369 hits reports nbPages 20. The listings asset raises when a dealer's nbHits needs more than 20 pages.
  • nbHits is the number of hits the search matches.
  • The listings asset lists new and used vehicles. Each hit's car_condition is New or Used.

Group sites​

A site's own search filters on dealer_ids:"<id>". dealer_ids lists every dealer a vehicle is shared with, so a group's sites show each other's vehicles. For example, the Mercedes-Benz sites of Cincinnati (dealer code 62436, Motive id 530) and Westchester (dealer code 62437, Motive id 531) return the same vehicles, and only some of them have dealer_id 530.

The listings asset filters on dealer_id, the vehicle's own dealer, so it reads each vehicle once, from its own rooftop's site.

Vehicle fields​

A hit's fields include:

  • vin, stock_number, model_code, msrp, factory_codes and equipment_groups.
  • stock_status, which is in_stock, in_transit or in_production.
  • in_transit, a boolean field separate from stock_status.
  • on_hold, is_active and created_at.
  • dealer_id and dealer_ids; see Group sites.
  • incentives, oem_incentives and oem_conditional_incentives, which only some vehicles have.

Transformed tier​

<oem>/<market>/transformed/motive_inventory holds one row per VIN. ai_public_api.dealer_providers.motive.extract_inventory parses each hit whose car_condition is New into a MotiveVehicle. The columns shared by every dealer-website source are described in Dealer-Website Inventory.

stock_status sets in_stock and in_transit:

stock_statusin_stockin_transit
in_stocktruefalse
in_transitfalsetrue
in_productionfalsefalse

date_in_stock is the raw row's partition date less the hit's age in days. TransformedMotiveInventoryComponent (ai_public.components.motive) adds the partition date to each raw row's request parameters as partition_date, because an extractor reads only the response body and the request parameters.

date_in_stock does not use the hit's created_at. For vehicles whose arrival at the dealer the OEM's inventory feed recorded, the date age gives is closer to that arrival than created_at is.