@meterapp/vehicle-db 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # @meterapp/vehicle-db
2
2
 
3
- An offline, international vehicle make/model catalog for Node.js and TypeScript. The package combines U.S. model-year data, the UK registered fleet, and a manufacturer catalog into one small, zero-dependency API. It never makes runtime network requests.
3
+ An offline, international vehicle make/model catalog for Node.js and TypeScript. The package combines U.S. model-year data, the UK registered fleet, Asian-origin vehicles registered in New Zealand, Malaysian registration transactions, and an Indian manufacturer catalog into one small, zero-dependency API. It never makes runtime network requests.
4
4
 
5
- The catalog covers seven vehicle types: **Motorcycle**, **Passenger Car**, **Truck**, **Bus**, **Multipurpose Passenger Vehicle (MPV)**, **Auto Rickshaw**, and **Other Vehicle**. The UK fleet source adds European and Asian market vehicles plus motorcycles, light and heavy goods vehicles, and the explicit “Buses and coaches” category.
5
+ The current snapshot spans **1990–2026** and includes **1,145 makes**, **14,841 model names**, and **132,491 deduplicated model-year entries** from **5 data sources**.
6
+
7
+ The catalog covers seven vehicle types: **Motorcycle**, **Passenger Car**, **Truck**, **Bus**, **Multipurpose Passenger Vehicle (MPV)**, **Auto Rickshaw**, and **Other Vehicle**. The Asia-Pacific sources add Japanese domestic and kei models, Chinese EVs, Indian and Korean vehicles, Southeast Asian makes such as Perodua and Proton, and additional motorcycles and commercial vehicles.
8
+
9
+ ## Demo and playground
10
+
11
+ Want to see the API in action? Browse [Car Images](https://car-imgs.vercel.app), an example app built with this package, or explore the data directly in the [interactive playground](https://car-imgs.vercel.app/playground).
6
12
 
7
13
  ## Install
8
14
 
@@ -54,12 +60,72 @@ const buses = getModels({
54
60
  vehicleTypeId: 5,
55
61
  });
56
62
 
63
+ // Japanese domestic and kei models from the Asian-origin NZTA slice.
64
+ const nztaAsiaMakes = getMakes({
65
+ year: 2022,
66
+ sourceId: "nzta-asia-pacific-mvr",
67
+ });
68
+ const hondaAsia = nztaAsiaMakes.find((make) => make.makeName === "HONDA");
69
+ const hondaAsiaModels = getModels({
70
+ makeId: hondaAsia!.makeId,
71
+ year: 2022,
72
+ sourceId: "nzta-asia-pacific-mvr",
73
+ }); // Includes N-BOX.
74
+
75
+ // Southeast Asian market models such as Perodua Myvi and Proton S70.
76
+ const malaysiaMakes = getMakes({
77
+ year: 2026,
78
+ sourceId: "malaysia-jpj-registrations",
79
+ });
80
+
57
81
  // Existing queries remain valid.
58
82
  const toyota = getMakes({ year: 2024 }).find((make) => make.makeName === "TOYOTA");
59
83
  const toyotaModels = getModels({ makeId: toyota!.makeId, year: 2024 });
60
- const years = getAvailableYears();
84
+ const years = getAvailableYears({
85
+ makeId: toyota!.makeId,
86
+ vehicleTypeId: 2,
87
+ sourceId: "nhtsa-vpic",
88
+ });
61
89
  ```
62
90
 
91
+ ## Driver search and autocomplete
92
+
93
+ The optional, zero-dependency search entry point turns free-form driver input into canonical catalog candidates. Its index is built lazily on the first search, and matching runs entirely in memory without network requests.
94
+
95
+ ```typescript
96
+ import { searchVehicles } from "@meterapp/vehicle-db/search";
97
+
98
+ const suggestions = searchVehicles("2020 toy cam", {
99
+ sourceId: "nhtsa-vpic",
100
+ vehicleTypeId: 2,
101
+ limit: 10,
102
+ });
103
+
104
+ const camry = suggestions.find(
105
+ (result) => result.kind === "model" && result.modelName === "Camry",
106
+ );
107
+
108
+ if (camry?.kind === "model") {
109
+ // A query containing a year has one directly selectable variant.
110
+ const selection = camry.variants[0];
111
+ // Persist year, makeId, modelId, and vehicleTypeId — not display text alone.
112
+ }
113
+ ```
114
+
115
+ Search accepts year, make, and model tokens in any order. It recognizes common punctuation variants such as `F-150`/`f150` and `CR-V`/`crv`, a small set of make aliases such as `VW` and `Chevy`, and conservative misspellings. Results are ranked deterministically by exact, prefix, token, substring, then fuzzy match. Fuzzy matching is only used when no lexical result exists.
116
+
117
+ Queries without a year group a canonical make/model/type across all available years rather than returning duplicate suggestions for every year. Each model result contains `variants`, which provides the preferred catalog `modelId` for every selectable year.
118
+
119
+ For the simplest driver experience:
120
+
121
+ 1. Infer the relevant market and pass its `sourceId`; year semantics differ by source.
122
+ 2. Offer one field labelled “Search year, make, or model” and begin suggesting after two characters.
123
+ 3. If the driver enters only a year, use `getMakes({ year, ... })` for the next step; a year-only search intentionally returns no arbitrary alphabetical suggestions.
124
+ 4. On empty input, show application-owned recent vehicles. The catalog intentionally does not pretend that record frequency is vehicle popularity.
125
+ 5. Use the manual fallback Year → Make → Model. `getAvailableYears(options)` supports every step.
126
+
127
+ Applications with regional telemetry can request more candidates and rerank **within the same `matchKind`**. Text quality and market compatibility should remain ahead of behavioral popularity so an exact result never loses to an unrelated popular vehicle.
128
+
63
129
  ## API
64
130
 
65
131
  ### `getDataSources(): DataSource[]`
@@ -115,10 +181,11 @@ interface Make {
115
181
 
116
182
  ### `getModels(options?): Model[]`
117
183
 
118
- Returns models, optionally filtered by `year`, `vehicleTypeId`, `makeId`, and/or `sourceId`. `sourceIds` preserves provenance when equivalent records appear in more than one source.
184
+ Returns models, optionally filtered by `year`, `vehicleTypeId`, `makeId`, `modelId`, and/or `sourceId`. `sourceIds` preserves provenance when equivalent records appear in more than one source.
119
185
 
120
186
  ```typescript
121
187
  getModels({ makeId: 474, year: 2024 });
188
+ getModels({ modelId: 2469, year: 2024 });
122
189
  getModels({ year: 2024, vehicleTypeId: 1 });
123
190
  getModels({ year: 2024, vehicleTypeId: 5, sourceId: "uk-dft-vehicle-licensing" });
124
191
  ```
@@ -135,9 +202,21 @@ interface Model {
135
202
  }
136
203
  ```
137
204
 
138
- ### `getAvailableYears(): number[]`
205
+ ### `getAvailableYears(options?): number[]`
139
206
 
140
- Returns all years present in the combined catalog, sorted ascending.
207
+ Returns years present in the combined catalog, optionally filtered by `makeId`, `modelId`, `vehicleTypeId`, and/or `sourceId`. Results are sorted ascending.
208
+
209
+ ```typescript
210
+ getAvailableYears();
211
+ getAvailableYears({ makeId: 448, vehicleTypeId: 2, sourceId: "nhtsa-vpic" });
212
+ getAvailableYears({ modelId: 2469, sourceId: "nhtsa-vpic" });
213
+ ```
214
+
215
+ ### `searchVehicles(query, options?): VehicleSearchResult[]`
216
+
217
+ Import from `@meterapp/vehicle-db/search`. Returns deterministic make and grouped model candidates for free-form input. Options include `year`, `vehicleTypeId`, `sourceId`, `limit` (default 10, maximum 100), and `fuzzy` (default `true`).
218
+
219
+ Model results contain `years` and a year-specific `variants` array. Make results intentionally omit models, allowing applications to transition into the existing `getModels` flow after the driver chooses a make.
141
220
 
142
221
  ## Data sources
143
222
 
@@ -146,22 +225,30 @@ Returns all years present in the combined catalog, sorted ascending.
146
225
  | [NHTSA vPIC](https://vpic.nhtsa.dot.gov/api/) | U.S. passenger cars, trucks, and MPVs; model years 1990–2026 | U.S. government public data |
147
226
  | [UK DfT/DVLA vehicle licensing statistics](https://www.gov.uk/government/statistical-data-sets/vehicle-licensing-statistics-data-files) | 701 normalized makes across cars, motorcycles, goods vehicles, buses and coaches, and other vehicles; manufacture years 1990–2025 | [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) |
148
227
  | [Atul Auto product catalog](https://atulauto.co.in/products/) | Current Indian passenger and cargo auto-rickshaw range; catalog years 2024–2026 | Source attribution; factual product names only |
228
+ | [NZTA Motor Vehicle Register](https://www.nzta.govt.nz/resources/new-zealand-motor-vehicle-register-statistics/new-zealand-vehicle-fleet-open-data-sets) | 30,374 Asian-origin car, truck, bus, motorcycle, and moped model-year records from 12 countries of origin; vehicle years 1990–2026 | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) |
229
+ | [Malaysia JPJ registration transactions](https://data.gov.my/data-catalogue/registration_transactions_car) | 1,756 passenger car, MPV, jeep, pickup, and window-van model/registration-year records; 2024–2026 | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) |
149
230
 
150
- Year means the source’s model year for NHTSA, year of manufacture for DfT/DVLA (falling back to year of first use when manufacture year is unavailable), and catalog year for Atul Auto. DfT notes that its fields are administrative records and can contain classification or naming errors. Source filters let applications choose the semantics appropriate for their workflow.
231
+ Year means the source’s model year for NHTSA, year of manufacture for DfT/DVLA (falling back to year of first use when manufacture year is unavailable), catalog year for Atul Auto, vehicle year for NZTA, and registration year for Malaysia JPJ. From 2007 onward, NZTA vehicle year means the year of first registration in New Zealand or overseas. Registration sources are evidence that a make/model was present in that market and do not guarantee a factory model-year designation. Source filters let applications choose the semantics appropriate for their workflow.
151
232
 
152
233
  UK source attribution: Contains public sector information licensed under the Open Government Licence v3.0. Source: Department for Transport and Driver and Vehicle Licensing Agency.
153
234
 
235
+ NZTA and Malaysia source attribution: Licensed under Creative Commons Attribution 4.0 International. Sources: New Zealand Transport Agency Waka Kotahi and Malaysia Road Transport Department/data.gov.my.
236
+
237
+ ## Factory colors
238
+
239
+ Factory paint availability is not included. The NZTA and Malaysia records contain the observed basic color of each registered vehicle, not the manufacturer’s stock colors for a make/model/year. Treating those fields as factory availability would produce false positives from repaints, imports, and broad color categories, so the importers intentionally omit them. A future color API should require manufacturer-backed paint options with explicit market and model-year provenance.
240
+
154
241
  ## Snapshot stats
155
242
 
156
243
  | | |
157
244
  |---|---:|
158
245
  | Years | 1990–2026 |
159
- | Sources | 3 |
246
+ | Sources | 5 |
160
247
  | Vehicle types | 7 |
161
- | Makes | 1,017 |
162
- | Model names | 8,806 |
163
- | Deduplicated model-year entries | 108,308 |
164
- | Bundled TypeScript data | 3.32 MB |
248
+ | Makes | 1,145 |
249
+ | Model names | 14,841 |
250
+ | Deduplicated model-year entries | 132,491 |
251
+ | Bundled TypeScript data | 4.21 MB |
165
252
 
166
253
  ## Refreshing and rebuilding
167
254
 
@@ -179,10 +266,12 @@ Refresh either network source independently, then rebuild the combined catalog:
179
266
  ```bash
180
267
  npm run refresh:uk-dft
181
268
  npm run refresh:nhtsa -- --start-year 1990 --end-year 2026
269
+ npm run refresh:nzta-asia-pacific -- --start-year 1990 --end-year 2026
270
+ npm run refresh:malaysia-jpj -- --start-year 2024 --end-year 2026
182
271
  npm run build:data
183
272
  ```
184
273
 
185
- The NHTSA API rate-limits aggressively, so a full NHTSA refresh can take time. The UK importer downloads the two official VEH0124 CSV files to a temporary directory, keeps valid make/generic-model/year records, assigns deterministic numeric IDs to non-NHTSA entities, and deletes the raw downloads when complete.
274
+ The NHTSA API rate-limits aggressively, so a full NHTSA refresh can take time. The UK importer downloads the two official VEH0124 CSV files. The NZTA importer discovers the current official ArcGIS service and requests distinct records for supported vehicle types and Asian countries of origin. The Malaysia importer downloads annual JPJ CSVs and aggregates individual transactions into unique model/registration-year records. Importers assign deterministic numeric IDs, write normalized snapshots, and discard temporary raw downloads.
186
275
 
187
276
  ## License
188
277