Your model-year price chart is ready for the report, but the average has shifted and you can't explain which parts changed. The label still names the same vehicle. That should make the comparison safe.
It doesn't. In catalog mode, omitting vehicleEngine selects the first matching engine. Your year, make and model label can therefore conceal a different engine-specific parts basket.
An omitted engine selects a variant; it doesn't collect every engine.
Is the price changing, or is the basket changing?
Different engine variants can require different components. If your collection resolves to a different variant, the average listing price can change even when no shared part changes price.
That leaves you with a debugging decision: compare prices within the same resolved vehicle context, or describe a difference between catalogs. Both can be useful. They answer different questions.
For future captures, make the engine selection explicit. This Example input requests a particular vehicle and part type:
import json import os import pandas as pd from apify_client import ApifyClient run_input = { "mode": "catalog", "vehicleMake": "Toyota", "vehicleModel": "Camry", "vehicleYear": 2020, "vehicleEngine": "2.5L L4", "queries": ["brake pad"], "maxResults": 200, } client = ApifyClient(os.environ["APIFY_TOKEN"]) The reusable lesson is broader than vehicle catalogs: when an optional input resolves to a particular member of a group, that resolved member belongs in your comparison key.
A tidy chart label doesn't get to overrule the collection context.
What does the catalog cover?
The Actor resolves the vehicle and part term to a catalog page, then reads its listings. This is the US catalog, with listing prices in US dollars.
That gives you a vehicle-specific assortment for the requested part type. It doesn't give you every part for the model name, every engine variant, or a history of earlier prices.
The useful coverage boundaries fit in a small table:
| Boundary | What you can establish |
|---|---|
| Vehicle selection | Catalog records expose vehicle.make, vehicle.year, vehicle.model, vehicle.engine and vehicle.carCode. |
| Category selection | queries supplies the part term; category, partGroup and partType describe the returned listing. |
| Geography | markets, when present, describes fitment markets. It doesn't measure where purchases happen. |
| Capture window | scrapedAt records capture time. Historical comparisons require retained captures. |
| Conditional fields | Unshown listing fields are omitted. details requires enrichWithPartDetails; fitment requires includeFitment. |
Keep requested and resolved context separate. The request records your intention; the returned vehicle records the selection you can audit.
submitted vehicle + part term | resolved engine | selected catalog page | filtered, capped records | comparison basket The cap and filters redraw your sample
Catalog pages avoid the keyword search's 50-row page limit, but emitted results still have a separate boundary: maxResults applies across all inputs after deduplication and filtering. It defaults to 50 and allows up to 500.
Reaching your chosen cap is a warning that the pull may be truncated. Staying below it doesn't establish coverage beyond the selected vehicle, part term and filters.
Filters also change what an average means. A manufacturer or grade restriction defines a narrower basket; a price window selects on the quantity you're trying to compare.
There's a particularly awkward catch: minPrice and maxPrice retain records without a parsed price. A price-filtered dataset can still contain rows that can't enter a price calculation.
Likewise, inStockOnly removes listings explicitly marked out of stock. Missing availability isn't confirmation of stock.
For a defensible comparison, retain the complete request beside each capture. Otherwise, a changed filter can impersonate a changed market.
Keep the request beside the resolved vehicle
This collection function preserves the submitted inputs, run status and dataset identifier, and streams the dataset rather than relying on a page of results:
def capture(): submitted = json.loads(json.dumps(run_input)) run = client.actor( "dataspryva/rockauto-catalog-price-and-fitment-lookup" ).call(run_input=submitted) return { "requested": submitted, "status": run["status"], "dataset_id": run["defaultDatasetId"], "items": list( client.dataset(run["defaultDatasetId"]).iterate_items() ), } before = capture() Run the next cell at your intended comparison time. Executing it immediately checks collection consistency; it doesn't create a historical price series.
after = capture() snapshots = {"before": before, "after": after} For recurring collection, persist each returned bundle between executions. Don't reconstruct yesterday's request from today's notebook settings.
The next cell flattens resolved vehicle fields while retaining the request separately. It also accepts top-level context fields when vehicle isn't an object, and turns missing or unparseable prices into missing values rather than zeroes:
context = ["make", "year", "model", "engine", "carCode"] listing_fields = [ "manufacturer", "partNumber", "priceUSD", "packSize", "fitmentNotes", "scrapedAt", ] rows = [] for label, snapshot in snapshots.items(): for item in snapshot["items"]: vehicle = item.get("vehicle") vehicle = vehicle if isinstance(vehicle, dict) else {} row = {field: item.get(field) for field in listing_fields} row.update({ field: vehicle.get(field, item.get(field)) for field in context }) rows.append({"snapshot": label, **row}) data = pd.DataFrame( rows, columns=["snapshot", *listing_fields, *context] ) part_key = ["manufacturer", "partNumber"] for field in [*context, *part_key]: data[field] = data[field].astype("string").str.strip() data[field] = data[field].mask(data[field].eq("")) price_text = ( data["priceUSD"].astype("string").str.strip() .str.replace(r"^\$\s*", "", regex=True) .str.replace(",", "", regex=False) ) valid_price = price_text.str.fullmatch( r"(?:\d+(?:\.\d*)?|\.\d+)", na=False ) data["price"] = pd.to_numeric( price_text.where(valid_price), errors="coerce" ) data["pack"] = pd.to_numeric(data["packSize"], errors="coerce") data["notes_key"] = data["fitmentNotes"].map( lambda value: json.dumps(value, sort_keys=True) if value is not None else "" ) data["identity_ok"] = data[part_key].notna().all(axis=1) data["context_ok"] = data[context].notna().all(axis=1) Keep part numbers as text. Numeric-looking identifiers are still identifiers, and coercing them to numbers can destroy distinctions.
Rows without usable part identity stay in the audit. That matters because an unmatched lookup returns a diagnostic record, rather than silently producing an empty dataset. We don't guess its meaning from invented diagnostic fields.
Block the join when context changes
Before calculating any price movement, measure the returned contexts, missing identities and usable prices.
This cell builds those audits and permits comparison only when both successful captures have complete, identical vehicle context, identical requests and unique part identities:
context_audit = ( data.groupby(["snapshot", *context], dropna=False) .size().rename("returned_rows").reset_index() ) coverage = data.groupby("snapshot").agg( returned_rows=("partNumber", "size"), priced_rows=("price", "count"), usable_identity_rows=("identity_ok", "sum"), complete_context_rows=("context_ok", "sum"), ).reindex(snapshots, fill_value=0) caps = pd.Series({ label: snapshot["requested"]["maxResults"] for label, snapshot in snapshots.items() }) coverage["cap_may_bind"] = coverage["returned_rows"].ge(caps) left = data.loc[data["snapshot"].eq("before")].copy() right = data.loc[data["snapshot"].eq("after")].copy() def eligible(frame): return ( not frame.empty and bool(frame["identity_ok"].all()) and bool(frame["context_ok"].all()) and not frame.duplicated(part_key).any() and len(frame[context].drop_duplicates()) == 1 ) same_context = ( left[context].drop_duplicates().reset_index(drop=True) .equals( right[context].drop_duplicates().reset_index(drop=True) ) ) comparison_ready = ( all(s["status"] == "SUCCEEDED" for s in snapshots.values()) and before["requested"] == after["requested"] and eligible(left) and eligible(right) and same_context ) comparison_state = "ready" if comparison_ready else "withheld" This gate is deliberately conservative. Duplicate manufacturer and part-number pairs need investigation before a join; averaging them away would conceal the ambiguity.
If you intentionally want a cross-engine comparison, keep the contexts separate and name that analysis explicitly. Removing the engine from the join doesn't remove its effect on assortment.
Separate matched prices from assortment changes
Once the context agrees, an outer join distinguishes shared identities from records observed only in either capture.
The price calculation below further restricts shared identities to matching known pack sizes and unchanged printed fitment notes. That avoids silently treating a changed pack or stated application as a clean price movement.
paired = pd.DataFrame() assortment_counts = pd.Series(dtype="int64") matched_prices = pd.DataFrame() if comparison_ready: before_parts = left[part_key].copy() before_parts["pack_before"] = left["pack"] before_parts["notes_key_before"] = left["notes_key"] before_parts["price_before"] = left["price"] before_parts["observed_before"] = True after_parts = right[part_key].copy() after_parts["pack_after"] = right["pack"] after_parts["notes_key_after"] = right["notes_key"] after_parts["price_after"] = right["price"] after_parts["observed_after"] = True paired = before_parts.merge( after_parts, on=part_key, how="outer", validate="one_to_one", ) seen_before = paired["observed_before"].eq(True) seen_after = paired["observed_after"].eq(True) assortment_counts = pd.Series({ "observed_only_before": (seen_before & ~seen_after).sum(), "observed_only_after": (seen_after & ~seen_before).sum(), "matched_identity": (seen_before & seen_after).sum(), }) comparable = ( seen_before & seen_after & paired["pack_before"].notna() & paired["pack_before"].eq(paired["pack_after"]) & paired["notes_key_before"].eq(paired["notes_key_after"]) & paired["price_before"].gt(0) & paired["price_after"].notna() ).fillna(False) matched_prices = paired.loc[comparable].copy() matched_prices["change_usd"] = ( matched_prices["price_after"] - matched_prices["price_before"] ) matched_prices["change_pct"] = ( matched_prices["change_usd"] .div(matched_prices["price_before"]).mul(100) ) assortment_counts measures observed entry and exit from your pulls. It doesn't establish that a product launched or disappeared from the wider catalog, particularly when a cap may bind.
matched_prices answers the narrower question: how did listing prices change for the identities that passed the comparison checks?
Keep both objects. A shared-parts comparison has its own selection effect: it excludes anything not observed in both captures.
Put the selection in the chart
The worked example uses RockAuto Catalog Price & Fitment Lookup. The analytical contract belongs in your report, regardless of how you collect the records.
Use the resolved year, make, model and engine in the chart subtitle. Retain carCode in the accompanying methodology or snapshot metadata so another analyst can inspect the exact context.
Then state the part term, filters, capture timestamps and cap status. For a price-change chart, identify the measure as matched-listing priceUSD, with the pack and fitment-note restrictions used above.
Report the matched coverage and observed assortment changes alongside it. A percentage without its surviving basket is a number waiting for a difficult meeting.
The remaining gap is demand
These records describe public listings, not transactions. They don't supply purchase volumes or reveal which parts customers actually bought.
An unweighted average therefore gives each included listing equal influence. It isn't a customer spending index, and priceUSD alone doesn't establish the amount paid at checkout.
Matching engine, identity, pack and printed notes makes the comparison more defensible. It doesn't turn catalog availability into demand.
The engine belongs beside the price, before someone asks why the basket changed.
Drafted with AI assistance and reviewed for accuracy.
