Skip to content

Cars & vehicle safety

EPA fuel economy, NHTSA VIN decoding, recalls, complaints and crash ratings for US vehicles

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/cars/index.md to help me query Cars & vehicle safety with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Compare the fuel economy of every 2024 Toyota Tundra configuration

Example output · captured
Connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT model, drive, cylinders, city_mpg, highway_mpg, combined_mpg
FROM cars.main.vehicles(year := 2024, make := 'toyota', model := 'tundra')
ORDER BY combined_mpg DESC, model
Result · first 5 rows
model drive cylinders city_mpg highway_mpg combined_mpg
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20

Quick start

Choose where to run Cars & vehicle safety, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'cars' AS cars (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-cars-worker'
);

3. Run a query

query.sql
SELECT model, drive, cylinders, city_mpg, highway_mpg, combined_mpg
FROM cars.main.vehicles(year := 2024, make := 'toyota', model := 'tundra')
ORDER BY combined_mpg DESC, model
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'cars' AS cars (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-cars-worker'
);

Overview

US vehicle specifications, fuel economy and safety from keyless US-government sources: EPA fueleconomy.gov MPG and powertrain data since 1984, NHTSA vPIC VIN decoding, recalls, owner complaints and NCAP 5-Star crash ratings.

ATTACH options

cache_dir
Directory for the cached EPA vehicles.csv.zip (about 2 MB). Default: the per-user cache directory, e.g. ~/Library/Caches/vgi-cars or ~/.cache/vgi-cars.VARCHAR
max_age_days
Re-check fueleconomy.gov for a newer bulk file once the cached copy is this many days old.BIGINT
offline
Never download the EPA file; use the cached copy only (fails if there is none).BOOLEAN
epa_vehicles_url
URL of the EPA bulk file vehicles.csv.zip; override to use a mirror.VARCHAR
vpic_base_url
Base URL of the NHTSA vPIC API (VIN decoding, makes, models).VARCHAR
nhtsa_base_url
Base URL of api.nhtsa.gov (recalls, complaints, safety ratings).VARCHAR

Catalog

Everything cars exposes once attached — read straight from the worker's released build.

cars 1 schema
main 10 functions

Vehicle fuel economy, VIN decoding and safety functions from EPA and NHTSA.

Schema examples (10)
Examples (10)

Compare the fuel economy of every 2024 Toyota Tundra configuration

SELECT model, drive, cylinders, city_mpg, highway_mpg, combined_mpg
FROM cars.main.vehicles(year := 2024, make := 'toyota', model := 'tundra')
ORDER BY combined_mpg DESC, model;
Result · first 5 rows
model drive cylinders city_mpg highway_mpg combined_mpg
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20

Check whether the EPA file is cached and which model years it covers

SELECT cached, vehicle_rows, min_model_year, max_model_year
FROM cars.main.cache_info();

Make sure the newest EPA vehicles file is cached

SELECT status, vehicle_rows, max_model_year FROM cars.main.refresh_cache();

Passenger-car makes whose names start with A

SELECT make
FROM cars.main.makes(vehicle_type := 'car')
WHERE make LIKE 'A%'
ORDER BY make;
6 more examples

Honda's 2020 model lineup according to NHTSA

SELECT model
FROM cars.main.models('honda', year := 2020)
WHERE make = 'HONDA'
ORDER BY model;

Decode one VIN and pick out make, model, year, body and plant country

SELECT d.make, d.model, d.model_year, d.body_class, d.plant_country
FROM (SELECT cars.main.decode_vin('1HGCM82633A004352') AS d);

Decode a small list of VINs into make, model, year and electrification

SELECT vin, make, model, model_year, electrification_level
FROM cars.main.decode_vins((SELECT * FROM (VALUES ('1HGCM82633A004352'), ('5YJ3E1EA7KF317000')) AS t(vin)))
ORDER BY vin;

Air bag recalls for the 2003 Honda Accord, oldest first

SELECT campaign_number, report_received_date, component
FROM cars.main.recalls('honda', 'accord', 2003)
WHERE component LIKE 'AIR BAGS%'
ORDER BY report_received_date, campaign_number;

The five components owners complain about most for the 2003 Honda Accord

SELECT component, count(*) AS complaints
FROM (SELECT unnest(components) AS component FROM cars.main.complaints('honda', 'accord', 2003))
GROUP BY component
ORDER BY complaints DESC, component
LIMIT 5;

Crash ratings for each tested 2024 Toyota Tundra cab and drive variant

SELECT vehicle_description, overall_rating, rollover_rating, rollover_risk
FROM cars.main.safety_ratings('toyota', 'tundra', 2024)
ORDER BY vehicle_description;
Scalar functions
decode_vin (vin VARCHAR, model_year BIGINT) +1 overload 3 examples

Decode a VIN with NHTSA vPIC into a STRUCT of make, model, year, body, engine and plant

Arguments
vin VARCHAR
Vehicle Identification Number (17 characters; '*' wildcards allowed for partial VINs). NULL in, NULL out.
model_year BIGINT
Known model year for each row's VIN; NULL lets vPIC infer it from the VIN.
Overloads
decode_vin(vin VARCHAR) → STRUCT of 27 fieldsdecode_vin(vin VARCHAR, model_year BIGINT) → STRUCT of 27 fields
ReturnsSTRUCT of 27 fields
STRUCT 27 fields
  • vinVARCHAR
  • makeVARCHAR
  • modelVARCHAR
  • model_yearINTEGER
  • trimVARCHAR
  • seriesVARCHAR
  • body_classVARCHAR
  • vehicle_typeVARCHAR
  • doorsINTEGER
  • drive_typeVARCHAR
  • primary_fuelVARCHAR
  • secondary_fuelVARCHAR
  • electrification_levelVARCHAR
  • engine_cylindersINTEGER
  • displacement_lDOUBLE
  • engine_hpDOUBLE
  • turboVARCHAR
  • transmission_styleVARCHAR
  • transmission_speedsINTEGER
  • gvwr_classVARCHAR
  • manufacturerVARCHAR
  • plant_cityVARCHAR
  • plant_stateVARCHAR
  • plant_countryVARCHAR
  • error_codeVARCHAR
  • error_textVARCHAR
  • suggested_vinVARCHAR
Examples (3)

Decode one VIN and pick out make, model, year, body and plant country

SELECT d.make, d.model, d.model_year, d.body_class, d.plant_country
FROM (SELECT cars.main.decode_vin('1HGCM82633A004352') AS d);

Decode a 2003 Honda VIN and return its trim

SELECT cars.main.decode_vin('1HGCM82633A004352', 2003).trim AS trim;
SELECT cars.main.decode_vin('NOT-A-VIN!').error_code AS error_code;
SELECT cars.main.decode_vin(NULL::VARCHAR) IS NULL AS is_null;
Link
Table functions
cache_info () 1 example

Where the EPA vehicles file is cached, its vintage, size and row count (no network)

No arguments
Returns columns
status VARCHAR
What this call did: 'cached', 'downloaded', 'not_modified', 'stale', 'offline' or 'missing'.
cache_path VARCHAR
Absolute path of the cached vehicles.csv.zip.
cached BOOLEAN
TRUE when a verified copy is present in the cache.
source_url VARCHAR
URL the cached copy was downloaded from.
size_bytes BIGINT
Size of the cached zip in bytes.
sha256 VARCHAR
SHA-256 of the cached zip.
vehicle_rows BIGINT
Number of vehicle records in the cached file.
min_model_year INTEGER
Earliest model year in the cached file.
max_model_year INTEGER
Latest model year in the cached file.
upstream_last_modified VARCHAR
Last-Modified header fueleconomy.gov sent for the cached copy.
downloaded_at TIMESTAMP WITH TIME ZONE
When the cached copy was downloaded.
checked_at TIMESTAMP WITH TIME ZONE
When upstream was last checked for a newer file.
max_age_days INTEGER
Re-check interval in days.
Example

Check whether the EPA file is cached and which model years it covers

SELECT cached, vehicle_rows, min_model_year, max_model_year
FROM cars.main.cache_info();
Link
complaints (make VARCHAR, model VARCHAR, year BIGINT) 1 example

Owner complaints filed with NHTSA for a make, model and model year

Arguments
make VARCHAR
Make, case-insensitive ('honda').
model VARCHAR
Model as NHTSA names it, case-insensitive; usually the base model, for example accord.
year BIGINT
Model year of the vehicle, for example 2020.
Returns columns
odi_number BIGINT
NHTSA Office of Defects Investigation complaint number.
make VARCHAR
Make asked for, upper-cased join key.
model VARCHAR
Model asked for, upper-cased.
model_year INTEGER
Model year asked for.
manufacturer VARCHAR
Manufacturer of the vehicle.
incident_date DATE
Date of the incident, as reported by the owner.
complaint_date DATE
Date the complaint was filed with NHTSA.
crash BOOLEAN
TRUE when the complaint reports a crash.
fire BOOLEAN
TRUE when the complaint reports a fire.
injuries INTEGER
Number of injuries reported.
deaths INTEGER
Number of deaths reported.
components VARCHAR[]
Components the owner named.
summary VARCHAR
The owner's description of the problem.
vin_prefix VARCHAR
First 11 characters of the VIN as published.
Example

The five components owners complain about most for the 2003 Honda Accord

SELECT component, count(*) AS complaints
FROM (SELECT unnest(components) AS component FROM cars.main.complaints('honda', 'accord', 2003))
GROUP BY component
ORDER BY complaints DESC, component
LIMIT 5;
Link
makes (vehicle_type := VARCHAR) 1 example

Vehicle makes registered with NHTSA vPIC, optionally for one vehicle type

Named arguments
vehicle_type := VARCHAR
Only makes registered for this vPIC vehicle type; NULL (default) lists all ~12,000 registered makes, most of them trailer and specialty builders. · default null
Returns columns
make_id INTEGER
vPIC make id.
make VARCHAR
Make name, upper-cased join key.
vehicle_type VARCHAR
vPIC vehicle type when filtered by one.
Example

Passenger-car makes whose names start with A

SELECT make
FROM cars.main.makes(vehicle_type := 'car')
WHERE make LIKE 'A%'
ORDER BY make;
Link
models (make VARCHAR, vehicle_type := VARCHAR, year := BIGINT) 1 example

Models of a make from NHTSA vPIC, optionally for one model year and vehicle type

Positional arguments
make VARCHAR
Make name, case-insensitive ('honda'); partial names match in vPIC.
Named arguments
vehicle_type := VARCHAR
Only models of this vPIC vehicle type; needs `year`. · default null
year := BIGINT
Only models made in this model year; NULL lists every year. · default null
Returns columns
make_id INTEGER
vPIC make id.
make VARCHAR
Make, upper-cased join key.
model_id INTEGER
vPIC model id.
model VARCHAR
Model name as vPIC reports it.
model_year INTEGER
The model year asked for.
Example

Honda's 2020 model lineup according to NHTSA

SELECT model
FROM cars.main.models('honda', year := 2020)
WHERE make = 'HONDA'
ORDER BY model;
Link
recalls (make VARCHAR, model VARCHAR, year BIGINT) 1 example

NHTSA safety recalls for a make, model and model year

Arguments
make VARCHAR
Make, case-insensitive ('honda').
model VARCHAR
Model as NHTSA names it, case-insensitive; usually the base model, for example accord.
year BIGINT
Model year of the vehicle, for example 2020.
Returns columns
campaign_number VARCHAR
NHTSA recall campaign number.
make VARCHAR
Make, upper-cased join key.
model VARCHAR
Model as NHTSA names it.
model_year INTEGER
Model year.
manufacturer VARCHAR
Manufacturer that filed the recall.
report_received_date DATE
Date NHTSA received the manufacturer's defect report.
component VARCHAR
Affected component path.
summary VARCHAR
Description of the defect.
consequence VARCHAR
What can happen because of the defect.
remedy VARCHAR
How the manufacturer will fix it.
notes VARCHAR
Additional notes and contact information.
action_number VARCHAR
Related NHTSA investigation.
park_it BOOLEAN
TRUE when owners are told not to drive the vehicle until repaired.
park_outside BOOLEAN
TRUE when owners are told to park outside.
over_the_air_update BOOLEAN
TRUE when the remedy is an over-the-air software update.
recall_url VARCHAR
The recall's page on nhtsa.gov.
Example

Air bag recalls for the 2003 Honda Accord, oldest first

SELECT campaign_number, report_received_date, component
FROM cars.main.recalls('honda', 'accord', 2003)
WHERE component LIKE 'AIR BAGS%'
ORDER BY report_received_date, campaign_number;
Link
refresh_cache (force := BOOLEAN) 1 example

Download or re-check the EPA vehicles bulk file now and report the cache

Named arguments
force := BOOLEAN
TRUE downloads the file again even if upstream reports it unchanged; FALSE (default) sends a conditional request and keeps the cached copy when it is current. · default false
Returns columns
status VARCHAR
What this call did: 'cached', 'downloaded', 'not_modified', 'stale', 'offline' or 'missing'.
cache_path VARCHAR
Absolute path of the cached vehicles.csv.zip.
cached BOOLEAN
TRUE when a verified copy is present in the cache.
source_url VARCHAR
URL the cached copy was downloaded from.
size_bytes BIGINT
Size of the cached zip in bytes.
sha256 VARCHAR
SHA-256 of the cached zip.
vehicle_rows BIGINT
Number of vehicle records in the cached file.
min_model_year INTEGER
Earliest model year in the cached file.
max_model_year INTEGER
Latest model year in the cached file.
upstream_last_modified VARCHAR
Last-Modified header fueleconomy.gov sent for the cached copy.
downloaded_at TIMESTAMP WITH TIME ZONE
When the cached copy was downloaded.
checked_at TIMESTAMP WITH TIME ZONE
When upstream was last checked for a newer file.
max_age_days INTEGER
Re-check interval in days.
Example

Make sure the newest EPA vehicles file is cached

SELECT status, vehicle_rows, max_model_year FROM cars.main.refresh_cache();
Link
safety_ratings (make VARCHAR, model VARCHAR, year BIGINT) 1 example

NHTSA NCAP 5-Star crash ratings for each tested variant of a make, model and model year

Arguments
make VARCHAR
Make, case-insensitive ('honda').
model VARCHAR
Model as NHTSA names it, case-insensitive; usually the base model, for example accord.
year BIGINT
Model year of the vehicle, for example 2020.
Returns columns
vehicle_id BIGINT
NHTSA NCAP vehicle id.
vehicle_description VARCHAR
Tested variant.
make VARCHAR
Make, upper-cased join key.
model VARCHAR
Model as NHTSA names it.
model_year INTEGER
Model year.
overall_rating INTEGER
Overall vehicle score. NCAP stars 1-5.
overall_front_crash_rating INTEGER
Overall frontal crash rating. NCAP stars 1-5.
front_crash_driver_rating INTEGER
Frontal crash, driver side. NCAP stars 1-5.
front_crash_passenger_rating INTEGER
Frontal crash, passenger side. NCAP stars 1-5.
overall_side_crash_rating INTEGER
Overall side crash rating. NCAP stars 1-5.
side_crash_driver_rating INTEGER
Side barrier crash, driver side. NCAP stars 1-5.
side_crash_passenger_rating INTEGER
Side barrier crash, passenger side. NCAP stars 1-5.
side_pole_crash_rating INTEGER
Side pole crash. NCAP stars 1-5.
rollover_rating INTEGER
Rollover resistance. NCAP stars 1-5.
rollover_risk DOUBLE
Calculated probability of rollover in a single-vehicle crash.
dynamic_tip_result VARCHAR
Dynamic rollover test result.
electronic_stability_control VARCHAR
ESC availability.
forward_collision_warning VARCHAR
Forward collision warning availability.
lane_departure_warning VARCHAR
Lane departure warning availability.
complaints_count INTEGER
Complaints NHTSA has on file for this vehicle.
recalls_count INTEGER
Recalls NHTSA has on file for this vehicle.
investigations_count INTEGER
Defect investigations NHTSA has on file for this vehicle.
front_crash_picture_url VARCHAR
Photo from the frontal crash test.
side_crash_picture_url VARCHAR
Photo from the side crash test.
Example

Crash ratings for each tested 2024 Toyota Tundra cab and drive variant

SELECT vehicle_description, overall_rating, rollover_rating, rollover_risk
FROM cars.main.safety_ratings('toyota', 'tundra', 2024)
ORDER BY vehicle_description;
Link
vehicles (make := VARCHAR, model := VARCHAR, year := BIGINT) 2 examples

EPA fuel economy and specs for US vehicles since 1984, filterable by year, make and model

Named arguments
make := VARCHAR
Only this make, case-insensitive ('toyota'); NULL means all makes. · default null
model := VARCHAR
Only this model, case-insensitive; matches the base model ('Tundra') or the full EPA model name ('Tundra 4WD'). NULL means all models. · default null
year := BIGINT
Only this model year (1984 onward); NULL means all years. · default null
Returns columns
id BIGINT
EPA vehicle record id.
model_year INTEGER
Model year, 1984 onward.
make VARCHAR
Manufacturer brand, upper-cased so it joins with NHTSA/vPIC data.
model VARCHAR
EPA model name as published, often with drive or trim.
base_model VARCHAR
EPA base model name without drive/trim.
vehicle_class VARCHAR
EPA size class.
drive VARCHAR
Drive axle type.
transmission VARCHAR
Transmission.
transmission_notes VARCHAR
EPA transmission descriptor codes.
engine_displacement_l DOUBLE
Engine displacement in litres.
cylinders INTEGER
Number of engine cylinders.
turbocharged BOOLEAN
TRUE when the engine is turbocharged.
supercharged BOOLEAN
TRUE when the engine is supercharged.
engine_description VARCHAR
EPA engine descriptor.
electric_motor VARCHAR
Electric motor/battery description for EVs and hybrids.
fuel_type VARCHAR
Fuel summary.
primary_fuel VARCHAR
Primary fuel.
secondary_fuel VARCHAR
Secondary fuel for dual-fuel vehicles.
powertrain VARCHAR
Alternative powertrain: 'EV', 'Hybrid', 'Plug-in Hybrid', 'FFV', 'Diesel', 'CNG' .
city_mpg INTEGER
EPA city fuel economy on the primary fuel, MPG.
highway_mpg INTEGER
EPA highway fuel economy on the primary fuel, MPG.
combined_mpg INTEGER
EPA combined fuel economy on the primary fuel, MPG.
city_mpg_secondary INTEGER
City MPG on the secondary fuel.
highway_mpg_secondary INTEGER
Highway MPG on the secondary fuel.
combined_mpg_secondary INTEGER
Combined MPG on the secondary fuel.
combined_kwh_per_100mi DOUBLE
Combined electricity use in kWh per 100 miles.
electric_range_miles INTEGER
All-electric range in miles.
co2_grams_per_mile DOUBLE
Tailpipe CO2 in grams per mile on the primary fuel.
annual_fuel_cost_usd INTEGER
EPA estimated annual fuel cost on the primary fuel, US dollars.
five_year_savings_usd INTEGER
EPA 'you save/spend' over 5 years versus an average new vehicle.
fuel_economy_score INTEGER
EPA fuel economy score 1-10.
ghg_score INTEGER
EPA greenhouse gas score 1-10.
gas_guzzler BOOLEAN
TRUE when the vehicle is subject to the gas guzzler tax.
start_stop BOOLEAN
TRUE when the engine has start-stop.
charge_time_240v_hours DOUBLE
Hours to charge at 240 V.
manufacturer_code VARCHAR
EPA 3-letter manufacturer code.
created_on DATE
Date EPA created the record.
modified_on DATE
Date EPA last modified the record.
fueleconomy_url VARCHAR
This vehicle's page on fueleconomy.gov.
Examples (2)

Compare the fuel economy of every 2024 Toyota Tundra configuration

SELECT model, drive, cylinders, city_mpg, highway_mpg, combined_mpg
FROM cars.main.vehicles(year := 2024, make := 'toyota', model := 'tundra')
ORDER BY combined_mpg DESC, model;
Result · first 5 rows
model drive cylinders city_mpg highway_mpg combined_mpg
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 20 24 22
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20
Tundra 2WD Rear-Wheel Drive 6 18 23 20

Count EV models and the longest EPA range per model year since 2020

SELECT model_year, count(*) AS ev_models,
  max(electric_range_miles) AS longest_range
FROM cars.main.vehicles()
WHERE powertrain = 'EV' AND model_year >= 2020
GROUP BY model_year
ORDER BY model_year;
Link
Table in-out functions
decode_vins (data TABLE) 1 example

Decode the vin column of a query with NHTSA vPIC, one output row per input row

Arguments
data TABLE
Rows with a text column named `vin` and optionally a whole-number column `model_year`.
Returns columns
vin VARCHAR
The VIN as decoded.
make VARCHAR
Make, upper-cased join key.
model VARCHAR
Model name as vPIC reports it.
model_year INTEGER
Model year decoded from the VIN.
trim VARCHAR
Trim level.
series VARCHAR
Series designation.
body_class VARCHAR
Body class.
vehicle_type VARCHAR
NHTSA vehicle type.
doors INTEGER
Number of doors.
drive_type VARCHAR
Drive type.
primary_fuel VARCHAR
Primary fuel type.
secondary_fuel VARCHAR
Secondary fuel type for dual-fuel vehicles.
electrification_level VARCHAR
Electrification.
engine_cylinders INTEGER
Number of engine cylinders.
displacement_l DOUBLE
Engine displacement in litres.
engine_hp DOUBLE
Engine brake horsepower.
turbo VARCHAR
Turbo indicator as reported.
transmission_style VARCHAR
Transmission style.
transmission_speeds INTEGER
Number of transmission speeds.
gvwr_class VARCHAR
Gross vehicle weight rating class.
manufacturer VARCHAR
Manufacturer of record.
plant_city VARCHAR
Assembly plant city.
plant_state VARCHAR
Assembly plant state or province.
plant_country VARCHAR
Assembly plant country.
error_code VARCHAR
vPIC error codes, comma-separated.
error_text VARCHAR
vPIC explanation of the error codes.
suggested_vin VARCHAR
vPIC's corrected VIN when positions are in error.
Example

Decode a small list of VINs into make, model, year and electrification

SELECT vin, make, model, model_year, electrification_level
FROM cars.main.decode_vins((SELECT * FROM (VALUES ('1HGCM82633A004352'), ('5YJ3E1EA7KF317000')) AS t(vin)))
ORDER BY vin;
Link

Try these queries

Check whether the EPA file is cached and which model years it covers

SELECT cached, vehicle_rows, min_model_year, max_model_year
FROM cars.main.cache_info()

Uses cache_info

Make sure the newest EPA vehicles file is cached

SELECT status, vehicle_rows, max_model_year FROM cars.main.refresh_cache()

Uses refresh_cache

Passenger-car makes whose names start with A

SELECT make
FROM cars.main.makes(vehicle_type := 'car')
WHERE make LIKE 'A%'
ORDER BY make

Uses makes

Honda's 2020 model lineup according to NHTSA

SELECT model
FROM cars.main.models('honda', year := 2020)
WHERE make = 'HONDA'
ORDER BY model

Uses models

Decode one VIN and pick out make, model, year, body and plant country

SELECT d.make, d.model, d.model_year, d.body_class, d.plant_country
FROM (SELECT cars.main.decode_vin('1HGCM82633A004352') AS d)

Uses decode_vin

Decode a small list of VINs into make, model, year and electrification

SELECT vin, make, model, model_year, electrification_level
FROM cars.main.decode_vins((SELECT * FROM (VALUES ('1HGCM82633A004352'), ('5YJ3E1EA7KF317000')) AS t(vin)))
ORDER BY vin

Uses decode_vins

6 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • What make, model and model year is VIN 1HGCM82633A004352? Save a temporary table vin_answer with one row and columns make, model and model_year.
  • What overall NCAP star rating did NHTSA give the 2020 Honda Accord? Save it as a temporary table accord_rating with one row and one column stars.
  • How many makes are registered with NHTSA vPIC as passenger-car makes? Save the number as a temporary table car_makes with one row and one column makes.
  • How many distinct 2020 Honda (make HONDA) models does NHTSA vPIC list? Save the number as a temporary table honda_models with one row and one column models.

Cars & vehicle safety is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.