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
- Query Farm hosting
- Available · $10/month organization minimum
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
| 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.
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;
INSTALL vgi FROM community;
LOAD vgi;
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'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'cars' AS cars (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-cars:0.2.0'
);
3. Run a query
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
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'cars' AS cars
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
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
Query Farm operates Cars & vehicle safety for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use cars as the catalog alias for the query below.
4. Run a query
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
Technical details
- Verified connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
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'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'cars' AS cars (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-cars:0.2.0'
);
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.
Keyless US-government vehicle data in DuckDB. Look up EPA fuel economy and specifications for every US light-duty vehicle since 1984, decode VINs, and check recalls, owner complaints and crash ratings, then join them in SQL.
Sources (all US-government works in the public domain, no key needed):
- EPA fueleconomy.gov web services and bulk data
- NHTSA vPIC API for VIN decoding, makes and models
- NHTSA datasets and APIs for recalls, complaints and 5-Star Safety Ratings
Join across sources on model_year and the upper-cased make. Vehicle colors are not included: there is no free official source for them.
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.
main 10 functions
Vehicle fuel economy, VIN decoding and safety functions from EPA and NHTSA.
Schema 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;
| 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;
decode_vin (vin VARCHAR, model_year BIGINT) +1 overload
Decode a VIN with NHTSA vPIC into a STRUCT of make, model, year, body, engine and plant
decode_vin(vin VARCHAR) → STRUCT of 27 fieldsdecode_vin(vin VARCHAR, model_year BIGINT) → STRUCT of 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
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;
cache_info ()
Where the EPA vehicles file is cached, its vintage, size and row count (no network)
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();
complaints (make VARCHAR, model VARCHAR, year BIGINT)
Owner complaints filed with NHTSA for a make, model and model year
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;
makes (vehicle_type := VARCHAR)
Vehicle makes registered with NHTSA vPIC, optionally for one vehicle type
Passenger-car makes whose names start with A
SELECT make
FROM cars.main.makes(vehicle_type := 'car')
WHERE make LIKE 'A%'
ORDER BY make;
models (make VARCHAR, vehicle_type := VARCHAR, year := BIGINT)
Models of a make from NHTSA vPIC, optionally for one model year and vehicle type
Honda's 2020 model lineup according to NHTSA
SELECT model
FROM cars.main.models('honda', year := 2020)
WHERE make = 'HONDA'
ORDER BY model;
recalls (make VARCHAR, model VARCHAR, year BIGINT)
NHTSA safety recalls for a make, model and model year
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;
refresh_cache (force := BOOLEAN)
Download or re-check the EPA vehicles bulk file now and report the cache
Make sure the newest EPA vehicles file is cached
SELECT status, vehicle_rows, max_model_year FROM cars.main.refresh_cache();
safety_ratings (make VARCHAR, model VARCHAR, year BIGINT)
NHTSA NCAP 5-Star crash ratings for each tested variant of a make, model and model year
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;
vehicles (make := VARCHAR, model := VARCHAR, year := BIGINT)
EPA fuel economy and specs for US vehicles since 1984, filterable by year, make and model
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;
| 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;
decode_vins (data TABLE)
Decode the vin column of a query with NHTSA vPIC, one output row per input row
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;
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.
Related workers
CKAN
Government & civic
Search datasets and read DataStore tables from any CKAN open-data portal
Opendatasoft
Government & civic
Any Opendatasoft (Huwise) portal's catalog and records as SQL, with ODSQL pushdown
Socrata
Government & civic
Any Socrata (Tyler Data & Insights) portal's catalog and datasets as SQL, with SoQL pushdown