Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jakkuh/bmw-vin-decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BMW VIN Decoder

A Node.js web application that decodes BMW Vehicle Identification Numbers (VINs) using the NHTSA public API and BMW-specific VIN structure knowledge. Features SQLite caching for improved performance and a modern web interface.

Features

  • πŸš— BMW VIN Decoding: Decode 17-character BMW VINs to extract vehicle information
  • πŸ›οΈ NHTSA API Integration: Uses the official NHTSA Vehicle Product Information Catalog (vPIC) API
  • πŸ”§ BMW-Specific Decoding: Custom BMW VIN structure parsing for series, plant, model year, and more
  • πŸ’Ύ SQLite Caching: Automatic caching of results to reduce API calls and improve response times
  • πŸ“Š Statistics Dashboard: Track usage statistics including cache hits and API calls
  • 🎨 Modern UI: Clean, responsive web interface with real-time feedback
  • ⚑ Fast Performance: Cached results load instantly

What Data Can Be Decoded

NHTSA Data

  • Make, Model, Model Year
  • Vehicle Type, Body Class
  • Engine specifications (cylinders, horsepower, displacement)
  • Transmission type, Drive type
  • Fuel type
  • Manufacturing plant information
  • Series and trim information

BMW-Specific Data

  • World Manufacturer Identifier (WMI) validation
  • BMW series identification (1 Series, 3 Series, X5, etc.)
  • Body style (Sedan, Coupe, SUV, etc.)
  • Generation codes (F30, G20, etc.)
  • Assembly plant location
  • Model year decoding
  • Serial number extraction
  • Check digit validation

Future Features

  • BMW option codes (requires proprietary database access)
  • Additional BMW-specific APIs
  • Historical recall information
  • Maintenance records (if available)

Installation

  1. Clone the repository
git clone <repository-url>
cd bmw-vin-decoder
  1. Install dependencies
npm install
  1. Start the application
npm start

Or for development with auto-restart:

npm run dev
  1. Open your browser Navigate to http://localhost:3000

Usage

  1. Enter a 17-character BMW VIN in the input field
  2. Click "Decode VIN" or press Enter
  3. View the decoded information including NHTSA data and BMW-specific details
  4. Results are automatically cached for faster future lookups

Example VINs for Testing

  • WBAWC73549PD05618 (BMW 3 Series)
  • 5UXWX7C59BA123456 (BMW X5 - Spartanburg)
  • WBA3B54XF5S123456 (BMW 3 Series - Germany)

API Endpoints

POST /api/decode

Decode a VIN and return comprehensive vehicle information.

Request:

{
  "vin": "WBAWC73549PD05618"
}

Response:

{
  "vin": "WBAWC73549PD05618",
  "cached": false,
  "data": {
    "nhtsa": {
      "make": "BMW",
      "model": "3 Series",
      "modelYear": "2009",
      // ... more NHTSA data
    },
    "bmw_basic": {
      "isBMW": true,
      "wmi": {
        "code": "WBA",
        "manufacturer": "BMW AG",
        "region": "Germany"
      },
      // ... more BMW data
    },
    "bmw_options": null
  },
  "timestamp": "2024-01-15T10:30:00.000Z"
}

GET /api/stats

Get caching and usage statistics.

GET /api/search?query=WBA

Search cached VINs by partial VIN or pattern.

Architecture

bmw-vin-decoder/
β”œβ”€β”€ app.js                 # Main Express application
β”œβ”€β”€ package.json          # Dependencies and scripts
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ database.js       # SQLite operations
β”‚   β”œβ”€β”€ vinDecoder.js     # Main VIN decoding logic
β”‚   └── bmwDecoder.js     # BMW-specific VIN parsing
β”œβ”€β”€ public/
β”‚   └── index.html        # Web interface
β”œβ”€β”€ vin_cache.db          # SQLite database (auto-created)
└── README.md

BMW VIN Structure

BMW VINs follow the standard 17-character format with specific patterns:

World Manufacturer Identifier (WMI) - Positions 1-3

  • WBA: BMW AG (Germany)
  • WBS: BMW M Division (Germany)
  • 4US/5UX: BMW Manufacturing Corp (Spartanburg, USA)
  • WBY: BMW Motorrad (Motorcycles)

Vehicle Descriptor Section (VDS) - Positions 4-8

Contains model series, body style, and engine information (BMW proprietary codes)

Vehicle Identifier Section (VIS) - Positions 9-17

  • Position 9: Check digit
  • Position 10: Model year
  • Position 11: Assembly plant
  • Positions 12-17: Serial number

NHTSA API Information

This application uses the NHTSA Vehicle Product Information Catalog (vPIC) API:

  • Base URL: https://vpic.nhtsa.dot.gov/api/vehicles
  • Endpoint: /DecodeVinValues/{vin}?format=json
  • Rate Limiting: Automatically controlled by NHTSA
  • Documentation: NHTSA vPIC API

Database Schema

vin_cache table

CREATE TABLE vin_cache (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    vin TEXT UNIQUE NOT NULL,
    nhtsa_data TEXT,          -- JSON string
    bmw_basic_data TEXT,      -- JSON string
    bmw_options_data TEXT,    -- JSON string (future use)
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

cache_stats table

CREATE TABLE cache_stats (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    total_requests INTEGER DEFAULT 0,
    cache_hits INTEGER DEFAULT 0,
    api_calls INTEGER DEFAULT 0,
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
);

BMW Option Codes (Future Feature)

BMW option codes provide detailed information about factory-installed equipment and packages. Currently, this feature is not implemented due to the proprietary nature of BMW's option code databases. Potential sources for future implementation:

  • BMW ETK (Electronic Parts Catalog) - Dealer access required
  • BMW TIS (Technical Information System) - Dealer access required
  • Third-party services - Paid APIs like BimmerCode or similar
  • BMW ConnectedDrive API - Requires BMW developer partnership

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/option-codes)
  3. Commit your changes (git commit -am 'Add option codes support')
  4. Push to the branch (git push origin feature/option-codes)
  5. Create a Pull Request

Environment Variables

  • PORT: Server port (default: 3000)
  • NODE_ENV: Environment (development/production)

Error Handling

The application includes comprehensive error handling:

  • VIN format validation
  • BMW VIN verification
  • API timeout handling
  • Database error recovery
  • User-friendly error messages

Performance Considerations

  • SQLite caching reduces API calls
  • Efficient database indexing on VIN column
  • Concurrent API requests using Promise.allSettled
  • Request timeouts to prevent hanging
  • Optimized client-side rendering

License

MIT License - see LICENSE file for details

Support

For issues, questions, or contributions:

  1. Check existing issues
  2. Create a new issue with detailed description
  3. Provide example VINs for testing (if applicable)

Note: This application is for educational and informational purposes. Always verify critical vehicle information through official BMW dealers or certified sources.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published