@meterapp/vehicle-db 2.3.0 → 2.4.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 +112 -84
- package/dist/data.d.ts +16 -1
- package/dist/data.js +2 -2
- package/dist/index.d.ts +22 -0
- package/dist/index.js +53 -5
- package/package.json +21 -8
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @meterapp/vehicle-db
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
4
|
|
|
5
|
-
|
|
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.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -10,152 +10,180 @@ Covers four vehicle types: **Passenger Car**, **Truck**, **Multipurpose Passenge
|
|
|
10
10
|
npm install @meterapp/vehicle-db
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Requires Node.js 18 or newer.
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import {
|
|
19
|
+
getDataSources,
|
|
19
20
|
getVehicleTypes,
|
|
20
21
|
getMakes,
|
|
21
22
|
getModels,
|
|
22
23
|
getAvailableYears,
|
|
23
|
-
close,
|
|
24
24
|
} from "@meterapp/vehicle-db";
|
|
25
25
|
|
|
26
|
-
//
|
|
26
|
+
// Inspect provenance and coverage before querying.
|
|
27
|
+
const sources = getDataSources();
|
|
28
|
+
|
|
29
|
+
// All seven categories, including Motorcycle (1) and Bus (5).
|
|
27
30
|
const types = getVehicleTypes();
|
|
28
|
-
// => [
|
|
29
|
-
// { vehicleTypeId: 2, vehicleTypeName: "Passenger Car" },
|
|
30
|
-
// { vehicleTypeId: 3, vehicleTypeName: "Truck" },
|
|
31
|
-
// { vehicleTypeId: 7, vehicleTypeName: "Multipurpose Passenger Vehicle (MPV)" },
|
|
32
|
-
// { vehicleTypeId: 10001, vehicleTypeName: "Auto Rickshaw" },
|
|
33
|
-
// ]
|
|
34
|
-
|
|
35
|
-
// Get all makes
|
|
36
|
-
const allMakes = getMakes();
|
|
37
|
-
|
|
38
|
-
// Get makes that have models in 2024
|
|
39
|
-
const makes2024 = getMakes({ year: 2024 });
|
|
40
|
-
|
|
41
|
-
// Get only truck makes for 2024
|
|
42
|
-
const truckMakes = getMakes({ year: 2024, vehicleTypeId: 3 });
|
|
43
|
-
|
|
44
|
-
// Get all Toyota models for 2024
|
|
45
|
-
const toyotaModels = getModels({ makeId: 474, year: 2024 });
|
|
46
|
-
// => [
|
|
47
|
-
// { modelId: 2469, modelName: "Camry", makeId: 474, makeName: "TOYOTA", vehicleTypeId: 2, vehicleTypeName: "Passenger Car" },
|
|
48
|
-
// { modelId: 2208, modelName: "Corolla", ... },
|
|
49
|
-
// ...
|
|
50
|
-
// ]
|
|
51
|
-
|
|
52
|
-
// Get only Ford trucks for 2024
|
|
53
|
-
const fordTrucks = getModels({ makeId: 460, year: 2024, vehicleTypeId: 3 });
|
|
54
|
-
// => [{ modelId: 1801, modelName: "F-150", ... }, ...]
|
|
55
|
-
|
|
56
|
-
// Get Atul auto-rickshaw models for 2024
|
|
57
|
-
const atulRickshaws = getModels({ makeId: 100001, year: 2024, vehicleTypeId: 10001 });
|
|
58
|
-
// => [{ modelId: 100001, modelName: "RIK", makeName: "ATUL AUTO", vehicleTypeName: "Auto Rickshaw", ... }, ...]
|
|
59
|
-
|
|
60
|
-
// Get all available years
|
|
61
|
-
const years = getAvailableYears();
|
|
62
|
-
// => [1990, 1991, ..., 2026]
|
|
63
31
|
|
|
64
|
-
//
|
|
65
|
-
|
|
32
|
+
// All makes with a 2024 motorcycle in the international UK fleet source.
|
|
33
|
+
const motorcycleMakes = getMakes({
|
|
34
|
+
year: 2024,
|
|
35
|
+
vehicleTypeId: 1,
|
|
36
|
+
sourceId: "uk-dft-vehicle-licensing",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Honda motorcycle models manufactured in 2024.
|
|
40
|
+
const honda = motorcycleMakes.find((make) => make.makeName === "HONDA");
|
|
41
|
+
const hondaMotorcycles = getModels({
|
|
42
|
+
makeId: honda!.makeId,
|
|
43
|
+
year: 2024,
|
|
44
|
+
vehicleTypeId: 1,
|
|
45
|
+
sourceId: "uk-dft-vehicle-licensing",
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Coach and transit bus makes/models use vehicle type 5.
|
|
49
|
+
const busMakes = getMakes({ year: 2024, vehicleTypeId: 5 });
|
|
50
|
+
const alexanderDennis = busMakes.find((make) => make.makeName === "ALEXANDER DENNIS");
|
|
51
|
+
const buses = getModels({
|
|
52
|
+
makeId: alexanderDennis!.makeId,
|
|
53
|
+
year: 2024,
|
|
54
|
+
vehicleTypeId: 5,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Existing queries remain valid.
|
|
58
|
+
const toyota = getMakes({ year: 2024 }).find((make) => make.makeName === "TOYOTA");
|
|
59
|
+
const toyotaModels = getModels({ makeId: toyota!.makeId, year: 2024 });
|
|
60
|
+
const years = getAvailableYears();
|
|
66
61
|
```
|
|
67
62
|
|
|
68
63
|
## API
|
|
69
64
|
|
|
65
|
+
### `getDataSources(): DataSource[]`
|
|
66
|
+
|
|
67
|
+
Returns the provenance, license, region, retrieval date, year range, vehicle types, and record counts for every source.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
interface DataSource {
|
|
71
|
+
sourceId: string;
|
|
72
|
+
sourceName: string;
|
|
73
|
+
sourceUrl: string;
|
|
74
|
+
license: string;
|
|
75
|
+
licenseUrl?: string;
|
|
76
|
+
region: string;
|
|
77
|
+
description: string;
|
|
78
|
+
retrievedAt: string;
|
|
79
|
+
vehicleTypeIds: number[];
|
|
80
|
+
yearFrom: number;
|
|
81
|
+
yearTo: number;
|
|
82
|
+
makeCount: number;
|
|
83
|
+
modelCount: number;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
70
87
|
### `getVehicleTypes(): VehicleType[]`
|
|
71
88
|
|
|
72
|
-
Returns
|
|
89
|
+
Returns every vehicle category in the bundled catalog.
|
|
73
90
|
|
|
74
91
|
```typescript
|
|
75
92
|
interface VehicleType {
|
|
76
|
-
vehicleTypeId: number;
|
|
77
|
-
vehicleTypeName: string;
|
|
93
|
+
vehicleTypeId: number;
|
|
94
|
+
vehicleTypeName: string;
|
|
78
95
|
}
|
|
79
96
|
```
|
|
80
97
|
|
|
81
98
|
### `getMakes(options?): Make[]`
|
|
82
99
|
|
|
83
|
-
Returns makes, optionally filtered by year and/or
|
|
100
|
+
Returns makes, optionally filtered by `year`, `vehicleTypeId`, and/or `sourceId`.
|
|
84
101
|
|
|
85
102
|
```typescript
|
|
86
|
-
getMakes()
|
|
87
|
-
getMakes({ year: 2024 })
|
|
88
|
-
getMakes({ vehicleTypeId:
|
|
89
|
-
getMakes({
|
|
90
|
-
getMakes({ year: 2024, vehicleTypeId: 10001 }) // auto-rickshaw makes in 2024
|
|
103
|
+
getMakes();
|
|
104
|
+
getMakes({ year: 2024 });
|
|
105
|
+
getMakes({ year: 2024, vehicleTypeId: 5 });
|
|
106
|
+
getMakes({ sourceId: "uk-dft-vehicle-licensing" });
|
|
91
107
|
```
|
|
92
108
|
|
|
93
109
|
```typescript
|
|
94
110
|
interface Make {
|
|
95
|
-
makeId: number;
|
|
96
|
-
makeName: string;
|
|
111
|
+
makeId: number;
|
|
112
|
+
makeName: string;
|
|
97
113
|
}
|
|
98
114
|
```
|
|
99
115
|
|
|
100
116
|
### `getModels(options?): Model[]`
|
|
101
117
|
|
|
102
|
-
Returns models, optionally filtered by year
|
|
118
|
+
Returns models, optionally filtered by `year`, `vehicleTypeId`, `makeId`, and/or `sourceId`. `sourceIds` preserves provenance when equivalent records appear in more than one source.
|
|
103
119
|
|
|
104
120
|
```typescript
|
|
105
|
-
getModels({ makeId: 474, year: 2024 })
|
|
106
|
-
getModels({
|
|
107
|
-
getModels({
|
|
108
|
-
getModels({ vehicleTypeId: 3 }) // all trucks (all years)
|
|
109
|
-
getModels({ year: 2024 }) // everything in 2024
|
|
121
|
+
getModels({ makeId: 474, year: 2024 });
|
|
122
|
+
getModels({ year: 2024, vehicleTypeId: 1 });
|
|
123
|
+
getModels({ year: 2024, vehicleTypeId: 5, sourceId: "uk-dft-vehicle-licensing" });
|
|
110
124
|
```
|
|
111
125
|
|
|
112
126
|
```typescript
|
|
113
127
|
interface Model {
|
|
114
|
-
modelId: number;
|
|
115
|
-
modelName: string;
|
|
116
|
-
makeId: number;
|
|
117
|
-
makeName: string;
|
|
118
|
-
vehicleTypeId: number;
|
|
119
|
-
vehicleTypeName: string;
|
|
128
|
+
modelId: number;
|
|
129
|
+
modelName: string;
|
|
130
|
+
makeId: number;
|
|
131
|
+
makeName: string;
|
|
132
|
+
vehicleTypeId: number;
|
|
133
|
+
vehicleTypeName: string;
|
|
134
|
+
sourceIds: string[];
|
|
120
135
|
}
|
|
121
136
|
```
|
|
122
137
|
|
|
123
138
|
### `getAvailableYears(): number[]`
|
|
124
139
|
|
|
125
|
-
Returns all years present in the
|
|
140
|
+
Returns all years present in the combined catalog, sorted ascending.
|
|
141
|
+
|
|
142
|
+
## Data sources
|
|
143
|
+
|
|
144
|
+
| Source | Coverage in this snapshot | Terms |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| [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
|
+
| [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
|
+
| [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 |
|
|
126
149
|
|
|
127
|
-
|
|
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.
|
|
128
151
|
|
|
129
|
-
|
|
152
|
+
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.
|
|
130
153
|
|
|
131
|
-
##
|
|
154
|
+
## Snapshot stats
|
|
132
155
|
|
|
133
156
|
| | |
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
157
|
+
|---|---:|
|
|
158
|
+
| Years | 1990–2026 |
|
|
159
|
+
| Sources | 3 |
|
|
160
|
+
| 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 |
|
|
142
165
|
|
|
143
|
-
##
|
|
166
|
+
## Refreshing and rebuilding
|
|
144
167
|
|
|
145
|
-
|
|
168
|
+
The committed source snapshots make the package build deterministic and offline:
|
|
146
169
|
|
|
147
170
|
```bash
|
|
148
|
-
npm run build:
|
|
171
|
+
npm run build:data
|
|
172
|
+
npm test
|
|
173
|
+
npm run typecheck
|
|
174
|
+
npm run build
|
|
149
175
|
```
|
|
150
176
|
|
|
151
|
-
|
|
177
|
+
Refresh either network source independently, then rebuild the combined catalog:
|
|
152
178
|
|
|
153
179
|
```bash
|
|
154
|
-
npm run
|
|
180
|
+
npm run refresh:uk-dft
|
|
181
|
+
npm run refresh:nhtsa -- --start-year 1990 --end-year 2026
|
|
182
|
+
npm run build:data
|
|
155
183
|
```
|
|
156
184
|
|
|
157
|
-
|
|
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.
|
|
158
186
|
|
|
159
187
|
## License
|
|
160
188
|
|
|
161
|
-
ISC
|
|
189
|
+
The package code is ISC licensed. Upstream data remains subject to the terms listed above.
|
package/dist/data.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
interface CompactData {
|
|
2
|
+
sources: {
|
|
3
|
+
source_id: string;
|
|
4
|
+
source_name: string;
|
|
5
|
+
source_url: string;
|
|
6
|
+
license: string;
|
|
7
|
+
license_url?: string;
|
|
8
|
+
region: string;
|
|
9
|
+
description: string;
|
|
10
|
+
retrieved_at: string;
|
|
11
|
+
vehicle_type_ids: number[];
|
|
12
|
+
year_from: number;
|
|
13
|
+
year_to: number;
|
|
14
|
+
make_count: number;
|
|
15
|
+
model_count: number;
|
|
16
|
+
}[];
|
|
2
17
|
vehicleTypes: {
|
|
3
18
|
vehicle_type_id: number;
|
|
4
19
|
vehicle_type_name: string;
|
|
@@ -8,7 +23,7 @@ interface CompactData {
|
|
|
8
23
|
make_name: string;
|
|
9
24
|
}[];
|
|
10
25
|
modelNames: string[];
|
|
11
|
-
models: [number, number, number, number, number][];
|
|
26
|
+
models: [number, number, number, number, number, number][];
|
|
12
27
|
}
|
|
13
28
|
declare const data: CompactData;
|
|
14
29
|
export default data;
|